/**
 * Header Fixalis — [apb_header]
 *
 * Desktop : sticky, logo + nav horizontale + CTA
 * Mobile  : hamburger 3 barres → X + off-canvas panel slide depuis la droite
 * Breakpoint mobile : 991px
 *
 * Utilise les variables CSS du design system Fixalis.
 */

/* =========================================================================
   Structure principale
   ========================================================================= */

.apb-header {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: #fff;
    border-bottom: 1px solid transparent;
    transition: border-color .2s ease, box-shadow .2s ease;
    font-family: var(--apb-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
}

.apb-header.is-scrolled {
    border-bottom-color: var(--color-border, #E2E6EA);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
}

.apb-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 68px;
}

/* =========================================================================
   Logo
   ========================================================================= */

.apb-header__logo {
    display: flex;
    align-items: center;
    gap: .45rem;
    text-decoration: none;
    flex-shrink: 0;
    outline-offset: 3px;
    border-radius: 8px;
}

.apb-header__logo:focus-visible {
    outline: 2px solid #185FA5;
}

.apb-header__logo img,
.apb-header__logo .custom-logo {
    height: 38px;
    width: auto;
    display: block;
}

.apb-header__logo-brand {
    font-size: 1.4rem;
    font-weight: 800;
    color: #185FA5;
    letter-spacing: -.035em;
    line-height: 1;
}

.apb-header__logo-tld {
    color: #E6892A;
}

/* =========================================================================
   Navigation desktop
   ========================================================================= */

.apb-header__nav {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.apb-header__menu {
    display: flex;
    align-items: center;
    gap: .2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.apb-header__menu li {
    position: relative;
}

.apb-header__menu > li > a {
    display: block !important;
    padding: 8px 16px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #1A1A2E !important;
    text-decoration: none !important;
    border-radius: 10px !important;
    transition: background .15s ease, color .15s ease !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif !important;
    letter-spacing: -.01em !important;
}

.apb-header__menu > li > a:hover,
.apb-header__menu > li > a:focus-visible {
    background: #EBF3FB;
    color: #185FA5;
    outline: none;
}

.apb-header__menu > li.current-menu-item > a,
.apb-header__menu > li.current_page_item > a,
.apb-header__menu > li.current-menu-ancestor > a {
    color: #185FA5;
    font-weight: 600;
}

/* Sous-menu dropdown desktop */
.apb-header__menu ul {
    display: none;
    position: absolute;
    top: calc(100% + .4rem);
    left: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid #E2E6EA;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .1);
    padding: .4rem;
    list-style: none;
    margin: 0;
    z-index: 100;
}

.apb-header__menu li:hover > ul,
.apb-header__menu li:focus-within > ul {
    display: block;
}

.apb-header__menu ul li a {
    display: block;
    padding: .5rem .8rem;
    font-size: .875rem;
    color: #1A1A2E;
    text-decoration: none;
    border-radius: 8px;
    transition: background .15s ease, color .15s ease;
}

.apb-header__menu ul li a:hover {
    background: #EBF3FB;
    color: #185FA5;
}

/* =========================================================================
   Actions desktop (droite)
   ========================================================================= */

.apb-header__actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

/* Groupe switcher langue séparé visuellement */
.apb-header__lang {
    display: flex;
    align-items: center;
}

/* Les deux boutons CTA desktop côte à côte avec gap */
.apb-header__desktop-cta {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =========================================================================
   Switcher langue — classes APB (apb-lang-switcher__btn)
   ========================================================================= */

.apb-lang-switcher {
    display: inline-flex !important;
    gap: 5px !important;
    align-items: center !important;
}

.apb-lang-switcher__btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 38px !important;
    min-width: 46px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    letter-spacing: .04em !important;
    text-transform: uppercase !important;
    text-decoration: none !important;
    color: #6B7280 !important;
    border: 1.5px solid #E2E6EA !important;
    background: #fff !important;
    transition: all .2s ease !important;
    line-height: 1 !important;
}

.apb-lang-switcher__btn:hover {
    color: #185FA5 !important;
    border-color: #185FA5 !important;
}

.apb-lang-switcher__btn--active {
    color: #fff !important;
    background: #185FA5 !important;
    border-color: #185FA5 !important;
}

/* Version off-canvas mobile */
.apb-offcanvas .apb-lang-switcher {
    gap: 6px !important;
}

.apb-offcanvas .apb-lang-switcher__btn {
    height: 40px !important;
    min-width: 50px !important;
    font-size: 14px !important;
}

/* =========================================================================
   WPML Language switcher — sélecteurs larges pour matcher tous les templates
   ========================================================================= */

/* Reset liste */
.apb-header ul[class*="wpml-ls"],
.apb-header div[class*="wpml-ls"] {
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    list-style: none !important;
    display: flex !important;
    gap: 5px !important;
    align-items: center !important;
}

/* Chaque item */
.apb-header li[class*="wpml-ls-item"] {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Liens */
.apb-header li[class*="wpml-ls-item"] a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    color: #6B7280 !important;
    border: 1.5px solid #E2E6EA !important;
    background: #fff !important;
    transition: all .2s ease !important;
    height: 38px !important;
    min-width: 46px !important;
    letter-spacing: .04em !important;
    text-transform: uppercase !important;
}

.apb-header li[class*="wpml-ls-item"] a:hover {
    color: #185FA5 !important;
    border-color: #185FA5 !important;
}

/* Langue active */
.apb-header li[class*="wpml-ls-current"] a {
    color: #fff !important;
    background: #185FA5 !important;
    border-color: #185FA5 !important;
}

/* Cacher flag */
.apb-header [class*="wpml-ls-flag"],
.apb-header img[class*="wpml"] {
    display: none !important;
}

/* Texte langue */
.apb-header [class*="wpml-ls-native"],
.apb-header [class*="wpml-ls-display"] {
    display: block !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    letter-spacing: .04em !important;
    text-transform: uppercase !important;
}

/* Même style dans l'off-canvas */
.apb-offcanvas ul.wpml-ls {
    list-style: none;
    display: flex;
    gap: 6px;
    padding: 0;
    margin: 0;
}

.apb-offcanvas .wpml-ls-item a.wpml-ls-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #6B7280;
    border: 1.5px solid #E2E6EA;
    background: #fff;
    text-decoration: none;
    text-transform: uppercase;
    min-height: 36px;
    min-width: 44px;
    transition: all .2s ease;
}

.apb-offcanvas .wpml-ls-current-language a.wpml-ls-link {
    color: #fff;
    background: #185FA5;
    border-color: #185FA5;
}

.apb-offcanvas .wpml-ls-flag {
    display: none;
}

.apb-header__cta-btn {
    white-space: nowrap;
    font-size: .875rem !important;
    padding: .48rem 1.1rem !important;
    min-height: 40px !important;
    border-radius: 10px !important;
}

/* =========================================================================
   Hamburger (visible mobile ≤ 991px)
   ========================================================================= */

.apb-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    gap: 5px;
    border-radius: 8px;
    transition: background .15s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 10001;
}

.apb-hamburger:hover,
.apb-hamburger:focus-visible {
    background: #EBF3FB;
    outline: none;
}

.apb-hamburger__line {
    display: block;
    width: 24px;
    height: 2.5px;
    background: #1A1A2E;
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.77, 0, 0.175, 1);
    transform-origin: center;
    pointer-events: none;
}

/* Animation → X */
.apb-hamburger.is-active .apb-hamburger__line:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}
.apb-hamburger.is-active .apb-hamburger__line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.apb-hamburger.is-active .apb-hamburger__line:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* =========================================================================
   Off-canvas panel (mobile)
   ========================================================================= */

.apb-offcanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: none;
    visibility: hidden;
}

.apb-offcanvas.is-open {
    pointer-events: auto;
    visibility: visible;
}

/* Backdrop semi-transparent */
.apb-offcanvas__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.4s ease;
}

.apb-offcanvas.is-open .apb-offcanvas__backdrop {
    background: rgba(0, 0, 0, 0.45);
}

/* Panel slide depuis la droite */
.apb-offcanvas__panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100%;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.77, 0, 0.175, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.12);
}

.apb-offcanvas.is-open .apb-offcanvas__panel {
    transform: translateX(0);
}

/* En-tête panel : logo + bouton fermer */
.apb-offcanvas__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #E2E6EA;
    flex-shrink: 0;
}

.apb-offcanvas__logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.apb-offcanvas__logo img {
    height: 30px;
    width: auto;
}

.apb-offcanvas__brand {
    font-size: 16px;
    font-weight: 800;
    color: #185FA5;
    letter-spacing: -0.3px;
}

.apb-offcanvas__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: #F7F8FA;
    border-radius: 10px;
    cursor: pointer;
    color: #1A1A2E;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.apb-offcanvas__close:hover {
    background: #E2E6EA;
}

/* Zone navigation */
.apb-offcanvas__nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    overflow-y: auto;
}

.apb-offcanvas__link {
    display: flex;
    align-items: center;
    padding: 16px 28px;
    font-size: 17px;
    font-weight: 500;
    color: #1A1A2E;
    text-decoration: none;
    transition: all 0.25s ease;
    border-left: 3px solid transparent;
}

.apb-offcanvas__link:hover,
.apb-offcanvas__link:focus-visible {
    color: #185FA5;
    background: #EBF3FB;
    border-left-color: #185FA5;
    outline: none;
}

.apb-offcanvas__link.is-active {
    color: #185FA5;
    font-weight: 600;
    border-left-color: #185FA5;
}

/* Pied de panel : CTA + contact */
.apb-offcanvas__footer {
    padding: 24px;
    border-top: 1px solid #E2E6EA;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

/* Bouton principal (connecté → Mon espace) */
.apb-offcanvas__cta-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    background: #185FA5;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.25s ease;
    border: none;
    cursor: pointer;
    min-height: 48px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.apb-offcanvas__cta-primary:hover {
    background: #0C447C;
    transform: translateY(-1px);
}

/* Bouton secondaire (Devenir Pro) */
.apb-offcanvas__cta-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    background: #E6892A;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.25s ease;
    border: none;
    cursor: pointer;
    min-height: 48px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.apb-offcanvas__cta-secondary:hover {
    background: #C97720;
    transform: translateY(-1px);
}

/* Lien déconnexion */
.apb-offcanvas__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    color: #DC2626;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.apb-offcanvas__logout:hover {
    background: #FEF2F2;
}

/* Body : désactiver le scroll derrière l'off-canvas */
body.apb-no-scroll {
    overflow: hidden;
}

/* =========================================================================
   Responsive — breakpoints
   ========================================================================= */

@media (max-width: 991px) {
    /* Masquer nav desktop et CTA desktop */
    .apb-header__nav,
    .apb-header__desktop-cta {
        display: none !important;
    }

    /* Masquer aussi le switcher langue dans le header (visible dans l'off-canvas) */
    .apb-header__lang {
        display: none !important;
    }

    /* Afficher hamburger */
    .apb-hamburger {
        display: flex;
    }

    /* Pousser les actions (hamburger) à droite */
    .apb-header__actions {
        margin-left: auto;
    }

    /* Logo plus petit sur mobile */
    .apb-header__logo img {
        height: 28px !important;
    }

    .apb-header__logo-brand {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .apb-header__inner {
        padding: 0 1rem;
        height: 60px;
    }

    .apb-header__logo-brand {
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .apb-header__inner {
        padding: 0 .75rem;
        height: 56px;
    }
}
