/* ==========================================================================
   header-v2.css  —  header overrides / enhancements
   Loaded AFTER agri.css.  Only adds/corrects; does not re-declare layout.
   ========================================================================== */

/* ── Site header shell ──────────────────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, #F4FBF4 0%, #EEF9EE 50%, #E8F6E8 100%);
    border-bottom: 1px solid #D7E8D7;
    box-shadow: 0 8px 25px rgba(46, 125, 50, 0.08);
    position: sticky;
    top: 0;
    z-index: 3200;
}

/* ── Nav row: let agri.css grid govern; only set padding / min-height ───── */
.nav-row.top-row {
    /* Keep agri.css grid-template-columns; just ensure sensible vertical spacing */
    min-height: 72px;
    height: auto;           /* CRITICAL: remove fixed 82px so wrapped rows don't clip */
    padding: 10px 0;
    align-items: center;
    gap: 14px;
}

/* ── Left column ────────────────────────────────────────────────────────── */
.left-col {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ── Center column (search-wrapper + tech btn) ──────────────────────────── */
.center-col {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   SEARCH WRAPPER  —  positions the pill + dropdown + voice overlay together
   ══════════════════════════════════════════════════════════════════════════ */
.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    max-width: 540px;
}

/* ── The pill ────────────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    width: 100%;
    height: 46px;
    padding: 0 6px 0 14px;
    border-radius: 999px;
    border: 2px solid #AED9AE;
    background: #fff;
    gap: 4px;
    transition: border-color 0.22s ease, box-shadow 0.22s ease;
    box-shadow: 0 2px 10px rgba(46,125,50,0.07);
}

.search-bar:focus-within {
    border-color: #2E7D32;
    box-shadow: 0 0 0 3px rgba(46,125,50,0.14), 0 2px 10px rgba(46,125,50,0.1);
}

/* leading search icon */
.sb-icon-search {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: #6aad7a;
    pointer-events: none;
    margin-right: 2px;
}

/* text input — transparent, no border */
.search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #1a2e1e;
    padding: 0;
    caret-color: #2E7D32;
}

.search-input::placeholder {
    color: #a0b8a8;
}

/* shared base for mic + submit buttons inside the pill */
.sb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 999px;
    transition: background 0.18s ease, transform 0.18s ease;
    padding: 0;
}

/* mic button */
.sb-mic-btn {
    position: relative;
    width: 34px;
    height: 34px;
    color: #6aad7a;
}

.sb-mic-btn:hover  { background: #f0faf2; color: #2E7D32; }
.sb-mic-btn.active { color: #e53935; }
.sb-mic-btn.active:hover { background: #fdecea; }

/* pulsing ring shown while listening */
.mic-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #e53935;
    opacity: 0;
    pointer-events: none;
}

.sb-mic-btn.active .mic-pulse {
    animation: mic-ring 1s ease-out infinite;
}

@keyframes mic-ring {
    0%   { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.75); }
}

/* submit arrow button */
.sb-submit-btn {
    width: 34px;
    height: 34px;
    background: #2E7D32;
    color: #fff;
    margin-left: 2px;
}

.sb-submit-btn:hover  { background: #1b5e20; transform: scale(1.06); }
.sb-submit-btn:active { transform: scale(0.97); }

/* ── Autocomplete suggestions dropdown ──────────────────────────────────── */
.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    max-height: 380px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #d8edd9;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(20,67,43,0.14);
    z-index: 9999;
    padding: 8px;
    list-style: none;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: #c8e6c9 transparent;
}

.search-suggestions::-webkit-scrollbar { width: 4px; }
.search-suggestions::-webkit-scrollbar-thumb { background: #c8e6c9; border-radius: 4px; }

.search-suggestions li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-suggestions li:hover,
.search-suggestions li[aria-selected="true"] {
    background: #f0faf2;
}

.ss-thumb {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: contain;
    background: #f5f9f5;
    flex-shrink: 0;
}

.ss-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.ss-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a2e1e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-meta {
    font-size: 11.5px;
    color: #6aad7a;
    margin-top: 1px;
}

.ss-price {
    font-size: 13px;
    font-weight: 700;
    color: #1f704c;
    flex-shrink: 0;
}

.ss-no-results {
    padding: 16px 12px;
    text-align: center;
    color: #8aab94;
    font-size: 13px;
    list-style: none;
}

/* ── Voice listening overlay ────────────────────────────────────────────── */
.voice-listening-overlay {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: #fff;
    border: 1px solid #d8edd9;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(20,67,43,0.14);
    z-index: 9999;
    padding: 24px 20px 20px;
    /* NOTE: do NOT set display here — the `hidden` attribute controls visibility */
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Only show as flex when the `hidden` attribute has been removed by JS */
.voice-listening-overlay:not([hidden]) {
    display: flex;
}

/* Hard guard — ensure `hidden` always wins over any display rule */
.voice-listening-overlay[hidden],
.search-suggestions[hidden] {
    display: none !important;
}

/* wave bars */
.vl-waves {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 40px;
}

.vl-waves span {
    display: block;
    width: 5px;
    border-radius: 3px;
    background: #2E7D32;
    animation: vl-wave 0.9s ease-in-out infinite alternate;
    min-height: 6px;
}

.vl-waves span:nth-child(1) { animation-delay: 0s;    height: 18px; }
.vl-waves span:nth-child(2) { animation-delay: 0.12s; height: 32px; }
.vl-waves span:nth-child(3) { animation-delay: 0.24s; height: 40px; }
.vl-waves span:nth-child(4) { animation-delay: 0.12s; height: 32px; }
.vl-waves span:nth-child(5) { animation-delay: 0s;    height: 18px; }

@keyframes vl-wave {
    from { transform: scaleY(0.35); opacity: 0.55; }
    to   { transform: scaleY(1);    opacity: 1; }
}

.vl-hint {
    margin: 0;
    font-size: 14px;
    color: #4a7a5a;
    font-weight: 600;
    text-align: center;
}

.vl-cancel {
    border: none;
    background: #f0faf2;
    color: #1f704c;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 22px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s ease;
}

.vl-cancel:hover { background: #d6f0db; }

/* ── Tech-search button ─────────────────────────────────────────────────── */
#tech-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eef8ee;
    color: #2E7D32;
    border: 1px solid #cfe6cf;
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

#tech-search-btn:hover {
    background: #2E7D32;
    color: #fff;
    box-shadow: 0 8px 20px rgba(46, 125, 50, 0.25);
}

/* ── Right column ───────────────────────────────────────────────────────── */
.right-col {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Each icon-link: clean pill card, no min-height that breaks rows */
.right-col > .icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #eef8ee;
    border: 1px solid #cfe6cf;
    color: #1b5e20;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    /* NO min-height, NO fixed height — auto size */
}

.right-col > .icon-link:hover {
    background: #2E7D32;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(46, 125, 50, 0.25);
}

.icon-link {
    text-decoration: none;
    color: #222;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Cart count badge */
.cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #ff9800;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* ── Brand logo ─────────────────────────────────────────────────────────── */
.brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.brand img:hover {
    transform: scale(1.06);
}

/* ── Hamburger / drawer-toggle ──────────────────────────────────────────── */
.drawer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid #2E7D32;
    background: #fff;
    color: #2E7D32;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.25s ease, color 0.25s ease;
}

.drawer-toggle:hover {
    background: #2E7D32;
    color: #fff;
}

/* ── Left drawer ────────────────────────────────────────────────────────── */
/* Use agri.css's width:0 collapse model — NOT top:130px transform model */
.left-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    width: 0;
    height: 100dvh;
    z-index: 99999;
    background: #fff;
    overflow: hidden;
    transition: width 0.28s ease;
}

.left-drawer.is-open {
    width: min(300px, 88vw);
    padding: 20px 16px;
    overflow-y: auto;
}

/* ── Green category nav bar ─────────────────────────────────────────────── */
.green-nav {
    background: #1f704c;
    color: #fff;
    position: relative;
    z-index: 3100;
    overflow: visible;
}

.green-nav .container {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 52px;
    position: relative;
    overflow: visible;
}

.category-nav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
}

.category-nav::-webkit-scrollbar { display: none; }

.category-nav > a,
.category-nav .nav-dropdown > a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.category-nav > a:hover,
.category-nav .nav-dropdown > a:hover,
.category-nav .nav-dropdown.open > a {
    background: rgba(255, 255, 255, 0.16);
}

/* Dropdown caret */
.dropdown-caret {
    display: inline-flex;
    align-items: center;
    font-size: 0.7em;
    opacity: 0.8;
}

/* Nav dropdown menu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    background: #fff;
    color: #1d3a2e;
    border-radius: 12px;
    box-shadow: 0 18px 36px rgba(15, 44, 30, 0.16);
    padding: 8px;
    display: none;
    z-index: 3300;
}

.nav-dropdown.open .nav-dropdown-menu,
.nav-dropdown:hover .nav-dropdown-menu {
    display: grid;
    gap: 4px;
}

.nav-dropdown-menu a {
    display: block;
    color: #1d3a2e;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
}

.nav-dropdown-menu a:hover {
    background: #f0f7f2;
}

.nav-dropdown-menu strong { display: block; font-size: 0.9em; }
.nav-dropdown-menu small  { display: block; font-size: 0.78em; color: #61776a; margin-top: 1px; }

/* Carousel scroll buttons */
.nav-carousel-btn {
    flex-shrink: 0;
    border: 0;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-carousel-btn:hover {
    background: rgba(255, 255, 255, 0.32);
}

/* ==========================================================================
   RESPONSIVE — TABLET  (≤ 900px)
   ========================================================================== */
@media (max-width: 900px) {

    /* Nav row: switch to a 2-row layout
       Row 1: hamburger + logo + icons
       Row 2: full-width search bar                                           */
    .nav-row.top-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 0;
        min-height: unset;
    }

    .left-col {
        flex: 0 0 auto;
        gap: 8px;
    }

    /* Search drops to its own full-width row */
    .center-col {
        order: 10;          /* pushes below left+right */
        flex: 0 0 100%;
        width: 100%;
        gap: 8px;
    }

    .search-bar {
        flex: 1;
        max-width: 100%;
    }

    /* Tech-search btn: icon-only pill on mobile */
    #tech-search-btn .tech-text,
    #tech-search-btn span:not(.tech-icon) {
        display: none;
    }

    #tech-search-btn {
        padding: 9px 10px;
        gap: 0;
        flex-shrink: 0;
    }

    .right-col {
        flex: 0 0 auto;
        margin-left: auto;  /* push to far right */
        gap: 6px;
    }

    /* Shrink icon cards on mobile */
    .right-col > .icon-link {
        padding: 7px 10px;
        font-size: 12px;
    }

    /* Hide icon labels — keep emoji only */
    .icon-link .icon-text {
        display: none;
    }

    /* Compact brand logo */
    .brand img {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================================================
   RESPONSIVE — MOBILE  (≤ 480px)
   ========================================================================== */
@media (max-width: 480px) {

    .right-col > .icon-link {
        padding: 6px 8px;
    }

    .drawer-toggle {
        width: 38px;
        height: 38px;
    }

    .brand img {
        width: 36px;
        height: 36px;
    }

    /* Green nav: icon-pill mode */
    .category-nav > a,
    .category-nav .nav-dropdown > a {
        padding: 8px;
        font-size: 0;       /* hide text, show data-icon via ::before */
        border-radius: 10px;
        min-width: 36px;
        justify-content: center;
    }

    .category-nav > a::before,
    .category-nav .nav-dropdown > a::before {
        content: attr(data-icon);
        font-size: 1.1rem;
        display: block;
    }

    .dropdown-caret { display: none; }

    /* Dropdown menus: full-width from left edge */
    .nav-dropdown-menu {
        left: 0;
        right: auto;
        min-width: 180px;
        max-width: min(260px, calc(100vw - 20px));
    }

    .nav-dropdown-menu a {
        font-size: 12px;
    }
}
