/* ─── Scroll lock ───────────────────────────────────────────────── */
html.mw-no-scroll,
html.mw-no-scroll body { overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════════
   MOBILE FULL-SCREEN OVERLAY  (iHerb-style)
   Created by JS and appended directly to <body> — no transform
   ancestor issues with position:fixed.
   ═══════════════════════════════════════════════════════════════════ */
#mw-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999999;
    background: #fff;
    flex-direction: column;
    overflow: hidden;
}
#mw-mobile-overlay.mw-mob-active { display: flex; }

/* Header row: input + Cancel */
.mw-mob-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}
.mw-mob-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.mw-mob-search-icon {
    position: absolute;
    left: 12px;
    pointer-events: none;
    flex-shrink: 0;
}
[dir="rtl"] .mw-mob-search-icon { left: auto; right: 12px; }

#mw-mob-input {
    width: 100%;
    height: 42px;
    border: 1.5px solid #e0e0e0;
    border-radius: 22px;
    padding: 0 14px 0 36px;
    font-size: 16px; /* 16px prevents iOS auto-zoom */
    outline: none;
    background: #f5f5f5;
    color: #111;
    -webkit-appearance: none;
    box-sizing: border-box;
}
[dir="rtl"] #mw-mob-input { padding: 0 36px 0 14px; }
#mw-mob-input:focus { border-color: #4f2964; background: #fff; }

.mw-mob-cancel-btn {
    background: none;
    border: none;
    color: #4f2964;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 0 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Scrollable results area */
.mw-mob-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Reset the autocomplete container and panel inside the overlay */
.mw-mob-results #search_autocomplete {
    display: block !important;
    overflow: visible !important;
    position: static !important;
    margin: 0 !important;
    z-index: auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.mw-mob-results .mw-ac {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-width: 0 !important;
    overflow: visible !important;
    max-height: none !important;
}
.mw-mob-results .mw-ac-body   { flex-direction: column; min-height: 0; }
.mw-mob-results .mw-ac-left {
    flex: none; width: 100%; max-height: none; overflow-y: visible;
    border-right: none; border-bottom: 1px solid #f0f0f0;
    padding: 8px 0 4px;
}
.mw-mob-results .mw-ac-right  { flex: none; width: 100%; max-height: none; overflow-y: visible; padding: 8px 0; }
.mw-mob-results .mw-ac-suggest-item a,
.mw-mob-results .mw-ac-category-item a { padding: 12px 16px; font-size: 14px; }
.mw-mob-results .mw-ac-brand-chips     { gap: 10px; padding: 6px 16px 14px; }
.mw-mob-results .mw-ac-brand-chip      { padding: 7px 18px; font-size: 14px; }
.mw-mob-results .mw-ac-section-label   { font-size: 11px; padding: 8px 16px 4px; }

/* 2-column product grid inside the mobile overlay */
.mw-mob-results .mw-ac-products-header { padding: 6px 12px 8px; }
.mw-mob-results .mw-ac-products-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 12px 16px;
}
.mw-mob-results .mw-ac-product {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 6px;
    border-bottom: none;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
}
.mw-mob-results .mw-ac-product-img-wrap {
    width: 100%;
    height: 90px;
    border-radius: 6px;
    background: none;
    border: none;
}
.mw-mob-results .mw-ac-product-name  { font-size: 12px; }
.mw-mob-results .mw-ac-product-price { font-size: 13px; }
/* Stack old price below special price in narrow grid cells */
.mw-mob-results .mw-ac-product-price .old-price { display: block; margin: 0; }

/* ─── Loading animation ─────────────────────────────────────────── */
form.minisearch.loading .control input[type="text"] {
    animation: mw-search-pulse 1.4s ease-in-out infinite;
}
@keyframes mw-search-pulse {
    0%,100% { box-shadow: none; }
    50%      { box-shadow: 0 0 0 3px rgba(79,41,100,.18); }
}

/* ─── Desktop container ─────────────────────────────────────────── */
.mw-ac {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 9999999;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    overflow: hidden;
    min-width: 520px;
}

/* ─── Body: two-column flex ─────────────────────────────────────── */
.mw-ac-body {
    display: flex;
    align-items: flex-start;
    min-height: 160px;
}

/* ─── Left column ───────────────────────────────────────────────── */
.mw-ac-left {
    flex: 0 0 300px;
    width: 300px;
    border-right: 1px solid #f0f0f0;
    padding: 12px 0;
    max-height: 480px;
    overflow-y: auto;
}

/* ─── Right column ──────────────────────────────────────────────── */
.mw-ac-right {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 0;
    max-height: 480px;
    overflow-y: auto;
}

/* ─── Section label ─────────────────────────────────────────────── */
.mw-ac-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #9ca3af;
    padding: 6px 16px 4px;
}

/* ─── Sections ──────────────────────────────────────────────────── */
.mw-ac-section { margin-bottom: 4px; }
.mw-ac-section + .mw-ac-section {
    border-top: 1px solid #f5f5f5;
    margin-top: 4px;
    padding-top: 4px;
}
.mw-ac-section ul { list-style: none; margin: 0; padding: 0; }

/* ─── Suggestion / category rows ────────────────────────────────── */
.mw-ac-suggest-item a,
.mw-ac-category-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 13.5px;
    color: #111 !important;
    text-decoration: none;
    transition: background .12s;
    cursor: pointer;
}
.mw-ac-suggest-item a:hover,
.mw-ac-category-item a:hover { background: #faf7fc; }

.mw-ac-icon { flex-shrink: 0; color: #bbb; }
.mw-ac-suggest-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-ac-suggest-count { font-size: 11px; color: #bbb; white-space: nowrap; }

/* ─── Brand chips ────────────────────────────────────────────────── */
.mw-ac-brand-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 16px 12px;
}
.mw-ac-brand-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border: 1.5px solid #e2e2e2;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #333 !important;
    text-decoration: none;
    background: #fafafa;
    white-space: nowrap;
    transition: border-color .12s, color .12s, background .12s;
    cursor: pointer;
}
.mw-ac-brand-chip:hover {
    border-color: #4f2964;
    color: #4f2964 !important;
    background: #faf7fc;
}

/* ─── Products header ───────────────────────────────────────────── */
.mw-ac-products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px 8px;
}
.mw-ac-see-all {
    font-size: 12px;
    color: #4f2964 !important;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.mw-ac-see-all:hover { text-decoration: underline; }

/* ─── Product list ──────────────────────────────────────────────── */
.mw-ac-products-list { list-style: none; margin: 0; padding: 0; }

.mw-ac-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f5f5f5;
    transition: background .12s;
}
.mw-ac-product:last-child  { border-bottom: none; }
.mw-ac-product:hover       { background: #faf7fc; }

.mw-ac-product-img-wrap {
    flex-shrink: 0;
    display: block;
    width: 58px;
    height: 58px;
    border-radius: 8px;
    overflow: hidden;
    background: #f9f9f9;
    border: 1px solid #eee;
}
.mw-ac-product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.mw-ac-product-info { flex: 1; min-width: 0; }

.mw-ac-product-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #111 !important;
    text-decoration: none;
    margin-bottom: 4px;
}
.mw-ac-product-name:hover { color: #4f2964 !important; }

.mw-ac-product-reviews { margin-bottom: 3px; }
.mw-ac-product-reviews .product-reviews-summary { margin: 0; }
/* Hide "Be the first to review" — not useful in autocomplete */
.mw-ac-product-reviews .product-reviews-summary.empty { display: none !important; }

/* ─── Price: special + old side-by-side ─────────────────────────── */
.mw-ac-product-price { font-size: 13.5px; font-weight: 700; color: #4f2964; }
.mw-ac-product-price .price-label  { display: none !important; }
.mw-ac-product-price .price-from   { display: none !important; }
.mw-ac-product-price .special-price { display: inline; }
.mw-ac-product-price .special-price .price {
    font-size: 13.5px;
    font-weight: 700;
    color: #4f2964;
}
.mw-ac-product-price .old-price { display: inline; margin-left: 6px; }
[dir="rtl"] .mw-ac-product-price .old-price { margin-left: 0; margin-right: 6px; }
.mw-ac-product-price .old-price .price {
    font-size: 12px;
    font-weight: 400;
    color: #aaa;
    text-decoration: line-through;
}

.mw-ac-product-addtocart { margin-top: 6px; }
.mw-ac-atc-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #4f2964;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}
.mw-ac-atc-btn:hover { background: #3a1e4a; }

/* ─── No result ─────────────────────────────────────────────────── */
.mw-ac-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */
.mw-ac-left::-webkit-scrollbar,
.mw-ac-right::-webkit-scrollbar       { width: 4px; }
.mw-ac-left::-webkit-scrollbar-thumb,
.mw-ac-right::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

/* ─── RTL ───────────────────────────────────────────────────────── */
[dir="rtl"] .mw-ac-left { border-right: none; border-left: 1px solid #f0f0f0; }

/* ─── Tablet ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .mw-ac         { min-width: 0; }
    .mw-ac-left    { flex: 0 0 220px; width: 220px; }
}

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .mw-ac {
        min-width: 0;
        max-height: 65vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mw-ac-body { flex-direction: column; }
    .mw-ac-left {
        flex: none;
        width: 100%;
        max-height: none;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
        padding: 8px 0 4px;
    }
    .mw-ac-right {
        flex: none;
        width: 100%;
        max-height: none;
        overflow-y: visible;
        padding: 8px 0;
    }
    .mw-ac-product          { padding: 10px 16px; gap: 12px; }
    .mw-ac-product-img-wrap { width: 54px; height: 54px; }
    .mw-ac-product-name     { font-size: 13px; }
    .mw-ac-product-price    { font-size: 13px; }
    .mw-ac-suggest-item a,
    .mw-ac-category-item a  { padding: 10px 16px; font-size: 14px; }
    .mw-ac-brand-chips      { gap: 10px; padding: 6px 16px 14px; }
    .mw-ac-brand-chip       { padding: 6px 16px; font-size: 13.5px; }
    .mw-ac-section-label    { font-size: 11px; padding: 8px 16px 4px; }
}
