/* Reset et variables CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5aa0;
    --secondary-color: #4a90e2;
    --accent-color: #00c851;
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.15);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Styles généraux */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background-gradient);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.logo:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-hover);
}

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Main content */
.main {
    flex: 1;
    width: 100%;
    max-width: 800px;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Module cards */
.module-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    text-decoration: none;
    color: var(--text-dark);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.module-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: var(--transition);
}

.module-card:hover::before {
    left: 100%;
}

.module-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-hover);
    background: rgba(255, 255, 255, 0.98);
}

.card-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.card-icon img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    transition: var(--transition);
}

.module-card:hover .card-icon img {
    transform: scale(1.1) rotate(-5deg);
    filter: brightness(1.1);
}

.module-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-align: center;
}

.module-card p {
    color: var(--text-light);
    text-align: center;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.card-arrow {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--secondary-color);
    transition: var(--transition);
}

.module-card:hover .card-arrow {
    transform: translateX(5px);
    color: var(--accent-color);
}

/* Footer */
.footer {
    margin-top: 3rem;
    text-align: center;
    animation: fadeIn 0.8s ease-out 0.4s both;
}

.footer p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .modules-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .module-card {
        padding: 2rem;
    }
    
    .logo {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .module-card {
        padding: 1.5rem;
    }
    
    .card-icon img {
        width: 50px;
        height: 50px;
    }
}

/* Header d'authentification transparent */
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: transparent;
    backdrop-filter: none;
    border-bottom: none;
    box-shadow: none;
    z-index: 1000;
    padding: 1rem 2rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.logo-section .logo {
    font-size: 1.5rem;
}

.auth-section {
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* Boutons d'authentification (non connecté) */
.auth-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn-subscribe {
    padding: 0.5rem 1.5rem;
    background: linear-gradient(135deg, #2E7D32 0%, #1B5E20 100%);
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
    animation: pulse 2s ease-in-out infinite;
}

.btn-subscribe:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 125, 50, 0.6);
    background: linear-gradient(135deg, #388E3C 0%, #2E7D32 100%);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
    }
    50% {
        box-shadow: 0 4px 16px rgba(46, 125, 50, 0.6);
    }
}

.btn-login {
    padding: 0.5rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-login:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* Section utilisateur connecté */
.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.profile-settings-btn {
    background: none;
    border: 2px solid #2E7D32;
    color: #2E7D32;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.profile-settings-btn:hover {
    background: #2E7D32;
    color: white;
    transform: scale(1.05);
}

.user-email {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.user-email:before {
    content: "📧";
    font-size: 1rem;
}

.btn-logout {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

.btn-logout:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

/* Ajuster le contenu principal pour le header transparent */
body:has(.top-bar) .container {
    margin-top: 0;
}

/* États des modules */
.module-card.disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(0.7);
    position: relative;
    transition: var(--transition);
}

.module-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
    background: var(--card-bg);
}

.module-card.disabled::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    border-radius: var(--border-radius);
    z-index: 1;
}

.module-card.disabled::after {
    content: "🔒 Connexion requise";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.module-card.disabled .card-icon,
.module-card.disabled h2,
.module-card.disabled p,
.module-card.disabled .card-arrow {
    position: relative;
    z-index: 0;
}

/* Responsive pour le header */
@media (max-width: 768px) {
    .top-bar {
        padding: 0.5rem 1rem;
        justify-content: flex-end;
        gap: 0.5rem;
        min-height: auto;
        padding-bottom: 0.75rem;
    }
    
    .logo-section {
        font-size: 1.1rem;
    }
    
    .auth-buttons {
        gap: 0.5rem;
    }
    
    .btn-subscribe, .btn-login {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
    
    .user-section {
        padding: 0.4rem 0.75rem;
        gap: 0.75rem;
    }
    
    .user-email {
        font-size: 0.85rem;
    }
    
    body:has(.top-bar) .container {
        margin-top: 100px;
    }
}

@media (max-width: 480px) {
    /* Optimisations bannière mobile */
    .top-bar {
        padding: 0.4rem 0.75rem;
    }
    
    .logo-section {
        font-size: 1rem;
    }
    
    .logo-section .logo {
        font-size: 1.25rem;
    }
    
    .btn-subscribe, .btn-login {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Section utilisateur - mode compact */
    .user-section {
        padding: 0.3rem 0.5rem;
        gap: 0.3rem;
        background: transparent;
    }
    
    /* Nom/Email utilisateur - masquer, remplacer par icône */
    .user-email {
        display: none;
    }
    
    /* Ajouter une icône utilisateur */
    .user-section::before {
        content: "👤";
        font-size: 16px;
        color: white;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    }
    
    /* Bouton settings plus compact */
    .profile-settings-btn {
        width: 1.8rem;
        height: 1.8rem;
        font-size: 0.85rem;
        padding: 0.3rem;
        border-color: rgba(255, 255, 255, 0.8);
        color: white;
    }
    
    .profile-settings-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        color: white;
    }
    
    /* Bouton logout plus compact */
    .btn-logout {
        padding: 0.25rem 0.6rem;
        font-size: 11px;
    }
}

/* User Dropdown Menu */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 2000;
    animation: dropdownSlideIn 0.2s ease-out;
}

.dropdown-menu.show {
    display: block;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px 12px 0 0;
}

.dropdown-header strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.dropdown-header span {
    display: block;
    font-size: 12px;
    color: var(--text-light);
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

.dropdown-item.logout-item {
    border-radius: 0 0 12px 12px;
    color: #dc3545;
}

.dropdown-item.logout-item:hover {
    background: #fff5f5;
    color: #c82333;
}

@media (max-width: 480px) {
    .dropdown-menu {
        min-width: 200px;
        right: -10px;
    }
}

/* ========================================
 * FIX iOS CAPACITOR - NOTCH iPhone
 * Date: 2025-10-30
 * Solution robuste avec fallback
 * ======================================== */

/* Fix padding pour que les boutons ne soient pas dans le notch */
.capacitor-app.platform-ios .top-bar {
    padding-top: max(50px, env(safe-area-inset-top, 50px)) !important;
}

/* Fallback universel pour tous les iOS si la détection échoue */
@supports (padding: max(0px, env(safe-area-inset-top))) {
    .top-bar {
        padding-top: max(50px, env(safe-area-inset-top, 50px)) !important;
    }
}
