/* ============================================================================
   IMAGILIRE MOBILE HEADER CSS
   Version: 1.0.0
   Description: Styles optimisés pour l'en-tête mobile avec support Android/iOS
   ============================================================================ */

/* Variables spécifiques au header mobile */
:root {
    --mobile-header-height: 64px;
    --mobile-header-compact-height: 56px;
    --mobile-header-bg: #36B1B3;
    --mobile-header-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    --mobile-header-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --mobile-safe-area-top: env(safe-area-inset-top, 0px);
    --mobile-safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================================
   HEADER PRINCIPAL - STRUCTURE DE BASE
   ============================================================================ */

.mobile-optimized-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: var(--mobile-header-bg);
    box-shadow: var(--mobile-header-shadow);
    transition: var(--mobile-header-transition);
    
    /* Support des zones sûres iOS (notch) */
    padding-top: var(--mobile-safe-area-top);
    
    /* Optimisations de performance */
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* État scrollé (header compact) */
.mobile-optimized-header.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Conteneur interne du header */
.mobile-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--mobile-header-height);
    padding: 0 1rem;
    max-width: 100%;
    margin: 0 auto;
    gap: 0.75rem;
    transition: var(--mobile-header-transition);
}

.mobile-optimized-header.scrolled .mobile-header-content {
    height: var(--mobile-header-compact-height);
}

/* ============================================================================
   SECTION GAUCHE - LOGO ET BRANDING
   ============================================================================ */

.mobile-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0; /* Permet au texte de se tronquer */
}

.mobile-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: var(--mobile-header-transition);
    overflow: hidden;
}

.mobile-optimized-header.scrolled .mobile-logo-container {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.mobile-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* Titre et sous-titre */
.mobile-title-container {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.mobile-header-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--mobile-header-transition);
}

.mobile-optimized-header.scrolled .mobile-header-title {
    font-size: 1rem;
}

.mobile-header-subtitle {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--mobile-header-transition);
    max-height: 1rem;
    opacity: 1;
}

.mobile-optimized-header.scrolled .mobile-header-subtitle {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* ============================================================================
   SECTION DROITE - ACTIONS
   ============================================================================ */

.mobile-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Boutons d'action du header */
.mobile-header-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--mobile-header-transition);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Effet de survol et d'activation */
.mobile-header-action-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.25);
}

.mobile-header-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Badge de notification (optionnel) */
.mobile-header-action-btn .badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #F7B731;
    border: 2px solid var(--mobile-header-bg);
}

/* État scrollé - boutons plus compacts */
.mobile-optimized-header.scrolled .mobile-header-action-btn {
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
}

/* ============================================================================
   BARRE DE PROGRESSION (INDICATEUR DE SCROLL)
   ============================================================================ */

.mobile-scroll-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.mobile-scroll-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #F7B731, #D4542D);
    width: 0%;
    transition: width 0.1s ease-out;
    transform-origin: left;
}

/* ============================================================================
   MENU HAMBURGER (pour navigation future)
   ============================================================================ */

.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: var(--mobile-header-transition);
    transform-origin: center;
}

.mobile-menu-btn span:not(:last-child) {
    margin-bottom: 6px;
}

/* Animation du menu hamburger en X */
.mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ============================================================================
   SUPPORT THÈME SOMBRE (auto-détection)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --mobile-header-bg: #2a7a7c;
    }
    
    .mobile-logo-container,
    .mobile-header-action-btn {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .mobile-header-action-btn:hover,
    .mobile-header-action-btn:active {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* ============================================================================
   OPTIMISATIONS SPÉCIFIQUES IOS
   ============================================================================ */

/* Support Safari iOS */
@supports (-webkit-touch-callout: none) {
    .mobile-optimized-header {
        /* Correction du padding pour les appareils iOS avec notch */
        padding-top: max(var(--mobile-safe-area-top), 0px);
    }
    
    /* Amélioration du rendu des arrière-plans flous sur iOS */
    .mobile-logo-container,
    .mobile-header-action-btn {
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
    
    /* Désactiver le zoom lors du double-tap sur iOS */
    .mobile-header-action-btn {
        touch-action: manipulation;
    }
}

/* ============================================================================
   OPTIMISATIONS SPÉCIFIQUES ANDROID
   ============================================================================ */

/* Support Chrome Android */
@supports selector(::-webkit-scrollbar) {
    /* Amélioration des performances sur Android */
    .mobile-optimized-header {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* ============================================================================
   MEDIA QUERIES - RESPONSIVE
   ============================================================================ */

/* Très petits mobiles (< 360px) */
@media (max-width: 359px) {
    .mobile-header-content {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
    
    .mobile-header-title {
        font-size: 1rem;
    }
    
    .mobile-header-subtitle {
        font-size: 0.7rem;
    }
    
    .mobile-logo-container {
        width: 44px;
        height: 44px;
    }
    
    .mobile-header-action-btn {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }
}

/* Mobiles standards (360px - 575px) */
@media (min-width: 360px) and (max-width: 575px) {
    .mobile-header-content {
        padding: 0 1rem;
    }
}

/* Grands mobiles et petites tablettes (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .mobile-header-content {
        padding: 0 1.25rem;
        gap: 1rem;
    }
    
    .mobile-logo-container {
        width: 52px;
        height: 52px;
    }
    
    .mobile-header-title {
        font-size: 1.25rem;
    }
    
    .mobile-header-subtitle {
        font-size: 0.8rem;
    }
}

/* Tablettes (768px+) - Retour au header desktop */
@media (min-width: 768px) {
    .mobile-optimized-header {
        position: relative;
        padding-top: 0;
    }
    
    .mobile-header-content {
        height: auto;
        padding: 1.5rem 2rem;
        gap: 1.5rem;
    }
    
    .mobile-logo-container {
        width: 80px;
        height: 80px;
    }
    
    .mobile-header-title {
        font-size: 1.75rem;
    }
    
    .mobile-header-subtitle {
        font-size: 1rem;
    }
    
    .mobile-header-action-btn {
        width: 48px;
        height: 48px;
    }
    
    /* Cacher la barre de progression sur tablette+ */
    .mobile-scroll-progress {
        display: none;
    }
}

/* Desktop (992px+) */
@media (min-width: 992px) {
    .mobile-header-content {
        max-width: 1200px;
    }
}

/* ============================================================================
   ANIMATIONS ET TRANSITIONS
   ============================================================================ */

/* Animation d'entrée du header au chargement */
@keyframes headerSlideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-optimized-header.animated {
    animation: headerSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animation de pulsation pour les actions importantes */
@keyframes headerPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.mobile-header-action-btn.pulse {
    animation: headerPulse 0.6s ease-in-out;
}

/* ============================================================================
   ACCESSIBILITÉ
   ============================================================================ */

/* Focus visible pour la navigation au clavier */
.mobile-header-action-btn:focus-visible,
.mobile-menu-btn:focus-visible {
    outline: 3px solid rgba(247, 183, 49, 0.8);
    outline-offset: 2px;
}

/* Réduction des animations si préférence utilisateur */
@media (prefers-reduced-motion: reduce) {
    .mobile-optimized-header,
    .mobile-header-content,
    .mobile-header-title,
    .mobile-header-subtitle,
    .mobile-logo-container,
    .mobile-header-action-btn,
    .mobile-scroll-progress-bar {
        transition: none;
        animation: none;
    }
}

/* ============================================================================
   OPTIMISATIONS DE PERFORMANCE
   ============================================================================ */

/* Hardware acceleration pour les éléments animés */
.mobile-optimized-header,
.mobile-logo-container,
.mobile-header-action-btn {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Optimisation du rendu */
.mobile-optimized-header * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   MODE PAYSAGE (LANDSCAPE)
   ============================================================================ */

@media (max-width: 767px) and (orientation: landscape) {
    :root {
        --mobile-header-height: 56px;
        --mobile-header-compact-height: 48px;
    }
    
    .mobile-header-content {
        height: var(--mobile-header-height);
        padding: 0 1rem;
    }
    
    .mobile-logo-container {
        width: 40px;
        height: 40px;
    }
    
    .mobile-header-title {
        font-size: 1rem;
    }
    
    .mobile-header-subtitle {
        font-size: 0.7rem;
    }
    
    .mobile-header-action-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ============================================================================
   ÉTATS D'ERREUR ET DE CHARGEMENT
   ============================================================================ */

/* État de chargement */
.mobile-optimized-header.loading {
    pointer-events: none;
}

.mobile-optimized-header.loading .mobile-logo-container {
    animation: headerPulse 1.5s ease-in-out infinite;
}

/* Overlay semi-transparent pour les états de chargement */
.mobile-header-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.mobile-optimized-header.loading .mobile-header-overlay {
    display: flex;
}

/* ============================================================================
   MASQUAGE DU FAB SETTINGS SUR MOBILE
   ============================================================================ */

@media (max-width: 767px) {
    /* Masquer spécifiquement le settings-icon sur mobile */
    .mobile-optimized-header ~ .settings-icon {
        display: none !important;
    }
}

@media (min-width: 768px) {
    /* Afficher le settings-icon sur tablette+ */
    .mobile-optimized-header ~ .settings-icon {
        display: flex !important;
    }
}

/* Cacher des éléments sur mobile uniquement */
.mobile-hide {
    display: none !important;
}

@media (min-width: 768px) {
    .mobile-hide {
        display: block !important;
    }
}

/* Afficher des éléments sur mobile uniquement */
.mobile-show {
    display: block !important;
}

@media (min-width: 768px) {
    .mobile-show {
        display: none !important;
    }
}
