/* ===== VARIABLES & RESET ===== */
:root {
    /* Couleurs par structure */
    --color-petite-enfance: #FFC107;
    --color-scolaire: #2196F3;
    --color-hotel: #9C27B0;
    --color-entreprise: #00BCD4;
    --color-hospitalier: #F44336;
    
    /* Couleurs par rôle */
    --color-cuisinier: #FF6B35;
    --color-gestionnaire: #2D5AA0;
    --color-admin: #4CAF50;
    
    /* Couleurs neutres */
    --color-light: #F8F9FA;
    --color-gray: #6C757D;
    --color-dark: #343A40;
    --color-white: #FFFFFF;
    --color-black: #212529;
    
    /* Ombres */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
    
    /* Arrondis */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== STRUCTURE GÉNÉRALE ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===== PAGE 1: CHOIX ÉTABLISSEMENT ===== */
.page-home {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 2rem 0;
}

.header-home {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeIn 0.8s ease-out;
}

.title-home {
    font-size: 3.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 1rem;
}

.subtitle-home {
    font-size: 1.25rem;
    color: var(--color-gray);
    max-width: 600px;
    margin: 0 auto;
}

/* Cartes structure améliorées */
.structures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 3rem 0;
}

.structure-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
    border: 2px solid transparent;
    animation: fadeIn 0.6s ease-out backwards;
}

.structure-card:nth-child(1) { animation-delay: 0.1s; }
.structure-card:nth-child(2) { animation-delay: 0.2s; }
.structure-card:nth-child(3) { animation-delay: 0.3s; }
.structure-card:nth-child(4) { animation-delay: 0.4s; }
.structure-card:nth-child(5) { animation-delay: 0.5s; }

.structure-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: currentColor;
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.structure-card:hover::before {
    transform: scaleX(1);
}

.structure-card.selected::before {
    transform: scaleX(1);
}

.structure-card.selected {
    border-color: currentColor;
    box-shadow: var(--shadow-xl);
    transform: translateY(-8px);
}

.structure-icon-wrapper {
    width: 80px;
    height: 80px;
    background: rgba(0,0,0,0.05);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    transition: all var(--transition-normal);
}

.structure-card:hover .structure-icon-wrapper {
    transform: scale(1.1) rotate(5deg);
    background: rgba(0,0,0,0.1);
}

.structure-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--color-dark);
}

.structure-description {
    color: var(--color-gray);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.checkmark {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 24px;
    height: 24px;
    background: var(--color-white);
    border: 2px solid currentColor;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-normal);
}

.structure-card.selected .checkmark {
    opacity: 1;
    transform: scale(1);
    background: currentColor;
}

.checkmark svg {
    width: 12px;
    height: 12px;
    fill: var(--color-white);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0,0,0,0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.1rem;
    color: var(--color-gray);
    animation: pulse 2s infinite;
}

/* Cookie banner */
.cookie-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-white);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    z-index: 1000;
    animation: slideUp 0.5s ease-out forwards;
}

@keyframes slideUp {
    to { transform: translateX(-50%) translateY(0); }
}

.cookie-banner.hidden {
    animation: slideDown 0.5s ease-out forwards;
}

@keyframes slideDown {
    to { transform: translateX(-50%) translateY(100px); }
}

/* ===== PAGE 2: CONNEXION ===== */
.page-login {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 2rem 0;
}

.login-container {
    max-width: 500px;
    margin: 0 auto;
}

.structure-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    animation: slideInFromLeft 0.6s ease-out;
}

.structure-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.structure-icon-large {
    font-size: 2.5rem;
}

.structure-details h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--color-dark);
}

.structure-details p {
    color: var(--color-gray);
    font-size: 0.9rem;
}

/* Sélecteur de rôle */
.role-selector {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    animation: slideInFromRight 0.6s ease-out 0.2s backwards;
}

.role-selector-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--color-dark);
}

.role-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.role-option {
    padding: 1.5rem;
    border: 2px solid var(--color-light);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.role-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: currentColor;
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.role-option:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.role-option.active {
    border-color: currentColor;
    background: rgba(0,0,0,0.02);
}

.role-option.active::before {
    transform: scaleX(1);
}

.role-option.cuisinier.active {
    color: var(--color-cuisinier);
}

.role-option.gestionnaire.active {
    color: var(--color-gestionnaire);
}

.role-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.role-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.role-description {
    color: var(--color-gray);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Formulaire de connexion */
.login-form-container {
    animation: formAppear 0.6s ease-out 0.4s backwards;
}

.login-form {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-form-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-form-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
}

.login-form-subtitle {
    color: var(--color-gray);
    font-size: 1rem;
}

.role-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.role-badge.cuisinier {
    background: rgba(255, 107, 53, 0.1);
    color: var(--color-cuisinier);
}

.role-badge.gestionnaire {
    background: rgba(45, 90, 160, 0.1);
    color: var(--color-gestionnaire);
}

/* Champs de formulaire */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-dark);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
    background: var(--color-white);
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-control.error {
    border-color: #f56565;
}

.error-message {
    color: #f56565;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Options additionnelles */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: 18px;
    height: 18px;
}

.form-check-label {
    font-size: 0.9rem;
    color: var(--color-gray);
}

.forgot-password {
    font-size: 0.9rem;
    color: #667eea;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.forgot-password:hover {
    color: #5a67d8;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    gap: 0.5rem;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--color-white);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid #e2e8f0;
    color: var(--color-dark);
}

.btn-outline:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

.btn-full {
    width: 100%;
}

/* Liens d'action */
.action-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.action-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-gray);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
}

.action-link:hover {
    color: #667eea;
}

/* Footer connexion */
.login-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--color-gray);
    font-size: 0.9rem;
    animation: fadeIn 0.6s ease-out 0.6s backwards;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal-content {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    opacity: 0;
    transition: all var(--transition-normal);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-gray);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--color-dark);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .title-home {
        font-size: 2.5rem;
    }
    
    .structures-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .role-options {
        grid-template-columns: 1fr;
    }
    
    .login-form {
        padding: 1.5rem;
    }
    
    .structure-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .action-links {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .title-home {
        font-size: 2rem;
    }
    
    .login-form {
        padding: 1rem;
    }
}

/* ===== UTILITAIRES ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }

.hidden { display: none; }
.visible { display: block; }

/* ===== THEME SOMBRE ===== */
[data-theme="dark"] {
    --color-light: #1a202c;
    --color-dark: #e2e8f0;
    --color-white: #2d3748;
    --color-black: #e2e8f0;
    --color-gray: #a0aec0;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
}

[data-theme="dark"] .structure-card,
[data-theme="dark"] .login-form,
[data-theme="dark"] .role-selector,
[data-theme="dark"] .structure-header {
    background: #2d3748;
    color: #e2e8f0;
}

[data-theme="dark"] .structure-title,
[data-theme="dark"] .role-name {
    color: #e2e8f0;
}

[data-theme="dark"] .structure-description,
[data-theme="dark"] .role-description {
    color: #a0aec0;
}