/*
 * assets/css/header.css
 * Styles du header (top bar, logo/recherche/actions, mega-menu),
 * du header mobile, et de la nav basse fixe.
 */

/* ==========================================================================
   TOP BAR (ligne 1 - desktop)
   ========================================================================== */
.epi-topbar {
    background-color: var(--epi-blue-dark);
    color: var(--epi-white);
    font-size: 13px;
    display: none; /* affiché en desktop via media query plus bas */
}

.epi-topbar__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 6px 20px;
    display: flex;
    gap: 24px;
    align-items: center;
}

.epi-topbar__item a {
    color: var(--epi-white);
    text-decoration: none;
}

.epi-topbar__item--delivery {
    margin-left: auto;
    opacity: 0.9;
}

/* ==========================================================================
   HEADER PRINCIPAL (ligne 2 - desktop)
   ========================================================================== */
.epi-header__main {
    display: none; /* desktop only, cf media query */
    border-bottom: var(--epi-border-subtle);
}

.epi-header__main-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.epi-header__logo img,
.epi-header__logo a {
    font-size: 22px;
    font-weight: 700;
    color: var(--epi-blue-dark);
    text-decoration: none;
}

.epi-header__search {
    flex: 1;
    position: relative;
    display: flex;
    max-width: 640px;
}

.epi-header__search-input {
    width: 100%;
    padding: 10px 44px 10px 16px;
    border: var(--epi-border-subtle);
    border-radius: var(--epi-radius-card);
    font-size: 14px;
}

.epi-header__search-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--epi-blue-pro);
    color: var(--epi-white);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.epi-header__search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--epi-white);
    border: var(--epi-border-subtle);
    border-radius: var(--epi-radius-card);
    box-shadow: var(--epi-shadow-card);
    z-index: 50;
    display: none; /* affiché en JS quand des résultats existent - Phase 8 */
}

.epi-header__actions {
    display: flex;
    align-items: center;
    gap: 20px;
    white-space: nowrap;
}

.epi-header__action {
    color: var(--epi-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    position: relative;
}

.epi-header__action--cart {
    padding-right: 14px;
}

.epi-header__cart-count {
    background: var(--epi-orange);
    color: var(--epi-white);
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ==========================================================================
   MEGA-MENU (ligne 3 - desktop)
   ========================================================================== */
.epi-header__nav {
    display: none; /* desktop only */
    background: var(--epi-white);
}

.epi-header__nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.epi-mega-menu__list {
    list-style: none;
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.epi-mega-menu__item {
    position: relative;
}

.epi-mega-menu__item > a {
    display: block;
    padding: 12px 14px;
    color: var(--epi-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.epi-mega-menu__item > a:hover {
    color: var(--epi-blue-pro);
}

.epi-mega-menu__panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 260px;
    background: var(--epi-white);
    border: var(--epi-border-subtle);
    border-radius: 0 0 var(--epi-radius-card) var(--epi-radius-card);
    box-shadow: var(--epi-shadow-card);
    padding: 16px;
    z-index: 40;
}

.epi-mega-menu__item.has-children:hover .epi-mega-menu__panel,
.epi-mega-menu__item.has-children:focus-within .epi-mega-menu__panel {
    display: block;
}

.epi-mega-menu__panel ul {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}

.epi-mega-menu__panel li a {
    display: block;
    padding: 6px 0;
    color: var(--epi-text);
    text-decoration: none;
    font-size: 13.5px;
}

.epi-mega-menu__panel li a:hover {
    color: var(--epi-blue-pro);
}

.epi-mega-menu__view-all {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--epi-blue-pro);
    text-decoration: none;
    border-top: var(--epi-border-subtle);
    padding-top: 10px;
    width: 100%;
}

/* ==========================================================================
   HEADER MOBILE
   ========================================================================== */
.epi-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: var(--epi-border-subtle);
}

.epi-header-mobile__hamburger {
    background: none;
    border: none;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.epi-header-mobile__bar {
    width: 22px;
    height: 2px;
    background: var(--epi-blue-dark);
    display: block;
}

.epi-header-mobile__logo a {
    font-weight: 700;
    color: var(--epi-blue-dark);
    text-decoration: none;
    font-size: 17px;
}

.epi-header-mobile__logo .custom-logo-link {
    display: flex;
    align-items: center;
}

.epi-header-mobile__logo .custom-logo {
    width: auto;
    max-width: 145px;
    max-height: 42px;
    object-fit: contain;
}

.epi-header-mobile__actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.epi-header-mobile__actions a {
    color: var(--epi-text);
    position: relative;
}

.epi-header-mobile__search {
    padding: 0 16px 12px;
}

.epi-header-mobile__search input {
    width: 100%;
    padding: 9px 14px;
    border: var(--epi-border-subtle);
    border-radius: var(--epi-radius-card);
    font-size: 14px;
}

/* Panneau menu mobile (accordéon) */
.epi-mobile-panel {
    background: var(--epi-white);
    border-bottom: var(--epi-border-subtle);
}

.epi-mobile-panel[hidden] {
    display: none;
}

.epi-mobile-menu__list {
    list-style: none;
    margin: 0;
    padding: 8px 16px 16px;
}

.epi-mobile-menu__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: var(--epi-border-subtle);
}

.epi-mobile-menu__row a {
    color: var(--epi-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 14.5px;
}

.epi-mobile-menu__toggle {
    background: var(--epi-gray-light);
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    cursor: pointer;
}

.epi-mobile-menu__submenu {
    list-style: none;
    margin: 0;
    padding: 0 0 8px 12px;
    display: none;
}

.epi-mobile-menu__submenu.is-open {
    display: block;
}

.epi-mobile-menu__submenu a {
    display: block;
    padding: 6px 0;
    color: var(--epi-text);
    text-decoration: none;
    font-size: 13.5px;
}

/* ==========================================================================
   NAV BASSE FIXE (mobile uniquement)
   ========================================================================== */
.epi-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--epi-white);
    border-top: var(--epi-border-subtle);
    box-shadow: 0 -2px 10px rgba(11, 31, 51, 0.08);
    display: flex;
    justify-content: space-between;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}

.epi-bottom-nav__item {
    flex: 1;
    text-align: center;
    font-size: 11px;
    color: var(--epi-text);
    text-decoration: none;
    position: relative;
}

/* Compense la hauteur de la nav basse fixe pour ne pas masquer le contenu */
.epi-main {
    padding-bottom: 64px;
}

/* ==========================================================================
   RESPONSIVE : bascule desktop / mobile
   ========================================================================== */
@media (min-width: 992px) {
    .epi-topbar,
    .epi-header__main,
    .epi-header__nav {
        display: block;
    }

    .epi-header__main-inner {
        display: flex;
    }

    .epi-header-mobile,
    .epi-header-mobile__search,
    .epi-mobile-panel,
    .epi-bottom-nav {
        display: none !important;
    }

    .epi-main {
        padding-bottom: 0;
    }
}
