/* ============================================
   DASHBOARD-ELEVE.CSS — VERSION PROPRE
   Pas de code JS, pas de doublons, encodage UTF-8
   ============================================ */

/* ============================================
   RESET & BASE
   ============================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ============================================
   CONTAINER PRINCIPAL
   ============================================ */

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

/* ============================================
   HEADER
   ============================================ */

.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ============================================
   AVATAR CLIQUABLE
   ============================================ */

.avatar-container {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.avatar-container:hover {
    transform: scale(1.05);
}

.avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2em;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    border: 3px solid #f0f0f0;
}

.edit-hint {
    font-size: 12px;
    color: #888;
    font-weight: 600;
}

/* ============================================
   INFOS UTILISATEUR
   ============================================ */

.user-details h1 {
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 6px;
}

.user-details p {
    color: #6c757d;
    font-size: 1em;
}

/* ============================================
   BOUTONS HEADER
   ============================================ */

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* ============================================
   STATS HEADER (3 cartes dans le header)
   ============================================ */

.stats-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.stats-summary .stat-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    text-align: center;
    min-width: 130px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.stats-summary .stat-value {
    font-size: 28px;
    font-weight: 700;
    display: block;
}

.stats-summary .stat-label {
    font-size: 12px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ============================================
   LOADING
   ============================================ */

.loading {
    text-align: center;
    padding: 60px 40px;
    color: white;
    font-size: 1.1em;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* ============================================
   STATS RAPIDES (4 cartes)
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Cartes des stats rapides — fond blanc */
.stats-grid .stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
    transition: all 0.3s ease;
    color: inherit;
}

.stats-grid .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.stat-icon {
    font-size: 2.5em;
    margin-bottom: 12px;
}

.stat-number {
    font-size: 2.2em;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 6px;
}

.stats-grid .stat-label {
    color: #6c757d;
    font-size: 0.9em;
}

/* ============================================
   TITRES DE SECTIONS
   ============================================ */

.section-title {
    color: white;
    font-size: 1.6em;
    font-weight: 700;
    margin: 30px 0 16px 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ============================================
   GRILLE OUTILS
   ============================================ */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.tool-card {
    background: white;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
}

.tool-icon {
    font-size: 3em;
    margin-bottom: 16px;
    text-align: center;
}

.tool-title {
    font-size: 1.3em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
}

.tool-description {
    color: #6c757d;
    line-height: 1.5;
    margin-bottom: 14px;
    font-size: 0.95em;
}

.tool-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
}

/* ============================================
   FILTRES CHAPITRES
   ============================================ */

.filters-bar {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.3);
}

.filters-label {
    font-weight: 700;
    color: white;
    font-size: 0.95em;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.35);
    border-color: white;
}

.filter-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
}

/* ============================================
   GRILLE CHAPITRES — 2-3 COLONNES
   ============================================ */

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1100px) {
    .chapters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 680px) {
    .chapters-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   CARTE CHAPITRE
   ============================================ */

.chapter-card {
    background: white;
    border: 2px solid #e8e8e8;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.chapter-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.14);
    border-color: #667eea;
}

/* Header carte */
.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
    gap: 8px;
}

.chapter-title {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    flex: 1;
}

.chapter-number {
    font-size: 13px;
    color: #888;
    font-weight: 600;
    background: #f5f5f5;
    padding: 3px 10px;
    border-radius: 16px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Barre de progression */
.chapter-progress {
    margin: 12px 0;
}

.progress-bar-container {
    width: 100%;
    height: 10px;
    background: #eeeeee;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}

.progress-text {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
}

/* Liste items dans la carte */
.chapter-items-list {
    margin-top: 14px;
}

.item-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    margin: 5px 0;
    background: #f8f8f8;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    gap: 8px;
}

.item-label {
    flex: 1;
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

.item-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.status-not-started  { background: #ffeaea; color: #c62828; }
.status-learning     { background: #fff3e0; color: #e65100; }
.status-acquired     { background: #e8f5e9; color: #2e7d32; }
.status-mastered     { background: #e3f2fd; color: #1565c0; }

/* Boutons carte */
.chapter-actions {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.chapter-btn {
    flex: 1;
    padding: 8px 6px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-automatismes { background: #fff3cd; color: #856404; }
.btn-automatismes:hover { background: #ffd600; }
.btn-quiz { background: #e3f2fd; color: #1565c0; }
.btn-quiz:hover { background: #1976d2; color: white; }
.btn-flashcards { background: #e8f5e9; color: #2e7d32; }
.btn-flashcards:hover { background: #43a047; color: white; }

/* Mini stats sous la barre */
.chapter-mini-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.mini-stat {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    background: #f5f5f5;
    padding: 3px 10px;
    border-radius: 10px;
}

/* ============================================
   SECTION PROGRESSION DETAILLEE
   ============================================ */

.progress-section {
    background: white;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.progress-title {
    font-size: 1.3em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
}

.progress-subtitle {
    color: #6c757d;
    font-size: 0.95em;
    margin-bottom: 20px;
}

/* Accordion chapitres */
.chapter-accordion {
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

.chapter-summary {
    padding: 14px 18px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #2c3e50;
    list-style: none;
    gap: 12px;
}

.chapter-summary::-webkit-details-marker { display: none; }

.chapter-summary:hover {
    filter: brightness(0.97);
}

.chapter-stats-inline {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

/* Items dans accordion */
.items-list {
    border-top: 1px solid #e8e8e8;
}

.item-card {
    padding: 12px 18px;
    border-bottom: 1px solid #f0f0f0;
    background: white;
}

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

.item-card:hover {
    background: #fafafa;
}

.item-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 6px;
}

/* Indicateurs couleur chapitres */
.chapter-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.color-gray   { background: #9e9e9e; }
.color-red    { background: #e53935; }
.color-orange { background: #fb8c00; }
.color-yellow { background: #fdd835; }
.color-green  { background: #43a047; }

/* Badges items */
.item-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.badge.auto  { background: #667eea; }
.badge.flash { background: #43a047; }

/* Niveaux de maitrise */
.item-mastery { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.mastery-none      { color: #9e9e9e; }
.mastery-progress  { color: #fb8c00; }
.mastery-good      { color: #43a047; }
.mastery-excellent { color: #1565c0; }

.item-last-practice {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
}

/* ============================================
   MODALE PROFIL
   ============================================ */

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* display:flex quand ouverte — géré via JS */

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
    font-size: 1.4em;
    color: #2c3e50;
}

.close-btn {
    background: #e74c3c;
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #c0392b;
    transform: rotate(90deg);
}

/* Formulaire profil */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 7px;
    color: #2c3e50;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn-primary {
    flex: 1;
    padding: 13px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.form-actions .btn-secondary {
    flex: 1;
    padding: 13px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-actions .btn-secondary:hover {
    background: #bdbdbd;
}

/* ============================================
   RESPONSIVE GLOBAL
   ============================================ */

@media (max-width: 768px) {
    body { padding: 10px; }

    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }

    .header-actions {
        width: 100%;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .stats-summary {
        width: 100%;
        justify-content: center;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .chapter-actions {
        flex-direction: column;
    }

    .chapter-summary {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

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

#first-login-banner h3 {
    color: white !important;
}

.btn-game {
    display: inline-block;
    padding: 10px 22px;
    background: linear-gradient(135deg, #14508a, #2e7fc2);
    color: #fff;
    border-radius: 24px;
    text-decoration: none;
    font-weight: 600;
}
.btn-game:hover { opacity: 0.9; }