/* ===== NOUVEAU MENU MOBILE ===== */

/* ===== SECTION UTILISATEUR MOBILE ===== */
.mobile-user-section {
  border-top: 2px solid rgba(254, 163, 71, 0.2);
  padding-top: 20px;
  margin-top: 20px;
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  background: linear-gradient(135deg, rgba(254, 163, 71, 0.1) 0%, rgba(128, 0, 128, 0.1) 100%);
  border-radius: 12px;
  margin-bottom: 15px;
}

.mobile-user-info i {
  font-size: 2.5rem;
  color: var(--primary);
}

.mobile-user-details {
  flex: 1;
}

.mobile-user-name {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 3px;
}

.mobile-user-role {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.mobile-logout-form {
  margin: 0;
}

.logout-mobile {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: #dc2626 !important;
  font-family: inherit;
  font-size: 1rem;
  padding: 15px 20px;
}

.logout-mobile:hover {
  background-color: rgba(220, 38, 38, 0.1);
  color: #dc2626 !important;
}

/* Bouton hamburger optimisé */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    z-index: 1001;
    transition: transform 0.3s ease;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.hamburger-menu:hover {
    background-color: rgba(254, 163, 71, 0.1);
}

.hamburger-menu:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* Animation du hamburger quand actif */
.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Overlay sombre */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* Menu mobile sliding */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    max-width: 80vw;
    height: 100vh;
    background: var(--background);
    z-index: 1001;
    transition: right 0.3s ease;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
}

.mobile-menu.active {
    right: 0;
}

/* Header du menu mobile */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: var(--surface);
}

.mobile-logo {
    height: 40px;
    width: auto;
}

.mobile-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.mobile-close:hover {
    background: rgba(254, 163, 71, 0.1);
    color: var(--primary);
}

/* Liste du menu mobile */
.mobile-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-menu-list > li {
    border-bottom: 1px solid #f0f0f0;
}

.mobile-link {
    display: block;
    padding: 15px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.mobile-link:hover,
.mobile-link.active {
    background: rgba(254, 163, 71, 0.1);
    border-left-color: var(--primary);
    color: var(--primary);
}

/* Dropdowns du menu mobile */
.mobile-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-dropdown-header .mobile-link {
    flex: 1;
    border-left: none;
}

.dropdown-arrow {
    background: none;
    border: none;
    padding: 15px 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropdown-arrow:hover {
    color: var(--primary);
}

.dropdown-arrow i {
    transition: transform 0.3s ease;
}

.mobile-dropdown.active .dropdown-arrow i {
    transform: rotate(180deg);
}

/* Sous-menus */
.mobile-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--background);
}

.mobile-dropdown.active .mobile-submenu {
    max-height: 300px;
}

.mobile-sublink {
    display: block;
    padding: 12px 20px 12px 40px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.mobile-sublink:hover,
.mobile-sublink.active {
    background: rgba(254, 163, 71, 0.1);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Footer du menu mobile */
.mobile-menu-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: var(--surface);
}

.mobile-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: linear-gradient(45deg, var(--primary), #ffb366);
    color: white;
    text-decoration: none;
    padding: 15px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(254, 163, 71, 0.3);
}

.mobile-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(254, 163, 71, 0.4);
}

/* Bouton de connexion mobile optimisé */
.login-button-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(254, 163, 71, 0.1);
    color: var(--primary);
    text-decoration: none;
    border-radius: 50%;
    font-size: 16px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.login-button-mobile:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Classes utilitaires responsive améliorées */
.desktop-only {
    display: inline-flex;
}

.mobile-only {
    display: none;
}

.tablet-only {
    display: none;
}

/* Affichage conditionnel selon les breakpoints */
@media (max-width: 1024px) and (min-width: 768px) {
    .tablet-only {
        display: inline-flex;
    }
    
    .desktop-large-only {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex;
    }
    
    .tablet-only,
    .desktop-only {
        display: none !important;
    }
}

/* Classes pour gérer l'espacement selon l'appareil */
.spacing-mobile-sm { margin: 8px; }
.spacing-mobile-md { margin: 12px; }
.spacing-mobile-lg { margin: 16px; }

@media (min-width: 768px) {
    .spacing-tablet-sm { margin: 12px; }
    .spacing-tablet-md { margin: 16px; }
    .spacing-tablet-lg { margin: 20px; }
}

@media (min-width: 1024px) {
    .spacing-desktop-sm { margin: 16px; }
    .spacing-desktop-md { margin: 20px; }
    .spacing-desktop-lg { margin: 24px; }
}

/* Responsive optimisé - Afficher le hamburger selon les breakpoints */
/* Tablette portrait et mobile (768px et moins) */
@media (max-width: 768px) {
    .hamburger-menu {
        display: flex;
    }
    
    .desktop-nav {
        display: none;
    }
    
    /* Afficher le bouton de connexion mobile */
    .login-button-mobile {
        display: flex;
    }
    
    /* Cacher les boutons desktop */
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: flex;
    }
    
    /* Ajustements des actions header sur mobile */
    .header-actions {
        gap: 12px !important;
        align-items: center;
        flex-shrink: 0;
    }
    
    /* Ajustement de la hauteur du header sur mobile */
    .header-content {
        padding: 8px 0 !important;
        min-height: 65px !important;
    }
    
    /* Optimisation des éléments du header mobile */
    .theme-toggle {
        padding: 6px;
    }
    
    .theme-toggle-track {
        width: 45px !important;
        height: 24px !important;
    }
    
    .theme-toggle-thumb {
        width: 20px !important;
        height: 20px !important;
    }
    
    .theme-toggle.dark .theme-toggle-thumb {
        transform: translateX(21px) !important;
    }
    
    /* Alignement vertical parfait */
    .theme-toggle,
    .login-button-mobile,
    .hamburger-menu,
    .user-toggle-mobile {
        margin: 0;
        align-self: center;
    }
    
    /* Cacher les anciens éléments du menu mobile */
    .mobile-menu-toggle,
    .mobile-nav {
        display: none !important;
    }
}

/* Mobile standard (480px et moins) */
@media (max-width: 480px) {
    .header-actions {
        gap: 8px !important;
    }
    
    .header-content {
        padding: 6px 0 !important;
        min-height: 60px !important;
    }
    
    .theme-toggle-track {
        width: 42px !important;
        height: 22px !important;
    }
    
    .theme-toggle-thumb {
        width: 18px !important;
        height: 18px !important;
    }
    
    .theme-toggle.dark .theme-toggle-thumb {
        transform: translateX(20px) !important;
    }
}

/* Très petits écrans (320px et moins) */
@media (max-width: 320px) {
    .header-actions {
        gap: 6px !important;
    }
    
    .header-content {
        padding: 5px 0 !important;
        min-height: 55px !important;
    }
    
    .theme-toggle-track {
        width: 38px !important;
        height: 20px !important;
    }
    
    .theme-toggle-thumb {
        width: 16px !important;
        height: 16px !important;
    }
    
    .theme-toggle.dark .theme-toggle-thumb {
        transform: translateX(18px) !important;
    }
}

/* Animations d'entrée */
.mobile-menu.active .mobile-menu-header {
    animation: slideInRight 0.3s ease;
}

.mobile-menu.active .mobile-menu-list > li {
    animation: slideInRight 0.3s ease;
    animation-fill-mode: both;
}

.mobile-menu.active .mobile-menu-list > li:nth-child(1) { animation-delay: 0.1s; }
.mobile-menu.active .mobile-menu-list > li:nth-child(2) { animation-delay: 0.2s; }
.mobile-menu.active .mobile-menu-list > li:nth-child(3) { animation-delay: 0.3s; }
.mobile-menu.active .mobile-menu-list > li:nth-child(4) { animation-delay: 0.4s; }
.mobile-menu.active .mobile-menu-list > li:nth-child(5) { animation-delay: 0.5s; }
.mobile-menu.active .mobile-menu-list > li:nth-child(6) { animation-delay: 0.6s; }

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animation d'entrée optimisée pour la performance */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Animation pour le hamburger */
@keyframes hamburgerPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.hamburger-menu:focus {
    animation: hamburgerPulse 0.6s ease;
}

/* Animation pour les éléments interactifs */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.mobile-link:active,
.mobile-sublink:active {
    animation: buttonPress 0.15s ease;
}

/* Empêcher le scroll du body quand le menu est ouvert */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Améliorations UX et performance */

/* Zones de touch optimisées */
@media (max-width: 768px) {
    .hamburger-menu,
    .mobile-close,
    .dropdown-arrow,
    .theme-toggle,
    .login-button-mobile,
    .user-toggle-mobile {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-link,
    .mobile-sublink {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
}

/* États visuels améliorés */
.mobile-link:active,
.mobile-sublink:active,
.hamburger-menu:active,
.mobile-close:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* Smooth scrolling pour le menu mobile */
.mobile-menu {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Indication visuelle du menu actif */
.mobile-menu.active {
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
}

/* Amélioration des transitions */
.mobile-menu,
.mobile-overlay {
    will-change: transform, opacity;
}

/* Support du mode sombre */
body.dark-mode .mobile-menu {
    background: var(--background);
    color: var(--text-primary);
}

body.dark-mode .mobile-menu-header {
    background: var(--surface);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .mobile-menu-footer {
    background: var(--surface);
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .mobile-menu-list > li {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .mobile-link {
    color: var(--text-primary);
}

body.dark-mode .mobile-sublink {
    color: var(--text-secondary);
}

/* Orientation landscape spécifique */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-menu {
        width: 280px;
        max-width: 70vw;
    }
    
    .mobile-link {
        padding: 10px 15px;
        font-size: 15px;
    }
    
    .mobile-sublink {
        padding: 8px 15px 8px 30px;
        font-size: 13px;
    }
    
    .mobile-menu-header {
        padding: 15px;
    }
    
    .mobile-menu-footer {
        padding: 15px;
    }
}

/* Animation optimisée pour les très petits écrans */
@media (max-width: 320px) {
    .mobile-menu.active .mobile-menu-list > li {
        animation-duration: 0.2s;
    }
    
    .mobile-menu.active .mobile-menu-list > li:nth-child(n+5) {
        animation-delay: 0.4s;
    }
}

/* Preload hint pour les images du menu mobile */
.mobile-logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Support des préférences utilisateur */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu,
    .mobile-overlay,
    .hamburger-menu,
    .mobile-link,
    .mobile-sublink,
    .dropdown-arrow i {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
    
    .mobile-menu.active .mobile-menu-list > li {
        animation: none !important;
    }
}

/* Support des connexions lentes */
.slow-connection .mobile-menu.active .mobile-menu-list > li {
    animation-duration: 0.1s;
    animation-delay: 0s !important;
}

/* Optimisations pour écrans haute densité */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hamburger-line {
        height: 2px;
        border-radius: 1px;
    }
    
    .mobile-menu {
        border-left-width: 0.5px;
    }
}

/* Support du mode contraste élevé */
@media (prefers-contrast: high) {
    .mobile-menu {
        border: 2px solid var(--text-primary);
    }
    
    .mobile-link {
        border-left-width: 6px;
    }
    
    .mobile-link:hover,
    .mobile-sublink:hover {
        background-color: var(--text-primary);
        color: var(--background);
    }
}

/* Amélioration pour les écrans pliables */
@media (max-width: 768px) and (max-height: 600px) {
    .mobile-menu {
        width: 320px;
        max-width: 90vw;
    }
    
    .mobile-link {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .mobile-menu-header {
        padding: 10px 15px;
    }
    
    .mobile-menu-footer {
        padding: 10px 15px;
    }
}