/* =============================================
   SYSTÈME DE VARIABLES CSS OPTIMISÉ
   ============================================= */
:root {
    /* === COULEURS PRINCIPALES === */
    --primary-start: #667eea;
    --primary-end: #764ba2;
    --accent-color: #667eea;
    --accent-hover: #764ba2;
    
    /* === COULEURS SYSTÈME === */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-light: #a0aec0;
    
    --bg-white: #ffffff;
    --bg-light: #f7fafc;
    --bg-lighter: #edf2f7;
    --bg-accent: #f0f4ff;
    
    --border-light: #e2e8f0;
    --border-medium: #cbd5e0;
    
    --success-color: #38a169;
    --success-light: #48bb78;
    --error-color: #e53e3e;
    --warning-color: #d69e2e;
    
    /* === ESPACEMENTS === */
    --spacing-xs: 0.5rem;   /* 8px */
    --spacing-sm: 0.75rem;  /* 12px */
    --spacing-md: 1rem;     /* 16px */
    --spacing-lg: 1.25rem;  /* 20px */
    --spacing-xl: 1.875rem; /* 30px */
    --spacing-2xl: 2.5rem;  /* 40px */
    
    /* === RAYONS DE BORDURE === */
    --radius-sm: 0.5rem;    /* 8px */
    --radius-md: 0.625rem;  /* 10px */
    --radius-lg: 0.75rem;   /* 12px */
    --radius-xl: 1rem;      /* 16px */
    --radius-2xl: 1.25rem;  /* 20px */
    
    /* === TAILLES DE POLICE === */
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.875rem;    /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.25rem;     /* 20px */
    --text-2xl: 1.5rem;     /* 24px */
    --text-3xl: 1.875rem;   /* 30px */
    --text-4xl: 2.25rem;    /* 36px */
    --text-5xl: 3rem;       /* 48px */
    
    /* === OMBRES === */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --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.1);
    --shadow-2xl: 0 20px 40px rgba(0, 0, 0, 0.1);
    
    /* === TRANSITIONS === */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* === BREAKPOINTS === */
    --mobile: 480px;
    --tablet: 768px;
    --desktop: 1024px;
    
    /* === Z-INDEX === */
    --z-modal: 1000;
    --z-overlay: 2000;
    --z-tooltip: 3000;
}

[data-theme="green"] {
    --primary-start: #d1fae5;
    --primary-end: #a7f3d0;
    --accent-color: #10b981;
    --accent-hover: #059669;
}

[data-theme="orange"] {
    --primary-start: #fed7aa;
    --primary-end: #fbbf24;
    --accent-color: #f59e0b;
    --accent-hover: #d97706;
}

/* Thème pour le mode examen */
.btn-exam {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-exam:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

[data-theme="dark"] {
    --primary-start: #2c3e50;
    --primary-end: #34495e;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
}

/* =============================================
   RESET ET UTILITAIRES GLOBAUX
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === CLASSES UTILITAIRES === */
.border-standard {
    border: 2px solid var(--border-light);
}

.border-accent {
    border: 2px solid var(--accent-color);
}

.bg-light {
    background: var(--bg-light);
}

.bg-accent {
    background: var(--bg-accent);
}

.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-muted);
}

.radius-sm { border-radius: var(--radius-sm); }
.radius-md { border-radius: var(--radius-md); }
.radius-lg { border-radius: var(--radius-lg); }
.radius-xl { border-radius: var(--radius-xl); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

.transition-base { transition: all var(--transition-base); }
.transition-fast { transition: all var(--transition-fast); }

/* === CLASSES DE BASE POUR COMPOSANTS === */
.btn-base {
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-xl);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-height: 44px;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.card-base {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    box-shadow: var(--shadow-2xl);
}

.input-base {
    padding: var(--spacing-sm);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: border-color var(--transition-base);
}

.input-base:focus {
    outline: none;
    border-color: var(--accent-color);
}

.modal-base {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.modal-card {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-2xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-2xl);
    text-align: center;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.theme-selector {
    position: absolute;
    top: -30px;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-selector span {
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s;
    user-select: none;
}

.theme-selector span:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.1);
}

.header h1 {
    color: #4a5568;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.setup-form {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #2d3748;
}

/* =============================================
   SYSTÈME DE FORMULAIRES OPTIMISÉ
   ============================================= */
.form-group select,
.form-group input {
    padding: var(--spacing-sm);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: border-color var(--transition-base);
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s;
}

.checkbox-label:hover {
    border-color: var(--accent-color);
    background: #f0f4ff;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    padding: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]:checked + span {
    color: var(--accent-color);
    font-weight: 600;
}

.difficulty-mode {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.3s;
    flex: 1;
    justify-content: center;
}

.radio-label:hover {
    border-color: var(--accent-color);
    background: #f0f4ff;
}

.radio-label input[type="radio"] {
    margin: 0;
    padding: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    color: var(--accent-color);
    font-weight: 600;
}

.radio-label:has(input[type="radio"]:checked) {
    border-color: var(--accent-color);
    background: #f0f4ff;
}

/* =============================================
   SYSTÈME DE BOUTONS OPTIMISÉ
   ============================================= */
.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-xl);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-height: 44px;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    color: var(--bg-white);
}

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

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 2px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-lighter);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-light) 0%, var(--success-color) 100%);
    color: var(--bg-white);
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--success-color) 0%, #2f855a 100%);
    transform: translateY(-2px);
}

.btn-exam {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    color: var(--bg-white);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-exam:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* États des boutons */
.btn:active {
    transform: scale(0.98);
    transition: transform var(--transition-fast);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--border-light);
    color: var(--text-light);
}

.quiz-container {
    display: none;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #f7fafc;
    border-radius: 10px;
}

.question-info {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

.timer {
    font-size: 24px;
    font-weight: bold;
    color: #e53e3e;
    background: white;
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-left: 20px;
}

.question-card {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 3px solid #e2e8f0;
}

.question-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 25px;
    color: #2d3748;
    line-height: 1.5;
}

.options {
    display: grid;
    gap: 15px;
}

/* =============================================
   SYSTÈME D'OPTIONS DE QUIZ OPTIMISÉ
   ============================================= */
.option {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-white);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--text-base);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-height: 48px;
    touch-action: manipulation;
}

.option:hover {
    border-color: var(--accent-color);
    background: var(--bg-accent);
    transform: translateY(-1px);
}

.option.selected {
    background: var(--accent-color);
    color: var(--bg-white);
    border-color: var(--accent-color);
}

.option-letter {
    background: var(--text-secondary);
    color: var(--bg-white);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: var(--text-base);
    flex-shrink: 0;
}

.option.selected .option-letter {
    background: var(--bg-white);
    color: var(--accent-color);
}

.option:active {
    transform: scale(0.98);
    transition: transform var(--transition-fast);
}

.quiz-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.results-container {
    display: none;
    text-align: center;
}

.score-display {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.score-text {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 10px;
}

.score-percentage {
    font-size: 24px;
    opacity: 0.9;
}

.results-details {
    background: #f7fafc;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 18px;
}

.result-item:last-child {
    border-bottom: none;
}

.correct {
    color: #38a169;
    font-weight: 600;
}

.incorrect {
    color: #e53e3e;
    font-weight: 600;
}

/* Bulle d'info pour les tooltips */
.tooltip-info {
    display: flex;
    align-items: center;
    background: rgba(66, 153, 225, 0.1);
    border: 1px solid rgba(66, 153, 225, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 20px;
    font-size: 14px;
}

.info-icon {
    font-size: 18px;
    margin-right: 10px;
    flex-shrink: 0;
}

.info-text {
    color: #2c5282;
    line-height: 1.4;
}

.loading {
    text-align: center;
    padding: 40px;
    font-size: 18px;
    color: #4a5568;
}

.footer {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    font-size: 14px;
    color: #718096;
    border-top: 1px solid #e2e8f0;
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.progress-bar {
    background: #e2e8f0;
    height: 8px;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ========================================
   MOBILE RESPONSIVE DESIGN - PRINCIPAL
   ======================================== */

/* Media queries pour très petits écrans (< 480px) */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 10px;
        border-radius: 10px;
        min-height: calc(100vh - 10px);
    }
    
    .header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    
    .header h1 {
        font-size: 1.3em;
        line-height: 1.1;
        margin-bottom: 0;
    }
    
    .theme-selector {
        top: -15px;
        right: -5px;
    }
    
    .theme-selector span {
        font-size: 16px;
        padding: 3px;
    }
    
    .setup-form {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .form-group {
        gap: 6px;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    .form-group select,
    .form-group input {
        padding: 8px;
        font-size: 15px;
        border-radius: 6px;
    }
    
    .checkbox-label,
    .radio-label {
        padding: 8px;
        font-size: 12px;
        border-radius: 6px;
    }
    
    .form-actions {
        gap: 10px;
        margin-top: 15px;
    }
    
    .form-actions .btn {
        padding: 12px;
        font-size: 15px;
    }
    
    .question-header {
        padding: 12px;
        margin-bottom: 12px;
        gap: 8px;
    }
    
    .question-info {
        font-size: 14px;
    }
    
    .timer {
        font-size: 18px;
        padding: 6px 12px;
    }
    
    .question-card {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .question-text {
        font-size: 15px;
        margin-bottom: 15px;
        line-height: 1.3;
    }
    
    .options {
        gap: 8px;
    }
    
    .option {
        padding: 8px 10px;
        font-size: 13px;
        min-height: 42px;
        border-radius: 6px;
        gap: 10px;
    }
    
    .option-letter {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }
    
    .quiz-controls {
        gap: 8px;
        margin-top: 15px;
    }
    
    .quiz-controls .btn {
        padding: 10px 15px;
        font-size: 13px;
        min-width: 100px;
    }
    
    .keyboard-hints {
        margin-top: 8px;
        font-size: 11px;
        padding: 6px;
    }
    
    .footer {
        margin-top: 10px;
        padding: 8px;
        font-size: 11px;
    }
}


.keyboard-hints {
    text-align: center;
    margin-top: 15px;
    color: #718096;
    font-size: 13px;
}

kbd {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 12px;
    margin: 0 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.btn small {
    opacity: 0.7;
    font-weight: normal;
}

.timer-mode {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.timer-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.timer-input-group input[type="number"] {
    flex: 1;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
    transition: border-color 0.3s;
}

.timer-input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.timer-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    background: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.timer-btn:active {
    transform: scale(0.95);
}

.timer-help {
    color: #718096;
    font-size: 12px;
    text-align: center;
    display: block;
}

/* Styles pour l'écran des consignes d'examen */
.exam-instructions-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.instructions-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.instructions-card h2 {
    color: #2d3748;
    margin-bottom: 30px;
    font-size: 24px;
    font-weight: 700;
}

.instructions-content {
    text-align: left;
    margin-bottom: 30px;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 12px;
    border-left: 4px solid #7c3aed;
}

.instruction-icon {
    font-size: 24px;
    margin-right: 15px;
    flex-shrink: 0;
}

.instruction-item strong {
    display: block;
    color: #2d3748;
    font-weight: 600;
    margin-bottom: 4px;
}

.instruction-item small {
    color: #718096;
    font-size: 14px;
}

.instructions-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.instructions-actions .btn {
    min-width: 150px;
}


/* =============================================
   SYSTÈME DE MODAUX OPTIMISÉ
   ============================================= */
.exam-mode-selection-container,
.exam-code-container,
.student-info-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-start) 0%, var(--primary-end) 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.mode-selection-card,
.code-entry-card,
.student-info-card {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-2xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-2xl);
    text-align: center;
}

.modal-card h2 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    font-size: var(--text-2xl);
    font-weight: 700;
}

.modal-card p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-xl);
}

/* Boutons de sélection mode */
.mode-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.mode-btn {
    flex: 1;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.mode-btn:hover {
    border-color: #7c3aed;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(124, 58, 237, 0.15);
}

.mode-btn.selected {
    border-color: #7c3aed;
    background: #f3f0ff;
}

.mode-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.mode-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 14px;
    color: #718096;
}

/* Saisie du code d'examen */
.code-input-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.code-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
}

.code-input-group input:focus {
    outline: none;
    border-color: #7c3aed;
}

.error-message {
    color: #e53e3e;
    background: #fed7d7;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Formulaire élève */
.student-form {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.student-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.student-form label {
    font-weight: 600;
    color: #2d3748;
}

.student-form input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
}

.student-form input:focus {
    outline: none;
    border-color: #7c3aed;
}

.student-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}


/* Contrôles de navigation pour le mode élève */
.student-quiz-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.student-question-counter {
    font-weight: 600;
    color: #4a5568;
    font-size: 16px;
    flex: 1;
    text-align: center;
}

.student-quiz-controls .btn {
    min-width: 120px;
}

.student-quiz-controls .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e2e8f0;
    color: #a0aec0;
}

.student-quiz-controls .btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    font-weight: 600;
}

.student-quiz-controls .btn-success:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-2px);
}


/* Modal de confirmation de rendu de copie */
.submit-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.submit-modal-card {
    background: white;
    border-radius: 20px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.submit-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
}

.submit-modal-icon {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.submit-modal-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.submit-modal-content {
    padding: 30px;
    text-align: center;
}

.submit-modal-content p {
    font-size: 18px;
    color: #2d3748;
    margin-bottom: 20px;
}

.submit-warning {
    display: flex;
    align-items: center;
    background: #fed7d7;
    border: 1px solid #fc8181;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 25px;
    gap: 12px;
}

.warning-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.warning-text {
    color: #c53030;
    font-weight: 600;
    text-align: left;
}

.submit-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: 800;
    color: #2d3748;
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #718096;
    font-weight: 600;
}

.stat-divider {
    width: 2px;
    height: 40px;
    background: #e2e8f0;
    border-radius: 1px;
}

.submit-modal-actions {
    display: flex;
    gap: 15px;
    padding: 0 30px 30px 30px;
}

.submit-modal-actions .btn {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-modal-actions .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.submit-modal-actions .btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

.submit-modal-actions .btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.submit-modal-actions .btn-success:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.3);
}


.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.form-actions .btn {
    flex: 1;
    min-width: 200px;
}

/* Mode examen discret dans le header */
.exam-access {
    font-size: 20px;
    margin-left: 10px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.exam-access:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* ========================================
   MOBILE RESPONSIVE DESIGN - CONSOLIDÉ
   ======================================== */

/* =============================================
   RESPONSIVE DESIGN MOBILE-FIRST
   ============================================= */

/* Force les éléments cachés à rester cachés même sur mobile */
.quiz-container[style*="display: none"],
.results-container[style*="display: none"],
.exam-instructions-container[style*="display: none"],
.exam-mode-selection-container[style*="display: none"],
.exam-code-container[style*="display: none"],
.student-info-container[style*="display: none"],
.submit-modal-overlay[style*="display: none"] {
    display: none !important;
}

/* MOBILE PRINCIPAL - 768px et moins */
@media (max-width: 768px) {
    /* Layout de base mobile */
    body {
        padding: 10px;
        align-items: flex-start;
        min-height: 100vh;
    }
    
    .container {
        padding: 15px;
        width: 100%;
        max-width: 100%;
        border-radius: 15px;
        margin: 0;
        max-height: none;
        min-height: calc(100vh - 20px);
        display: flex;
        flex-direction: column;
    }
    
    /* Header mobile */
    .header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .theme-selector {
        top: -20px;
        right: -5px;
    }
    
    .theme-selector span {
        font-size: 20px;
        padding: 6px;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }
    
    .exam-access {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .header h1 {
        font-size: 1.6em;
        line-height: 1.2;
        margin-bottom: 5px;
    }
    
    /* Formulaires mobile */
    .setup-form {
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .form-group select,
    .form-group input {
        padding: 10px;
        font-size: 16px !important;
        border-radius: 8px;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .checkbox-label {
        padding: 12px;
        font-size: 14px;
    }
    
    .difficulty-mode {
        flex-direction: column;
        gap: 8px;
    }

    .timer-mode {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .radio-label {
        padding: 12px;
        font-size: 14px;
        justify-content: flex-start;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 20px;
    }
    
    .form-actions .btn {
        width: 100%;
        min-width: auto;
        padding: 14px;
        font-size: 16px;
    }
    
    /* Interface de quiz mobile */
    .question-header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .question-info {
        font-size: 16px;
        order: 2;
    }
    
    .timer {
        font-size: 20px;
        padding: 8px 16px;
        order: 1;
        align-self: center;
    }
    
    .question-card {
        padding: 20px;
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .question-text {
        font-size: 17px;
        margin-bottom: 20px;
        line-height: 1.4;
    }
    
    .options {
        gap: 10px;
    }
    
    .option {
        padding: 12px 15px;
        font-size: 15px;
        border-radius: 8px;
        min-height: 48px;
        align-items: center;
        touch-action: manipulation;
    }
    
    .option-letter {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    /* Boutons et contrôles */
    .btn {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .quiz-controls {
        gap: 10px;
        margin-top: 20px;
        flex-wrap: wrap;
    }
    
    .quiz-controls .btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Hints et résultats */
    .keyboard-hints {
        margin-top: 10px;
        font-size: 12px;
        padding: 8px;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 6px;
    }
    
    kbd {
        padding: 1px 4px;
        font-size: 11px;
    }
    
    .results-container.active {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .score-display {
        padding: 25px;
        border-radius: 15px;
        margin-bottom: 20px;
    }
    
    .score-text {
        font-size: 36px;
    }
    
    .score-percentage {
        font-size: 20px;
    }
    
    .results-details {
        padding: 20px;
        border-radius: 12px;
        margin-bottom: 15px;
        flex: 1;
    }
    
    .result-item {
        padding: 12px 0;
        font-size: 16px;
    }
    
    .footer {
        margin-top: 15px;
        padding: 10px;
        font-size: 12px;
    }
    
    /* Effets tactiles et accessibilité */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    input[type="text"],
    input[type="number"],
    select {
        font-size: 16px !important;
    }
    
    .option:active,
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* ===== MODAUX ET ÉCRANS SPÉCIAUX MOBILE ===== */
    
    /* Instructions d'examen */
    .exam-instructions-container:not([style*="display: none"]) {
        padding: 10px;
    }
    
    .instructions-card {
        padding: 20px;
        margin: 0;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .instructions-card h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .instruction-item {
        flex-direction: row;
        text-align: left;
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .instruction-icon {
        margin-right: 12px;
        margin-bottom: 0;
        font-size: 20px;
    }
    
    .instruction-item strong {
        font-size: 14px;
    }
    
    .instruction-item small {
        font-size: 12px;
    }
    
    .instructions-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 20px;
    }
    
    .instructions-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }
    
    /* Sélection mode et codes */
    .exam-mode-selection-container:not([style*="display: none"]),
    .exam-code-container:not([style*="display: none"]),
    .student-info-container:not([style*="display: none"]) {
        padding: 10px;
    }
    
    .mode-selection-card,
    .code-entry-card,
    .student-info-card {
        padding: 20px;
        margin: 0;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .mode-selection-card h2,
    .code-entry-card h2,
    .student-info-card h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .mode-selection-card p,
    .code-entry-card p,
    .student-info-card p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .mode-buttons {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .mode-btn {
        padding: 15px;
        width: 100%;
    }
    
    .mode-icon {
        font-size: 28px;
        margin-bottom: 8px;
    }
    
    .mode-title {
        font-size: 15px;
    }
    
    .mode-desc {
        font-size: 13px;
    }
    
    .code-input-group {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .code-input-group input {
        padding: 12px;
        font-size: 16px;
    }
    
    .code-input-group .btn {
        width: 100%;
        padding: 12px;
    }
    
    .student-form {
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .student-form input {
        padding: 12px;
        font-size: 16px;
    }
    
    .student-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .student-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }
    
    .error-message {
        font-size: 13px;
        padding: 8px;
        margin-bottom: 15px;
    }
    
    /* Contrôles mode élève */
    .student-quiz-controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
        margin-top: 15px;
    }
    
    .student-question-counter {
        order: 0;
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
        font-size: 14px;
    }
    
    .student-quiz-controls .btn {
        flex: 1;
        min-width: 120px;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .student-quiz-controls .btn-success {
        width: 100%;
        order: 3;
        margin-top: 5px;
    }
    
    /* Modal de confirmation */
    .submit-modal-overlay:not([style*="display: none"]) {
        padding: 10px;
    }
    
    .submit-modal-card {
        margin: 0;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .submit-modal-header {
        padding: 20px;
    }
    
    .submit-modal-icon {
        font-size: 36px;
        margin-bottom: 8px;
    }
    
    .submit-modal-header h3 {
        font-size: 18px;
    }
    
    .submit-modal-content {
        padding: 20px;
    }
    
    .submit-modal-content p {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .submit-warning {
        padding: 12px;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .warning-icon {
        font-size: 20px;
    }
    
    .warning-text {
        font-size: 14px;
    }
    
    .submit-stats {
        flex-direction: row;
        gap: 15px;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-divider {
        width: 2px;
        height: 30px;
    }
    
    .submit-modal-actions {
        flex-direction: column;
        gap: 12px;
        padding: 0 20px 20px 20px;
    }
    
    .submit-modal-actions .btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }
}

/* Interface compacte pour écrans courts */
@media (max-width: 768px) and (max-height: 800px) {
    .container {
        min-height: calc(100vh - 20px);
        display: flex;
        flex-direction: column;
    }
    
    .quiz-container.active {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .question-content {
        flex: 1;
    }
    
    .quiz-controls,
    .student-quiz-controls {
        margin-top: auto;
        padding: 15px;
        border-top: 1px solid #e2e8f0;
        background: rgba(255, 255, 255, 0.95);
        position: sticky;
        bottom: 0;
        margin-left: -15px;
        margin-right: -15px;
        backdrop-filter: blur(10px);
    }
    
    .keyboard-hints {
        display: none;
    }
}

/* Très petits écrans - ultra compact */
@media (max-width: 480px) and (max-height: 667px) {
    .header h1 {
        font-size: 1.2em;
    }
    
    .question-text {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .option {
        padding: 6px 8px;
        font-size: 12px;
        min-height: 40px;
    }
    
    .option-letter {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    
    .timer {
        font-size: 16px;
        padding: 4px 10px;
    }
    
    .quiz-controls .btn,
    .student-quiz-controls .btn {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 90px;
    }
    
    .question-header {
        padding: 10px;
    }
    
    .question-card {
        padding: 10px;
    }
}

