/* Minh Tâm Bảo - Global header search V1 */
.mtb-header-search {
    position: relative;
    margin-left: 10px;
}

.mtb-header-search__form {
    width: 230px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid rgba(20,45,39,.14);
    border-radius: 12px;
    background: #f8f9f7;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.mtb-header-search__form:focus-within {
    border-color: #b99552;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(185,149,82,.12);
}

.mtb-header-search__icon {
    flex: 0 0 auto;
    color: #9b7a3e;
    font-size: .9rem;
}

.mtb-header-search__input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 0;
    background: transparent;
    color: #142d27;
    font-size: .84rem;
}

.mtb-header-search__input::placeholder {
    color: #84938e;
}

.mtb-header-search__submit,
.mtb-header-search__mobile-toggle {
    border: 0;
    background: transparent;
    color: #17392f;
    cursor: pointer;
}

.mtb-header-search__submit {
    display: none;
}

.mtb-header-search__results {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 10px);
    right: 0;
    width: min(430px, calc(100vw - 24px));
    max-height: min(70vh, 620px);
    overflow-y: auto;
    border: 1px solid rgba(20,45,39,.10);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(20,45,39,.18);
}

.mtb-header-search__results[hidden] {
    display: none !important;
}

.mtb-search-state {
    padding: 18px;
    color: #65756f;
    font-size: .88rem;
    text-align: center;
}

.mtb-search-group + .mtb-search-group {
    border-top: 1px solid rgba(20,45,39,.08);
}

.mtb-search-group__title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 7px;
    color: #9b7a3e;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.mtb-search-result {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 14px;
    color: #17392f;
    text-decoration: none;
    transition: background .18s ease;
}

.mtb-search-result:hover,
.mtb-search-result:focus {
    background: #f7f5ef;
    color: #17392f;
}

.mtb-search-result__image {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    object-fit: cover;
    border-radius: 11px;
    background: #f3f1e9;
}

.mtb-search-result__body {
    min-width: 0;
    flex: 1;
}

.mtb-search-result__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.35;
}

.mtb-search-result__meta {
    margin-top: 4px;
    color: #7b8a84;
    font-size: .75rem;
}

.mtb-search-result__price {
    color: #9b7a3e;
    font-weight: 800;
}

.mtb-search-view-all {
    display: block;
    padding: 12px 14px;
    border-top: 1px solid rgba(20,45,39,.08);
    color: #17392f;
    text-align: center;
    font-size: .82rem;
    font-weight: 800;
    text-decoration: none;
}

.mtb-search-view-all:hover {
    color: #9b7a3e;
    background: #fbfaf6;
}

.mtb-header-search__mobile-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f7f8f6;
    border: 1px solid rgba(20,45,39,.12);
}

.mtb-header-search-mobile-panel {
    display: none;
}

@media (max-width: 1399px) and (min-width: 1200px) {
    .mtb-header-search__form {
        width: 175px;
    }

    .mtb-navbar__nav {
        gap: 1px;
    }

    .mtb-navbar__link {
        padding-left: 10px;
        padding-right: 10px;
        font-size: .88rem;
    }

    .mtb-language-switcher {
        margin-left: 7px;
        padding-left: 7px;
    }

    .mtb-language-switcher select {
        max-width: 120px;
    }
}

@media (max-width: 1199px) and (min-width: 992px) {
    .mtb-header-search {
        margin-left: 5px;
    }

    .mtb-header-search__form {
        width: 125px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .mtb-navbar__nav {
        gap: 0;
    }

    .mtb-navbar__link {
        padding-left: 6px;
        padding-right: 6px;
        font-size: .82rem;
    }

    .mtb-navbar__brand img.logo-main {
        height: 42px;
    }

    .mtb-language-switcher {
        margin-left: 5px;
        padding-left: 5px;
    }

    .mtb-language-switcher select {
        max-width: 105px;
        font-size: .78rem;
    }
}

@media (max-width: 991px) {
    .mtb-header-search--desktop {
        display: none;
    }

    .mtb-header-search__mobile-toggle {
        display: inline-flex;
    }

    .mtb-header-search-mobile-panel {
        position: absolute;
        z-index: 1190;
        top: 100%;
        left: 0;
        right: 0;
        padding: 12px 16px 16px;
        background: #fff;
        border-top: 1px solid rgba(20,45,39,.08);
        box-shadow: 0 14px 28px rgba(20,45,39,.12);
    }

    .mtb-header-search-mobile-panel.is-open {
        display: block;
    }

    .mtb-header-search-mobile-panel .mtb-header-search {
        margin: 0;
    }

    .mtb-header-search-mobile-panel .mtb-header-search__form {
        width: 100%;
        height: 46px;
    }

    .mtb-header-search-mobile-panel .mtb-header-search__results {
        position: static;
        width: 100%;
        max-height: 58vh;
        margin-top: 8px;
        box-shadow: none;
        border-radius: 14px;
    }
}

@media (max-width: 575px) {
    .mtb-header-search__mobile-toggle {
        width: 38px;
        height: 38px;
    }

    .mtb-header-search-mobile-panel {
        padding: 10px 10px 14px;
    }
}


/* V2: search in the upper brand-colored bar, instead of taking menu space.
   Keep the same inputs, API handlers, results and locale behavior. */
.mtb-topbar .mtb-topbar__search {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    min-width: 0;
}

.mtb-topbar .mtb-header-search--desktop {
    margin: 0;
    width: min(340px, 100%);
}

.mtb-topbar .mtb-header-search--desktop .mtb-header-search__form {
    width: 100%;
    height: 32px;
    border-color: rgba(255,255,255,.4);
    border-radius: 9px;
    padding: 0 12px;
    background: rgba(255,255,255,.97);
}

.mtb-topbar .mtb-header-search__form:focus-within {
    border-color: var(--mtb-theme-header-accent, #dbbd84);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(255,255,255,.22);
}

.mtb-topbar .mtb-header-search__form .mtb-header-search__icon {
    color: #946c2a;
}

.mtb-topbar .mtb-header-search__form .mtb-header-search__input {
    color: #17392f;
    font-size: .8rem;
    letter-spacing: normal;
}

.mtb-topbar .mtb-header-search__form .mtb-header-search__input::placeholder {
    color: #6b7975;
    opacity: 1;
}

/* The top bar is raised over the sticky menu, so the results dropdown
   remains clickable below the bar at every desktop viewport size. */
.mtb-topbar {
    position: relative;
    z-index: 1060;
    overflow: visible;
}

.mtb-topbar .mtb-header-search__results {
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    font-family: "Roboto", "Segoe UI", Arial, sans-serif;
    letter-spacing: normal;
}

/* Published Admin theme forces white text on the upper bar.
   Its white-on-red rules must not leak into the white search popup. */
html[data-mtb-theme="enabled"] body .mtb-topbar .mtb-header-search__form .mtb-header-search__icon {
    color: var(--mtb-theme-header-accent, #946c2a) !important;
}

html[data-mtb-theme="enabled"] body .mtb-topbar .mtb-header-search__results a.mtb-search-result,
html[data-mtb-theme="enabled"] body .mtb-topbar .mtb-header-search__results a.mtb-search-view-all {
    color: #17392f !important;
}

html[data-mtb-theme="enabled"] body .mtb-topbar .mtb-header-search__results a.mtb-search-result:hover,
html[data-mtb-theme="enabled"] body .mtb-topbar .mtb-header-search__results a.mtb-search-view-all:hover {
    color: #946c2a !important;
}

@media (max-width: 991px) {
    /* On narrower displays the red bar hosts a compact search button;
       the original API-backed search panel remains just below the menu. */
    .mtb-topbar .mtb-header-search--desktop {
        display: none;
    }

    .mtb-topbar .mtb-header-search__mobile-toggle {
        display: inline-flex;
        width: 32px;
        height: 32px;
        border: 1px solid rgba(255,255,255,.35);
        border-radius: 8px;
        background: rgba(255,255,255,.10);
        color: #fff;
        flex: 0 0 auto;
    }

    .mtb-topbar .mtb-header-search__mobile-toggle:hover,
    .mtb-topbar .mtb-header-search__mobile-toggle[aria-expanded="true"] {
        background: rgba(255,255,255,.23);
        color: #fff;
    }
}

@media (max-width: 575px) {
    .mtb-topbar .mtb-header-search__mobile-toggle {
        width: 30px;
        height: 30px;
    }
}
