/* ==========================================================================
   חיפוש חכם באתר — ד"ר אבי שזר
   תוסף Progressive Enhancement. משתמש בטוקני המותג הקיימים (style.css :root)
   עם ערכי fallback. RTL. נטען בכל העמודים אך לא נוגע ב-markup קיים.
   ========================================================================== */

/* ---- כפתור ההפעלה (זכוכית מגדלת) בתוך ה-header ---- */
.ss-trigger {
    --ss-blue: var(--primary-blue, #33658A);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-inline-start: auto;      /* מקבץ את הכפתור + ההמבורגר לקצה (שמאל ב-RTL) */
    padding: 0;
    background: none;
    border: none;
    border-radius: 9999px;
    color: var(--ss-blue);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.ss-trigger:hover { background-color: rgba(51, 101, 138, 0.08); }
.ss-trigger:active { transform: scale(0.92); }
.ss-trigger:focus-visible {
    outline: 2px solid var(--ss-blue);
    outline-offset: 2px;
}
.ss-trigger svg { width: 23px; height: 23px; pointer-events: none; }

/* בדסקטופ ה-nav-menu גדל וממלא — נשאיר רווח קטן לפני קו ההפרדה */
@media (min-width: 993px) {
    .ss-trigger { margin-inline-end: 0.25rem; }
}

/* כוונון header במובייל: הלוגו+הכיתוב בשורה אחת, וכפתור החיפוש מוזז שמאלה
   קרוב להמבורגר אך עם רווח קטן (לא צמוד). מתאזן עם נקודת השבירה של האתר (768px). */
@media (max-width: 768px) {
    .header .nav-container { gap: 0.6rem; }   /* רווח קטן בין 🔍 ל-☰ (במקום 2rem) */
    /* גופן נזיל: גדל עם רוחב המסך אך אף פעם לא נשבר לשתי שורות.
       ~1rem במסכים זעירים (320px), עד 1.3rem במסכים גדולים. */
    .header .logo { font-size: clamp(1.2rem, 5.2vw, 1.4rem); }
}

/* טווח הביניים (טאבלט צר 769–991px): ה-nav האופקי המלא כבר צפוף מראש שם,
   ולכן מסתירים את כפתור החיפוש כדי לא להוסיף לחץ על הפריסה.
   החיפוש זמין במובייל (≤768px) ובדסקטופ (≥992px). */
@media (min-width: 769px) and (max-width: 991px) {
    .ss-trigger { display: none; }
}

/* ---- שכבת הרקע (Scrim) ---- */
.ss-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;                  /* מתחת לווידג'ט הנגישות (10000) */
    display: none;
    justify-content: center;
    align-items: flex-start;
    background: rgba(45, 55, 72, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    direction: rtl;
}
.ss-overlay.is-open { display: flex; }

body.ss-lock { overflow: hidden; }   /* נעילת גלילת רקע */

/* ---- חלון החיפוש: מובייל = מסך מלא ---- */
.ss-modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    background: var(--white, #fff);
    color: var(--text-dark, #2D3748);
    overflow: hidden;
    font-family: inherit;
    animation: ss-pop 0.22s ease-out;
}
@keyframes ss-pop {
    from { opacity: 0; transform: translateY(-8px) scale(0.99); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- חלון החיפוש: דסקטופ = מודאל ממורכז ---- */
@media (min-width: 768px) {
    .ss-overlay { align-items: flex-start; padding: 8vh 1rem 2rem; }
    .ss-modal {
        width: 100%;
        max-width: 640px;
        height: auto;
        min-height: 0;
        max-height: 80vh;
        border-radius: var(--radius-lg, 24px);
        box-shadow: var(--shadow-lg, 0 15px 30px rgba(51, 101, 138, 0.15));
    }
}

/* ---- שורת החיפוש (sticky למעלה) ---- */
.ss-search-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color, #E2E8F0);
    background: var(--white, #fff);
    flex-shrink: 0;
}
.ss-field {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-light, #F7F9FC);
    border: 1.5px solid var(--border-color, #E2E8F0);
    border-radius: 9999px;
    padding: 0 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ss-field:focus-within {
    border-color: var(--primary-blue, #33658A);
    box-shadow: 0 0 0 3px rgba(51, 101, 138, 0.12);
}
.ss-field > svg { width: 20px; height: 20px; color: var(--text-muted, #4A5568); flex-shrink: 0; }
.ss-input {
    flex: 1;
    height: 50px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;                /* מונע zoom אוטומטי ב-iOS */
    font-family: inherit;
    color: var(--text-dark, #2D3748);
    padding: 0 0.6rem;
}
.ss-input::placeholder { color: var(--text-muted, #4A5568); opacity: 0.8; }
/* הסתרת כפתור הניקוי המובנה של הדפדפן (משאירים רק את ה-✕ שלנו) */
.ss-input::-webkit-search-cancel-button,
.ss-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.ss-clear {
    display: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(45, 55, 72, 0.12);
    color: var(--text-dark, #2D3748);
    border-radius: 9999px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 15px;
    line-height: 1;
}
.ss-field.has-text .ss-clear { display: inline-flex; }
.ss-close {
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--primary-blue, #33658A);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.5rem 0.4rem;
    border-radius: 8px;
    white-space: nowrap;
}
.ss-close:hover { background: var(--bg-light, #F7F9FC); }
.ss-close:focus-visible { outline: 2px solid var(--primary-blue, #33658A); outline-offset: 2px; }

/* ---- גוף תוצאות / מצבים (גלילה) ---- */
.ss-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0 1.25rem;
}
.ss-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted, #4A5568);
    letter-spacing: 0.02em;
    padding: 0.9rem 1.25rem 0.4rem;
    margin: 0;
}

/* ---- שורת תוצאה ---- */
.ss-result {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 0.7rem 1.25rem;
    border-inline-start: 3px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.ss-result:hover,
.ss-result.is-active {
    background: var(--bg-light, #F7F9FC);
    border-inline-start-color: var(--primary-blue, #33658A);
}
.ss-result:focus-visible {
    outline: 2px solid var(--primary-blue, #33658A);
    outline-offset: -2px;
}
.ss-result-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}
.ss-result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark, #2D3748);
    line-height: 1.35;
}
.ss-chip {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary-blue, #33658A);
    background: rgba(51, 101, 138, 0.09);
    border-radius: 9999px;
    padding: 0.15rem 0.55rem;
    white-space: nowrap;
}
.ss-result-desc {
    font-size: 0.85rem;
    color: var(--text-muted, #4A5568);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ss-hl { background: rgba(45, 212, 191, 0.30); border-radius: 3px; padding: 0 1px; font-weight: 700; }

/* ---- צ'יפים של חיפושים נפוצים ---- */
.ss-popular {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.3rem 1.25rem 0.5rem;
}
.ss-pchip {
    border: 1.5px solid var(--border-color, #E2E8F0);
    background: var(--white, #fff);
    color: var(--text-dark, #2D3748);
    border-radius: 9999px;
    padding: 0.45rem 0.95rem;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
}
.ss-pchip:hover {
    border-color: var(--primary-blue, #33658A);
    color: var(--primary-blue, #33658A);
    background: var(--bg-light, #F7F9FC);
}
.ss-pchip:focus-visible { outline: 2px solid var(--primary-blue, #33658A); outline-offset: 2px; }

/* ---- מצב אין-תוצאות ---- */
.ss-noresults { padding: 2rem 1.5rem; text-align: center; }
.ss-noresults-icon { color: var(--accent-turquoise, #98C1D9); margin-bottom: 0.5rem; }
.ss-noresults-title { font-size: 1.05rem; font-weight: 700; color: var(--text-dark, #2D3748); margin: 0 0 0.35rem; }
.ss-noresults-sub { font-size: 0.9rem; color: var(--text-muted, #4A5568); margin: 0 0 1.25rem; }
.ss-cta-row { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.ss-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.6rem 1.2rem;
    border-radius: 9999px;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.ss-cta:active { transform: scale(0.97); }
.ss-cta--wa { background: var(--accent-green, #2dd4bf); color: #fff; }
.ss-cta--tel { background: var(--primary-blue, #33658A); color: #fff; }
.ss-cta svg { width: 17px; height: 17px; }

/* ---- כיבוד העדפת תנועה מופחתת ---- */
@media (prefers-reduced-motion: reduce) {
    .ss-modal { animation: none; }
    .ss-trigger:active { transform: none; }
    .ss-cta:active { transform: none; }
    .ss-result, .ss-pchip, .ss-trigger { transition: none; }
}
