/*
 * VEAN — Instant Search Dropdown
 *
 * Decathlon-inspired, adapted to the VEAN palette (#ff8e4f primary).
 * Mobile: full-screen overlay. Desktop: dropdown anchored under the input.
 */

:root {
    --vean-search-bg: #ffffff;
    --vean-search-text: #232323;
    --vean-search-muted: #6b6b6b;
    --vean-search-border: #e5e5e5;
    --vean-search-row-hover: #f6f6f6;
    --vean-search-highlight-bg: #fff4dc;
    --vean-search-highlight-text: #232323;
    --vean-search-price-bg: #ffe066;
    --vean-search-price-text: #232323;
    --vean-search-primary: #ff8e4f;
    --vean-search-primary-dark: #ec7330;
    --vean-search-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* When the dropdown is open we lock body scroll so the user can scroll the
   overlay content freely (matters on mobile). */
body.has-search-overlay {
    overflow: hidden;
}

/* Dim backdrop behind the dropdown — pulls user focus to the search panel,
   matches the Decathlon pattern. Only shown on desktop because on mobile
   the dropdown already fills the viewport below the header. */
body.has-search-overlay::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.40);
    z-index: 1040;
    animation: vean-search-backdrop-fade-in 160ms ease-out;
    animation-fill-mode: both;
    pointer-events: auto;
}
@keyframes vean-search-backdrop-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@media (max-width: 768px) {
    /* On mobile the dropdown takes the screen below the header so the dim
       backdrop is redundant and would just darken the visible header. */
    body.has-search-overlay::before {
        display: none;
    }
}

/* Decathlon-style unified overlay: dropdown carries its own search input
   so the legacy header input doesn't need to remain interactive. Letting
   the header sit in normal flow (no z-index lift) means the backdrop
   dims it like the rest of the page — what the user explicitly asked
   for ("tout le reste en dark, le header aussi"). */

/* -------------------------------------------------------------------- */
/* v1 (modern) search bar — clean, Decathlon-inspired                    */
/*                                                                       */
/* The legacy `.search-widget` style stays untouched so the v0 design    */
/* keeps rendering as before. Only when the template adds the `--v2`    */
/* modifier class do we apply the new look.                             */
/* -------------------------------------------------------------------- */

.search-widget--v2 form {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d8d8d8;
    border-radius: 24px;
    padding: 4px 8px 4px 16px;
    transition: border-color 100ms ease-out, box-shadow 100ms ease-out;
    min-height: 44px;
}

.search-widget--v2 form:focus-within {
    border-color: var(--vean-search-primary);
    box-shadow: 0 0 0 3px rgba(255, 142, 79, 0.18);
}

.search-widget--v2 input[name="s"] {
    flex: 1 1 auto;
    background: transparent !important;
    border: none !important;
    color: var(--vean-search-text) !important;
    font-size: 0.95rem;
    padding: 8px 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

.search-widget--v2 input[name="s"]::placeholder {
    color: #9a9a9a !important;
    opacity: 1;
}

.search-widget--v2 button[type="submit"] {
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important;
    width: 36px;
    height: 36px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: var(--vean-search-text);
    padding: 0 !important;
    box-shadow: none !important;
    cursor: pointer;
}

.search-widget--v2 button[type="submit"]:hover {
    background: var(--vean-search-row-hover) !important;
}

.search-widget--v2 button[type="submit"] .material-icons {
    color: var(--vean-search-text) !important;
    font-size: 20px;
}

.search-widget--v2 button[type="submit"] span {
    display: none !important;
}

/* Make sure the input's parent positions the dropdown correctly. */
.search-widget {
    position: relative;
}

/* ---------------------------------------------------------------------- */
/* Dropdown panel — wide Decathlon-style overlay on desktop,               */
/* full-viewport sheet on mobile                                           */
/* ---------------------------------------------------------------------- */

.search-dropdown {
    /* Decathlon-style unified overlay anchored near the top of the
       viewport — no longer glued to the header input, because the panel
       has its own search bar at the top. CSS handles positioning;
       JS-side positionDropdown is now a no-op. */
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: min(96vw, 1240px);
    max-height: calc(100vh - 48px);
    background: var(--vean-search-bg);
    color: var(--vean-search-text);
    border: 1px solid var(--vean-search-border);
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    overflow-y: auto;
    display: none;
}

.search-dropdown.is-open {
    display: block;
    animation: vean-search-fade-in 140ms ease-out;
}

/* The HTML `hidden` attribute sets `display: none` via UA stylesheet, but
   any explicit `display:` rule (e.g. our `display:flex` on the loading row
   or a `display:grid` parent) silently wins and the element stays visible.
   This forces hidden descendants of the dropdown back to none so JS can
   toggle visibility predictably with `el.hidden = true/false`. */
.search-dropdown [hidden] {
    display: none !important;
}

@keyframes vean-search-fade-in {
    from { opacity: 0; transform: translate(-50%, -6px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* 2-column grid: sidebar (suggestions + recent + help) on the left,
   main (products carousel + categories + articles + FAQs) on the right.
   At narrower viewports we collapse to a single column so the sidebar
   sections stack above the main area. */
.search-dropdown-inner {
    display: grid;
    grid-template-columns: 260px 1fr;
    column-gap: 32px;
    padding: 24px 28px;
    align-items: start;
}

.search-dropdown-sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.search-dropdown-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

@media (max-width: 960px) {
    .search-dropdown-inner {
        grid-template-columns: 1fr;
        column-gap: 0;
        row-gap: 16px;
    }
    /* Flatten sidebar/main into the inner grid so we can reorder sections
       across them — pushes the help CTA to the very bottom on mobile so
       products get the premium real estate. */
    .search-dropdown-sidebar,
    .search-dropdown-main {
        display: contents;
    }
    .search-dropdown-help {
        order: 99;
    }
}

/* Mobile: full-screen sheet — the panel's own topbar replaces the
   legacy header input visually. */
@media (max-width: 768px) {
    .search-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        transform: none;
        background: #ffffff;
        -webkit-overflow-scrolling: touch;
    }
    .search-dropdown.is-open {
        animation: vean-search-mobile-slide 160ms ease-out;
    }
    @keyframes vean-search-mobile-slide {
        from { opacity: 0; transform: translateY(-8px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .search-dropdown-inner {
        padding: 16px 16px 32px;
        row-gap: 16px;
    }
}

/* ---------------------------------------------------------------------- */
/* Sections                                                                */
/* ---------------------------------------------------------------------- */

.search-dropdown-section {
    padding: 0;
    border-bottom: none;
    /* Critical at ≤960px where the sidebar/main use display: contents and
       sections become direct grid items. Default min-width is auto, which
       lets the carousel's intrinsic width (sum of all cards) propagate up
       and overflow the viewport. min-width: 0 forces the section to honor
       the 1fr column, and the carousel's own overflow-x: auto handles the
       horizontal scroll inside it. */
    min-width: 0;
}

.search-dropdown-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.search-dropdown-title {
    margin: 0 0 10px 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--vean-search-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* When sitting inside a flex section-head with a "Voir tous" link,
   drop the bottom margin so the row aligns. */
.search-dropdown-section-head .search-dropdown-title {
    margin: 0;
}

.search-dropdown-count {
    color: var(--vean-search-muted);
    font-weight: 500;
    font-size: 0.75rem;
}

.search-dropdown-clear-recent {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--vean-search-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}
.search-dropdown-clear-recent:hover {
    color: var(--vean-search-primary-dark);
    text-decoration: underline;
}

/* ---------------------------------------------------------------------- */
/* Suggestion / recent / categories / articles / faqs lists                */
/* ---------------------------------------------------------------------- */

.search-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-dropdown-item {
    margin: 0;
    padding: 0;
}

.search-dropdown-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    color: var(--vean-search-text);
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 80ms ease-out;
    min-height: 40px;   /* still tap-friendly, tighter visual rhythm */
}

/* Inline list variant for categories — chip-style layout so 5 categories
   fit on one row instead of stacking. */
.search-dropdown-list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.search-dropdown-list-inline .search-dropdown-item { display: inline-block; }
.search-dropdown-list-inline .search-dropdown-link {
    padding: 6px 12px;
    border: 1px solid var(--vean-search-border);
    border-radius: 999px;
    min-height: 0;
    font-size: 0.85rem;
    background: #ffffff;
}
.search-dropdown-list-inline .search-dropdown-link:hover {
    border-color: var(--vean-search-primary);
    background: rgba(255, 142, 79, 0.04);
}
.search-dropdown-list-inline .search-dropdown-icon { display: none; }

.search-dropdown-link:hover,
.search-dropdown-link.is-focused {
    background: var(--vean-search-row-hover);
    text-decoration: none;
}

.search-dropdown-icon {
    flex: 0 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--vean-search-muted);
}
.search-dropdown-icon svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.search-dropdown-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.search-dropdown-label {
    font-size: 0.95rem;
    color: var(--vean-search-text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-dropdown-utility-category {
    font-size: 0.7rem;
    color: var(--vean-search-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.search-dropdown-utility-intent .search-dropdown-label {
    font-weight: 700;
    color: var(--vean-search-primary);
}

.search-dropdown-sublabel {
    font-size: 0.8rem;
    color: var(--vean-search-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

/* Catégories et articles : titre + icône suffisent dans le dropdown.
   Cacher la description (sublabel) garde les items compacts et alignés
   avec le rendu dev. La FAQ garde sa description (la réponse aide
   l'utilisateur à se positionner avant de cliquer). */
.search-dropdown-categories .search-dropdown-sublabel,
.search-dropdown-articles .search-dropdown-sublabel {
    display: none;
}

/* FAQ : laisser 2 lignes à la description (le début de la réponse)
   au lieu d'une troncature à 1 ligne mid-phrase. L'utilisateur a assez
   de contexte pour décider de cliquer sans visiter la fiche. */
.search-dropdown-faqs .search-dropdown-sublabel,
.search-dropdown-product-qas .search-dropdown-sublabel {
    -webkit-line-clamp: 2;
}

.search-dropdown-link mark {
    background: var(--vean-search-highlight-bg);
    color: var(--vean-search-highlight-text);
    font-weight: 700;
    padding: 0 2px;
    border-radius: 2px;
}

/* ---------------------------------------------------------------------- */
/* Products carousel                                                       */
/* ---------------------------------------------------------------------- */

.search-dropdown-products-carousel {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 2px 0 14px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.search-dropdown-products-carousel::-webkit-scrollbar {
    height: 6px;
}
.search-dropdown-products-carousel::-webkit-scrollbar-thumb {
    background: var(--vean-search-border);
    border-radius: 3px;
}

.search-dropdown-product-card {
    flex: 0 0 170px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--vean-search-text);
    background: #ffffff;
    border: 1px solid var(--vean-search-border);
    border-radius: 12px;
    padding: 10px;
    transition: border-color 100ms ease-out, transform 100ms ease-out, box-shadow 100ms ease-out;
}

@media (min-width: 1100px) {
    .search-dropdown-product-card {
        flex: 0 0 190px;
    }
}

.search-dropdown-product-card:hover,
.search-dropdown-product-card.is-focused {
    border-color: var(--vean-search-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}

.search-dropdown-product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #f6f6f6;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 8px;
    margin-bottom: 8px;
}
.search-dropdown-product-image-empty {
    background-image: linear-gradient(135deg, #f0f0f0 25%, transparent 25%, transparent 50%, #f0f0f0 50%, #f0f0f0 75%, transparent 75%);
    background-size: 8px 8px;
}

.search-dropdown-product-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-dropdown-product-brand {
    font-size: 0.7rem;
    color: var(--vean-search-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-dropdown-product-name {
    font-size: 0.85rem;
    color: var(--vean-search-text);
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.5em;
}

.search-dropdown-product-price {
    display: inline-block;
    background: var(--vean-search-price-bg);
    color: var(--vean-search-price-text);
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-top: 4px;
    width: fit-content;
}

.search-dropdown-stock-badge {
    font-size: 0.7rem;
    margin-top: 4px;
    width: fit-content;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.search-dropdown-stock-oos {
    background: #ffe4e4;
    color: #b00020;
}

.search-dropdown-see-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--vean-search-primary);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.85rem;
}
.search-dropdown-see-all:hover {
    color: var(--vean-search-primary-dark);
    text-decoration: underline;
}
.search-dropdown-arrow {
    transition: transform 80ms ease-out;
    display: inline-flex;
    align-items: center;
}
.search-dropdown-see-all:hover .search-dropdown-arrow {
    transform: translateX(2px);
}

.search-dropdown-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    color: var(--vean-search-text);
    flex-shrink: 0;
}
.search-dropdown-help-arrow {
    display: inline-flex;
    align-items: center;
}

/* ---------------------------------------------------------------------- */
/* Empty state                                                             */
/* ---------------------------------------------------------------------- */

.search-dropdown-empty {
    padding: 24px 16px;
    text-align: center;
}
.search-dropdown-empty-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 8px 0;
}
.search-dropdown-empty-hint {
    font-size: 0.9rem;
    color: var(--vean-search-muted);
    margin: 0;
}
.search-dropdown-empty-hint a {
    color: var(--vean-search-primary);
    font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* Help card — Phase 4 hook, sidebar bottom                                */
/* ---------------------------------------------------------------------- */

.search-dropdown-help {
    margin-top: 4px;
}
.search-dropdown-help-card {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--vean-search-text);
    padding: 14px 16px;
    border-radius: 12px;
    transition: transform 100ms ease-out, box-shadow 100ms ease-out;
    background: linear-gradient(135deg, #fff4dc 0%, #ffe9c2 100%);
}
.search-dropdown-help-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}
.search-dropdown-help-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.search-dropdown-help-title {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.25;
}
.search-dropdown-help-subtitle {
    font-size: 0.75rem;
    color: var(--vean-search-muted);
    line-height: 1.35;
    margin-top: 2px;
}
.search-dropdown-help-arrow {
    color: var(--vean-search-primary);
    font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* "Did you mean X?" suggestion strip — sits between the topbar and the   */
/* inner grid. Same blue accent as the SERP banner for visual continuity. */
/* ---------------------------------------------------------------------- */

.search-dropdown-suggestion {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 12px 28px;
    background: rgba(46, 134, 222, 0.08);
    border-left: 3px solid #2e86de;
    color: var(--vean-search-text);
    font-size: 0.95rem;
}
.search-dropdown-suggestion-prefix,
.search-dropdown-suggestion-suffix {
    color: var(--vean-search-muted);
}
.search-dropdown-suggestion-link {
    color: #2e86de;
    font-weight: 700;
    text-decoration: underline;
    /* 44px tap target on touch devices without bloating desktop. */
    padding: 4px 2px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
}
.search-dropdown-suggestion-link:hover,
.search-dropdown-suggestion-link:focus {
    color: #1e5fa0;
    text-decoration: underline;
}
@media (max-width: 768px) {
    .search-dropdown-suggestion {
        padding: 14px 16px;
        font-size: 1rem;
    }
    .search-dropdown-suggestion-link {
        padding: 8px 4px;
    }
}

/* ---------------------------------------------------------------------- */
/* Loading spinner                                                         */
/* ---------------------------------------------------------------------- */

.search-dropdown-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 12px 24px;
    color: var(--vean-search-muted);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--vean-search-border);
}
.search-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--vean-search-border);
    border-top-color: var(--vean-search-primary);
    border-radius: 50%;
    animation: vean-spin 600ms linear infinite;
}
@keyframes vean-spin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------- */
/* Topbar — search input + close button, integrated into the dropdown     */
/* card so the whole experience reads as a single unified block.          */
/* ---------------------------------------------------------------------- */

.search-dropdown-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 18px 14px;
    padding: 10px 14px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
}

.search-dropdown-topbar-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    color: var(--vean-search-muted);
}

.search-dropdown-topbar-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.05rem;
    color: var(--vean-search-text);
    padding: 8px 0;
    box-shadow: none;
}

.search-dropdown-topbar-input::placeholder {
    color: #9a9a9a;
    opacity: 1;
}

.search-dropdown-topbar-close {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--vean-search-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background-color 80ms ease-out, color 80ms ease-out;
}

.search-dropdown-topbar-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--vean-search-text);
}

@media (max-width: 768px) {
    .search-dropdown-topbar {
        margin: 14px 14px 10px;
        padding: 10px 12px;
    }
    .search-dropdown-topbar-input {
        font-size: 1rem;
    }
}
