/* FILE: public/templates/headers/header-membre-mobile.css
 * URL: https://mymoonova.com/mymoonova/public/templates/headers/header-membre-mobile.css
 * CHANGELOG: [11/10/2025 03:15 Europe/Paris] Fix desktop : masquer .mobile-nav par défaut (navigation dupliquée)
 */

/* ╔════════════════════════════════════════════════════════════════════════════╗
 * ⚠️ CSS MOBILE HEADERS MEMBRE - Breakpoint 768px ⚠️
 * Cible: header-membre*.php (5 fichiers)
 * Objectif: Smart Header mobile : 80px initial, 48px scrolled (93% contenu)
 * Gains: Métriques drawer, bandeau réduit, shrink on scroll, transitions smooth
 * NE PAS dupliquer ces règles dans le CSS inline des fichiers PHP
 * ╚════════════════════════════════════════════════════════════════════════════╝ */

/* ═══════════════════════════════════════════════════════════════════════════
 * FIX CRITIQUE: MASQUER ÉLÉMENTS MOBILE PAR DÉFAUT (GLOBAL DESKTOP)
 * ═══════════════════════════════════════════════════════════════════════════ */
.drawer-metrics {
  display: none;
}

.mobile-nav {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 1. CACHER MÉTRIQUES MOBILE (vont dans drawer)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .banner-metrics {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 2. BANDEAU INITIAL 80px + TRANSITIONS
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .header-membre {
    transition: background 0.3s ease;
  }

  .header-banner {
    padding: 16px 0;
    min-height: 80px;
    transition: all 0.3s ease;
  }

  .banner-content {
    flex-direction: column;
    gap: 16px;
    text-align: center;
    padding: 0 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 3. TITRES AVEC TRANSITIONS
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .banner-info h1 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    transition: all 0.3s ease;
  }

  .banner-info p {
    font-size: 0.9rem;
    line-height: 1.4;
    transition: all 0.3s ease;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 3B. SMART HEADER - SHRINK ON SCROLL (MOBILE)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* État expanded (initial) - explicite */
  .header-membre.header-expanded .header-banner {
    min-height: 80px;
  }

  /* État shrunk (après scroll >50px) */
  .header-membre.header-shrunk .header-banner {
    min-height: 48px;
    padding: 8px 0;
  }

  .header-membre.header-shrunk .banner-info h1 {
    font-size: 1rem;
    margin: 0;
  }

  .header-membre.header-shrunk .banner-info p {
    display: none;
  }

  .header-membre.header-shrunk {
    background: var(--blanc, #FFFFFF);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 4. REPOSITIONNER ACTIONS UTILISATEUR
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .user-actions {
    position: static !important;
    justify-content: center;
    margin-top: 12px;
    top: auto;
    right: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 5. TAILLE TACTILE MINIMUM 44×44px
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .nav-link,
  .logout-link,
  .mobile-toggle,
  .accordion-header,
  .mobile-link {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
    touch-action: manipulation;
  }

  .logout-link {
    padding: 10px 16px;
    font-size: 0.875rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 6. NAVIGATION MOBILE - DRAWER LATÉRAL GAUCHE
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Bouton fermer drawer */
  .mobile-nav-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2002;
    min-height: 44px;
    min-width: 44px;
    transition: background 0.2s ease;
  }

  .mobile-nav-close:hover,
  .mobile-nav-close:focus {
    background: rgba(255, 255, 255, 0.35);
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
  }

  /* Cacher nav desktop */
  .nav-tabs {
    display: none;
  }

  /* Afficher bouton hamburger */
  .mobile-toggle {
    display: block;
    margin: 12px 16px;
    width: calc(100% - 32px);
    text-align: center;
    position: relative;
  }

  .mobile-toggle::before {
    content: '☰';
    margin-right: 8px;
    font-size: 1.2rem;
  }

  /* Drawer latéral */
  .mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: var(--blanc, #FFFFFF);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 2000;
    overflow-y: auto;
    padding: 24px 20px;
    border-top: none;
  }

  .mobile-nav.active,
  .mobile-nav.open {
    transform: translateX(0);
  }

  /* Section métriques dans drawer - AFFICHER UNIQUEMENT ICI */
  .mobile-nav .drawer-metrics {
    display: block;
    background: linear-gradient(135deg, 
      var(--couleur-metier, #6B46C1) 0%, 
      var(--couleur-secondary, #7C3AED) 100%);
    color: var(--blanc, #FFFFFF);
    padding: 20px;
    margin: -24px -20px 20px -20px;
    border-radius: 0;
  }

  .drawer-metrics h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    font-weight: 600;
  }

  .drawer-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .drawer-metric:last-child {
    border-bottom: none;
  }

  .drawer-metric-label {
    font-size: 0.875rem;
    opacity: 0.9;
  }

  .drawer-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
  }

  .drawer-separator {
    height: 1px;
    background: var(--gris, #E5E7EB);
    margin: 20px 0;
  }

  /* Liste mobile verticale */
  .mobile-nav .nav-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
  }

  .mobile-nav .nav-link,
  .mobile-nav .mobile-link {
    padding: 14px 16px;
    border-radius: 8px;
    width: 100%;
    text-align: left;
    position: relative;
    z-index: 2001;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--noir, #000000);
    font-weight: 500;
  }

  .mobile-nav .nav-link:hover,
  .mobile-nav .mobile-link:hover {
    transform: none;
    background: var(--gris, #F5F5F5);
  }

  .mobile-nav .nav-link.active,
  .mobile-nav .nav-link[aria-current="page"] {
    background: var(--couleur-metier, #6B46C1);
    color: var(--blanc, #FFFFFF);
  }

  /* Fix critique: Liens cliquables au-dessus de tout */
  .mobile-nav .logout-link {
    position: relative;
    z-index: 2001;
    display: flex;
    align-items: center;
  }

  /* Sections mobile */
  .mobile-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gris, #F5F5F5);
  }

  .mobile-section:last-child {
    border-bottom: none;
  }

  .mobile-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--couleur-metier, #6B46C1);
  }

  .mobile-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gris, #F5F5F5);
  }

  .mobile-primary {
    color: var(--couleur-metier, #6B46C1);
    font-weight: 600;
  }

  .mobile-cta {
    background: var(--couleur-metier, #6B46C1);
    color: var(--blanc, #FFFFFF);
    font-weight: 600;
    text-align: center;
    border-radius: 8px;
    margin-top: 8px;
  }

  .mobile-cta:hover {
    background: #553C9A;
    color: var(--blanc, #FFFFFF);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 7. ACCORDÉONS (si sous-menus présents)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-base, 'Segoe UI', Arial, sans-serif);
    color: var(--gris-fonce, #6C757D);
    font-weight: 500;
  }

  .accordion-icon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
  }

  .accordion-header[aria-expanded="true"] .accordion-icon {
    transform: rotate(180deg);
  }

  .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .accordion-content.open {
    max-height: 500px;
  }

  .accordion-content .nav-link {
    padding-left: 32px;
    font-size: 0.9rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 8. ESPACEMENTS & GAPS
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .nav-container {
    padding: 0 16px;
  }

  .user-actions {
    gap: 12px;
  }

  .banner-content {
    gap: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 9. ACCESSIBILITÉ & FOCUS
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .nav-link:focus,
  .logout-link:focus,
  .mobile-toggle:focus,
  .accordion-header:focus,
  .mobile-link:focus {
    outline: 3px solid var(--couleur-metier, #6B46C1);
    outline-offset: 2px;
  }

  /* Focus trap dans drawer */
  .mobile-nav.active,
  .mobile-nav.open {
    outline: none;
  }

  .mobile-nav.active .nav-link:first-child,
  .mobile-nav.open .nav-link:first-child {
    margin-top: 8px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 10. ANIMATIONS RÉDUITES (prefers-reduced-motion)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .mobile-nav,
  .accordion-icon,
  .accordion-content,
  .nav-link,
  .logout-link,
  .mobile-link,
  .header-membre,
  .header-banner,
  .banner-info h1,
  .banner-info p {
    transition: none !important;
    animation: none !important;
  }

  .mobile-nav.active,
  .mobile-nav.open {
    transform: translateX(0);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 11. TRÈS PETITS ÉCRANS (< 360px)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 359px) {
  .banner-info h1 {
    font-size: 1rem;
  }

  .banner-info p {
    font-size: 0.85rem;
  }

  .mobile-nav {
    width: 100%;
  }

  .mobile-toggle {
    font-size: 0.85rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 12. ÉTATS DE CHARGEMENT
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .loading .mobile-nav {
    opacity: 0.6;
    pointer-events: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 13. FERMETURE DRAWER (clic overlay)
 * ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .drawer-overlay {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
    cursor: pointer;
  }

  .drawer-overlay.active {
    display: block;
  }

  /* Bloquer scroll body quand drawer ouvert */
  body.drawer-open {
    overflow: hidden;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * FIN CSS MOBILE MEMBRE
 * Hauteur finale: 80px initial → 48px scrolled (objectif Smart Header ✅)
 * Gain: +11% contenu visible après scroll (93% vs 82%)
 * Métriques déplacées dans drawer, transitions smooth
 * FIX: drawer-metrics + mobile-nav masqués par défaut (desktop), visibles mobile
 * ═══════════════════════════════════════════════════════════════════════════ */