/* NGB live search — site palette: navy #002145, gold #ECB62E, Montserrat. */

.ngb-search {
    --ngb-navy: #002145;
    --ngb-gold: #ECB62E;
    --ngb-line: #E2E7EF;
    --ngb-muted: #6B7A90;
    position: relative;
    display: flex;
    align-items: center;
    font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

/* ---- icon toggle ---- */
.ngb-search__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    background: none;
    color: currentColor;
    cursor: pointer;
}
.ngb-search__toggle svg { width: 20px; height: 20px; fill: currentColor; }
.ngb-search__toggle:focus-visible { outline: 2px solid var(--ngb-gold); outline-offset: 2px; }

/* ---- the form ----
   Absolutely positioned so it overlays the header instead of taking a slot in
   the flex row — otherwise opening it reflows the menu onto a second line. */
.ngb-search__form {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    overflow: hidden;
    width: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 100001;
    transition: width .25s ease, opacity .18s ease;
}
.ngb-search.is-open .ngb-search__form {
    width: min(34rem, 70vw);
    opacity: 1;
    pointer-events: auto;
}
.ngb-search.is-open .ngb-search__input {
    box-shadow: 0 8px 28px rgba(0, 33, 69, 0.28);
}

/* a soft scrim across the header while searching — remove this block if you
   would rather the header stayed fully visible */
.ngb-search__scrim {
    position: absolute;
    top: 50%;
    right: -1rem;
    transform: translateY(-50%);
    height: 200%;
    width: 0;
    background: linear-gradient(to left, rgba(0, 33, 69, 0.96) 70%, rgba(0, 33, 69, 0));
    opacity: 0;
    pointer-events: none;
    transition: width .25s ease, opacity .2s ease;
    z-index: 100000;
}
.ngb-search__scrim { display: none; }   /* replaced by dimming the header itself */

/* inline mode keeps the old in-flow behaviour */
.ngb-search.is-inline .ngb-search__form {
    position: static;
    transform: none;
    width: 100%;
    opacity: 1;
    pointer-events: auto;
}
.ngb-search.is-inline .ngb-search__toggle,
.ngb-search.is-inline .ngb-search__scrim { display: none; }

.ngb-search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 2.25rem 0 0.9rem;
    border: 1px solid var(--ngb-line);
    border-radius: 0;
    background: #fff;
    color: var(--ngb-navy);
    font: 500 15px/1 'Montserrat', sans-serif;
}
.ngb-search__input::placeholder { color: var(--ngb-muted); font-weight: 400; }
.ngb-search__input:focus { outline: none; border-color: var(--ngb-navy); }

.ngb-search__clear {
    position: absolute;
    right: 0.6rem;
    border: 0;
    background: none;
    color: var(--ngb-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem;
}
.ngb-search__clear { display: none; z-index: 2; }
/* visible only while the field has text — :placeholder-shown means it is empty,
   so this needs no JS and cannot get out of sync */
.ngb-search__input:not(:placeholder-shown) ~ .ngb-search__clear { display: block; }
.ngb-search__clear:hover { color: var(--ngb-navy); }

@media (prefers-reduced-motion: reduce) {
    .ngb-search__form { transition: none; }
}

/* ---- dropdown ---- */
.ngb-ls {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    width: min(34rem, 92vw);
    max-height: min(62vh, 34rem);
    /* dvh shrinks with the on-screen keyboard; JS refines this further */
    max-height: min(62dvh, 34rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border: 1px solid var(--ngb-line, #E2E7EF);
    box-shadow: 0 14px 40px rgba(0, 33, 69, 0.16);
    z-index: 100000;
    font-family: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
    text-align: left;
}
.ngb-ls[hidden] { display: none; }

.ngb-ls__head {
    padding: 0.7rem 1rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6B7A90;
}

/* categories */
.ngb-ls__cats { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1rem 0.6rem; }
.ngb-ls__cat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.32rem 0.6rem;
    border: 1px solid #E2E7EF;
    color: #002145;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
}
.ngb-ls__cat span { color: #6B7A90; font-weight: 500; font-size: 0.75rem; }
.ngb-ls__cat:hover, .ngb-ls__cat.is-active { border-color: #002145; background: #F5F8FC; }

/* product rows */
.ngb-ls__row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid #EEF2F7;
    color: #002145;
    text-decoration: none;
}
.ngb-ls__row:first-child { border-top: 0; }
.ngb-ls__row:hover, .ngb-ls__row.is-active { background: #F5F8FC; }

.ngb-ls__img {
    flex: 0 0 auto;
    width: 52px; height: 52px;
    object-fit: contain;
    background: #fff;
}
.ngb-ls__img--none { background: #F1F4F9; }

.ngb-ls__text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.ngb-ls__meta {
    font-size: 0.7rem;
    color: #6B7A90;
    letter-spacing: 0.02em;
}
.ngb-ls__title { font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.ngb-ls__codes { font-size: 0.75rem; color: #6B7A90; }

.ngb-ls mark {
    background: rgba(236, 182, 46, 0.38);
    color: inherit;
    padding: 0 0.05em;
}

/* footer + empty */
.ngb-ls__all {
    display: block;
    padding: 0.75rem 1rem;
    border-top: 1px solid #E2E7EF;
    background: #002145;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}
.ngb-ls__all:hover, .ngb-ls__all.is-active { background: #013467; color: #fff; }

.ngb-ls__empty { padding: 1.1rem 1rem 1.25rem; color: #002145; font-size: 0.9rem; }
.ngb-ls__empty b { font-weight: 700; }
.ngb-ls__empty span { display: block; margin-top: 0.3rem; color: #6B7A90; font-size: 0.82rem; }

@media (max-width: 767px) {
    /* the form is absolutely positioned inside an icon-sized box, so a
       percentage width would resolve to the icon — use viewport units */
    .ngb-search.is-open .ngb-search__form { width: min(88vw, 22rem); }
    .ngb-search__input { height: 42px; font-size: 16px; }  /* 16px stops iOS zooming on focus */

    /* white on the navy header bar, rather than inheriting the gold */
    .ngb-search__toggle { color: #fff; }
    .ngb-search__toggle svg { fill: #fff; }
    .ngb-ls { width: min(94vw, 26rem); max-height: min(52dvh, 26rem); }
}

/* An external trigger (header button #searchicon) replaces the component's own icon. */
.ngb-search.has-external-trigger .ngb-search__toggle { display: none; }


/* The browser draws its own clear button on input[type=search]; we have our own. */
.ngb-search__input::-webkit-search-cancel-button,
.ngb-search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.ngb-search__input::-ms-clear { display: none; }

/* While searching, fade the rest of the HEADER back so the input owns the bar.
   Scoped to [data-elementor-type="header"] — without that it dims every button
   and menu on the page, not just the ones in the header. */
body.ngb-search-open [data-elementor-type="header"] .elementor-nav-menu,
body.ngb-search-open [data-elementor-type="header"] .elementor-widget-theme-site-logo,
body.ngb-search-open [data-elementor-type="header"] .elementor-widget-button:not(:has(#searchicon)) {
    opacity: 0.22;
    transition: opacity .2s ease;
    pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
    body.ngb-search-open [data-elementor-type="header"] .elementor-nav-menu,
    body.ngb-search-open [data-elementor-type="header"] .elementor-widget-theme-site-logo { transition: none; }
}

/* ---- search button inside the field ----
   Gold like every other "act" button on the site; takes the input's full height
   minus a 4px inset. The clear × moves left to make room. */
.ngb-search__input { padding-right: 86px !important; }
.ngb-search__submit {
    position: absolute;
    top: 4px;
    right: 4px;
    bottom: 4px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: var(--ngb-gold);
    color: var(--ngb-navy);
    cursor: pointer;
    z-index: 2;
    transition: background-color .15s ease, color .15s ease;
}
.ngb-search__submit svg { width: 18px; height: 18px; fill: currentColor; }
.ngb-search__submit:hover,
.ngb-search__submit:focus-visible { background: var(--ngb-navy); color: #fff; }
.ngb-search__clear { right: 46px !important; }

/* ---- "Otkaži" (phones only) ---- */
.ngb-search__cancel { display: none; }

@media (max-width: 767px) {
    .ngb-search.is-open .ngb-search__form { width: auto; transition: opacity .18s ease; }
    .ngb-search.is-open .ngb-search__cancel {
        display: block;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        z-index: 100002;
        padding: 10px 0 10px 4px;
        border: 0;
        background: none;
        color: #fff;
        font: 600 15px/1 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
        white-space: nowrap;
        cursor: pointer;
    }
    .ngb-search__cancel:focus-visible { outline: 2px solid var(--ngb-gold); outline-offset: 2px; }

    /* the open search covers the header row: hide what would peek out behind it */
    body.ngb-search-open [data-elementor-type="header"] .elementor-widget-image,
    body.ngb-search-open [data-elementor-type="header"] .elementor-menu-toggle,
    body.ngb-search-open [data-elementor-type="header"] .elementor-widget-button { visibility: hidden; }
}

/* header stays on screen while searching: scrolling through the live results
   must not carry the field (and the "Otkaži" button) away. Only while the
   search is open — normal browsing keeps the header scrolling as before. */
body.ngb-search-open [data-elementor-type="header"] {
    position: sticky;
    top: 0;
    z-index: 1000;
}
/* logged-in editors: sit below the admin bar (it only stays fixed above 600px) */
@media (min-width: 601px) {
    body.admin-bar.ngb-search-open [data-elementor-type="header"] { top: var(--wp-admin--admin-bar--height, 32px); }
}

/* close button is an icon (✕), not a word; and neither search button may take
   the theme's pink button background on tap/focus — that is what showed as a
   red box behind the old "Otkaži" */
.ngb-search__cancel, .ngb-search__cancel:hover, .ngb-search__cancel:focus, .ngb-search__cancel:active,
.ngb-search__toggle, .ngb-search__toggle:hover, .ngb-search__toggle:focus, .ngb-search__toggle:active {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
.ngb-search__cancel, .ngb-search__cancel:hover, .ngb-search__cancel:focus, .ngb-search__cancel:active { color: #fff !important; }
.ngb-search__cancel svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

@media (max-width: 767px) {
    .ngb-search.is-open .ngb-search__cancel {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0 !important;
    }
    /* the component's own icon sits exactly where the ✕ goes — hide it while open */
    .ngb-search.is-open .ngb-search__toggle { visibility: hidden; }
}

/* opening on phones: the icon that was tapped disappears at once (the header's
   hide rules fade, which left it under the ✕ for a moment), then the ✕ fades
   in just after — the two are never on screen together */
@media (max-width: 767px) {
    .ngb-search.is-open .ngb-search__toggle,
    body.ngb-search-open [data-elementor-type="header"] .elementor-widget-button {
        visibility: hidden !important;
        opacity: 0 !important;
        transition: none !important;
    }
    .ngb-search.is-open .ngb-search__cancel { animation: ngb-cancel-in .18s ease .1s both; }
}
@keyframes ngb-cancel-in {
    from { opacity: 0; transform: translateY(-50%) scale(.8); }
    to   { opacity: 1; transform: translateY(-50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .ngb-search.is-open .ngb-search__cancel { animation: none; }
}
