/* ============================================
   DASHBOARD - CSS CENTRALISÉ
   MathsEtMoi — v2
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
}

/* ============================================
   LOADING
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-size: 18px;
    color: #666;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 22px;
    color: #333;
    line-height: 1;
}

.header-subtitle {
    display: block;
    font-size: 13px;
    color: #888;
    margin-top: 3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info { text-align: right; }
.user-name  { font-weight: 600; color: #333; font-size: 15px; }
.user-email { font-size: 13px; color: #888; }

.btn-logout {
    padding: 9px 18px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s, transform 0.15s;
}
.btn-logout:hover { background: #c82333; transform: translateY(-1px); }

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px 24px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon  { font-size: 32px; }
.stat-value { font-size: 28px; font-weight: 700; color: #333; line-height: 1; }
.stat-label { font-size: 13px; color: #888; margin-top: 3px; }

/* ============================================
   LAYOUT 2 COLONNES
   ============================================ */
.two-col-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
}

/* ============================================
   SECTION
   ============================================ */
.section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

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

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #f0f0f0;
}

.section-header .section-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* ============================================
   CLASSES LIST
   ============================================ */
.class-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid #f0f0f0;
    margin-bottom: 8px;
}

.class-row:hover { background: #f8f9ff; border-color: #667eea44; }

.class-row-left  { display: flex; align-items: center; gap: 12px; }
.class-row-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #666; }

.class-name  { font-weight: 600; color: #333; }
.class-stat  { font-size: 13px; color: #666; }
.class-arrow { color: #aaa; font-size: 18px; margin-left: 4px; }

.class-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    color: white;
}
.class-badge.level-6 { background: #28a745; }
.class-badge.level-5 { background: #667eea; }
.class-badge.level-4 { background: #fd7e14; }
.class-badge.level-3 { background: #dc3545; }

/* ============================================
   CONSENT BADGES
   ============================================ */
.consent-badge {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}
.consent-badge.pending  { background: #fff3cd; color: #856404; }
.consent-badge.ok       { background: #d4edda; color: #155724; }
.consent-badge.refused  { background: #f8d7da; color: #721c24; }

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: #f5f7fa;
    padding: 4px;
    border-radius: 8px;
}

.tab {
    flex: 1;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.tab.active {
    background: white;
    color: #333;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================
   DROP ZONE CSV
   ============================================ */
.csv-format-info {
    background: #f8f9ff;
    border: 1px solid #e0e4ff;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13px;
    color: #555;
    margin-bottom: 14px;
    line-height: 1.8;
}

.csv-format-info code {
    background: #eef0ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #444d9e;
}

.link-small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #667eea;
    text-decoration: none;
}
.link-small:hover { text-decoration: underline; }

.drop-zone {
    border: 2px dashed #c5c8e8;
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbff;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #667eea;
    background: #f0f2ff;
}

.drop-icon { font-size: 36px; margin-bottom: 10px; }

.drop-text {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.drop-text span { font-size: 13px; color: #999; }

/* ============================================
   PREVIEW TABLE
   ============================================ */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
}

.table-scroll { overflow-x: auto; }

.preview-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th,
.data-table th {
    background: #f5f7fa;
    padding: 9px 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

.preview-table td,
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

.preview-table tr.row-error td { background: #fff5f5; }
.preview-table tr:hover td,
.data-table tr:hover td { background: #fafbff; }

/* ============================================
   FORMULAIRE
   ============================================ */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}

.form-group small {
    font-size: 12px;
    color: #999;
    display: block;
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.required { color: #dc3545; }

.btn-full {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

/* ============================================
   BOUTONS
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
    background: #f0f0f0;
    color: #555;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #e0e0e0; }

.btn-success {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-success:hover { background: #218838; }

.btn-sm {
    padding: 7px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.15s;
    color: #999;
}
.btn-icon:hover { background: #f5f5f5; color: #dc3545; }

/* ============================================
   RACCOURCIS
   ============================================ */
.shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #f8f9ff;
    border-radius: 8px;
    text-decoration: none;
    color: #444;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid #e8ebff;
}

.shortcut-item:hover {
    background: #eef0ff;
    color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102,126,234,0.15);
}

.shortcut-icon { font-size: 20px; }

/* ============================================
   MESSAGES
   ============================================ */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.5;
}

.message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.message.error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.message.info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.message.warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

.error-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    font-size: 13px;
    color: #721c24;
}
.error-list li { padding: 3px 0; }

.text-muted  { color: #999; font-size: 14px; }
.text-error  { color: #dc3545; font-size: 14px; }

/* ============================================
   MODALE
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-box {
    background: white;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-large { max-width: 750px; }

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

.modal-header h3 { font-size: 18px; color: #333; }

.modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #aaa;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}
.modal-close:hover { background: #f5f5f5; color: #555; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ============================================
   TOAST
   ============================================ */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    display: none;
    animation: slideIn 0.25s ease;
}

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

.toast-success { background: #28a745; color: white; }
.toast-error   { background: #dc3545; color: white; }
.toast-info    { background: #667eea; color: white; }
.toast-warning { background: #fd7e14; color: white; }

/* ============================================
   ACTIVITÉ RÉCENTE
   ============================================ */
.activity-list { list-style: none; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}
.activity-item:last-child { border-bottom: none; }
.activity-time { font-size: 12px; color: #aaa; white-space: nowrap; margin-left: auto; }

/* ============================================
   VALIDATION ÉLÈVE (modale)
   ============================================ */
.sv-status {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #6c757d;
}
.sv-status-label { font-weight: 700; font-size: 14px; }
.sv-status-sub   { font-size: 12px; color: #888; }

.sv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.sv-info-block {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px 12px;
}
.sv-info-label { font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.sv-info-value { font-size: 13px; color: #333; word-break: break-all; }

.sv-section {
    margin-top: 14px;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid #eee;
}
.sv-section-title { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 8px; }
.sv-section-blue   { background: #f0f4ff; border-color: #d0d8ff; }
.sv-section-orange { background: #fff8f0; border-color: #ffe0b2; }

.sv-email-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    transition: border-color 0.2s;
}
.sv-email-input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.12); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 960px) {
    .two-col-layout {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    .header-right {
        flex-direction: column;
        width: 100%;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 16px 12px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .shortcuts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Modale validation élève au-dessus de modalClassDetail */
#modalStudentValidation {
    z-index: 1100;
}