/* ==========================================================================
   HEADER.CSS — Styles globaux du header ESMaroc
   À inclure sur TOUTES les pages via : <link rel="stylesheet" href="header.css">
   Gère : barre de recherche, dropdown mobile, sticky scroll.
   ========================================================================== */

/* ── Barre de recherche déroulante ── */
.search-wrapper {
    position: relative;
}

.search-bar {
    display: none;
    position: absolute;
    top: 140%;
    right: 0;
    width: 340px;
    background: var(--white);
    border-radius: 4px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12);
    border-top: 3px solid var(--blue);
    padding: 12px 15px;
    z-index: 9999;
    animation: searchSlideDown 0.25s ease;
    flex-direction: column;
    gap: 8px;
}

.search-bar.open {
    display: flex;
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.search-bar-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

#search-input {
    flex: 1;
    border: 1.5px solid rgba(0, 69, 149, 0.15);
    border-radius: 3px;
    padding: 9px 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.88rem;
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.25s;
}

#search-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 69, 149, 0.07);
}

#search-input::placeholder { color: #b0b7c3; }

#search-close {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

#search-close:hover {
    color: var(--blue);
    background: var(--bg-light);
}

/* Résultats */
.search-results {
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    border-top: 1px solid #f0f0f0;
}

.search-result-item {
    padding: 10px 6px;
    border-bottom: 1px solid #f5f5f5;
    font-size: 0.84rem;
    cursor: pointer;
    color: var(--text-dark);
    transition: color 0.2s, background 0.2s;
    border-radius: 2px;
}

.search-result-item:hover {
    color: var(--blue);
    background: var(--bg-light);
    padding-left: 10px;
}

.search-result-item:last-child { border-bottom: none; }

.search-no-result {
    padding: 10px 6px;
    font-size: 0.83rem;
    color: var(--text-light);
    font-style: italic;
}

/* ── Icône loupe — même style que les autres icon-link ── */
#search-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--blue);
    font-size: 18px;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: color 0.3s, transform 0.3s;
}

#search-toggle:hover {
    color: var(--yellow);
    transform: scale(1.1);
}

/* ── Burger (menu mobile) ── */
.burger-menu {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--blue);
    font-size: 20px;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, transform 0.3s ease;
    line-height: 1;
}

.burger-menu:hover {
    color: var(--yellow);
    transform: scale(1.1);
}

/* ── Navigation mobile (drawer) ── */
@media (max-width: 900px) {
    .burger-menu { display: flex; }

    nav {
        position: fixed;
        top: 0;
        right: 0;
        height: 100dvh;
        width: min(320px, 85vw);
        background: var(--white);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 90px 24px 32px;
        box-shadow: -15px 0 40px rgba(0, 0, 0, 0.15);
        z-index: 9999;
        overflow-y: auto;
        transform: translateX(100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s;
    }

    nav.active {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    nav a {
        font-size: 14px;
        padding: 15px 4px;
        border-bottom: 1px solid #f0f0f0;
    }

    .dropdown {
        display: block;
        width: 100%;
    }

    .dropdown-trigger {
        padding: 15px 4px;
        border-bottom: 1px solid #f0f0f0;
        width: 100%;
        justify-content: space-between;
    }

    .dropdown.open .nav-arrow { transform: rotate(180deg); }

    .dropdown-menu {
        position: static !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: none !important;
        box-shadow: none !important;
        border-top: none !important;
        padding: 0 0 0 16px !important;
        display: none !important;
        min-width: unset !important;
        background: transparent !important;
    }

    .dropdown.open .dropdown-menu {
        display: flex !important;
        flex-direction: column !important;
    }

    .dropdown-menu a {
        padding: 13px 8px !important;
    }

    /* Barre de recherche pleine largeur sous le header */
    .search-bar {
        position: fixed;
        top: 76px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        border-top: none;
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    }
}

/* Voile sombre derrière le menu ouvert */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 40, 79, 0.45);
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.nav-open { overflow: hidden; }
