/* ========================================
   Variables et Reset
   ======================================== */
:root {
    /* Couleurs principales - Palette ludique */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #22c55e;
    --secondary-dark: #16a34a;
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;

    /* Couleurs de notes (Orange, Jaune, Vert clair, Vert foncé) */
    --note-1: #f97316;
    --note-2: #eab308;
    --note-3: #84cc16;
    --note-4: #22c55e;

    /* Couleurs neutres */
    --bg-primary: #faf5ff;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1e1b4b;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: rgba(99, 102, 241, 0.1);

    /* Espacements */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Bordures */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #e0e7ff 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   Header
   ======================================== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
    color: white;
    padding: var(--spacing-lg);
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Main Container
   ======================================== */
.main-container {
    padding: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   Actions Bar
   ======================================== */
.actions-bar {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.1rem;
    font-weight: 700;
}

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

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--accent-purple) 100%);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--accent-cyan) 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--accent-cyan) 100%);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

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

.btn-cancel:hover {
    background: var(--border);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8rem;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* ========================================
   Table Wrapper
   ======================================== */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px var(--shadow);
    -webkit-overflow-scrolling: touch;
}

.grades-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.grades-table th,
.grades-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.grades-table th {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.grades-table th:first-child {
    text-align: left;
    border-radius: var(--radius-lg) 0 0 0;
}

.grades-table th:last-child {
    border-radius: 0 var(--radius-lg) 0 0;
}

.col-student {
    min-width: 150px;
    text-align: left !important;
}

.col-category {
    min-width: 100px;
}

.col-total {
    min-width: 80px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
}

.col-actions {
    min-width: 120px;
}

.grades-table tbody tr:hover {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.grades-table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 var(--radius-lg);
}

.grades-table tbody tr:last-child td:last-child {
    border-radius: 0 0 var(--radius-lg) 0;
}

/* Nom de l'eleve */
.student-name {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 600;
}

.student-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}

/* Couleurs d'avatars */
.avatar-1 { background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%); }
.avatar-2 { background: linear-gradient(135deg, var(--secondary) 0%, var(--accent-cyan) 100%); }
.avatar-3 { background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-pink) 100%); }
.avatar-4 { background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%); }
.avatar-5 { background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--primary) 100%); }

/* Select de notes */
.grade-select {
    width: 70px;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.grade-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.grade-select.grade-1 { border-color: var(--note-1); background-color: #fff7ed; color: var(--note-1); }
.grade-select.grade-2 { border-color: var(--note-2); background-color: #fefce8; color: var(--note-2); }
.grade-select.grade-3 { border-color: var(--note-3); background-color: #ecfccb; color: #3f6212; }
.grade-select.grade-4 { border-color: var(--note-4); background-color: #f0fdf4; color: var(--note-4); }

/* Cellule de notes multiples */
.grades-cell {
    min-width: 160px;
    max-width: 220px;
}

.grades-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.grade-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: filter 0.2s;
}

.grade-chip:hover {
    filter: brightness(1.1);
}

.grade-chip.grade-1 { background: var(--note-1); }
.grade-chip.grade-2 { background: var(--note-2); }
.grade-chip.grade-3 { background: var(--note-3); color: #166534; }
.grade-chip.grade-4 { background: var(--note-4); }

.grade-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 2px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.grade-remove:hover {
    opacity: 1;
}

/* Boutons rapides pour ajouter une note */
.grade-buttons {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 4px;
    flex-wrap: wrap;
}

.grade-btn {
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.7;
}

.grade-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Classes de fallback si style inline non applique */
.grade-btn-1 { background: var(--note-1); color: white; }
.grade-btn-2 { background: var(--note-2); color: white; }
.grade-btn-3 { background: var(--note-3); color: #166534; }
.grade-btn-4 { background: var(--note-4); color: white; }

/* Menu deroulant pour baremes > 6 */
.grade-dropdown {
    padding: 4px 8px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grade-dropdown:hover {
    background: var(--primary);
    color: white;
}

.grade-dropdown:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.category-average {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.category-average.average-low { background: #fff7ed; color: var(--note-1); }
.category-average.average-medium-low { background: #fefce8; color: var(--note-2); }
.category-average.average-medium { background: #ecfccb; color: #3f6212; }
.category-average.average-high { background: #f0fdf4; color: var(--note-4); }
.category-average.average-libre { background: #eef2ff; color: var(--primary); }
.category-average.average-none { background: var(--border); color: var(--text-secondary); }

/* Moyenne */
.average-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.95rem;
}

.average-low { background: var(--note-1); color: white; }
.average-medium-low { background: var(--note-2); color: white; }
.average-medium { background: var(--note-3); color: #166534; }
.average-high { background: var(--note-4); color: white; }
.average-libre { background: var(--primary); color: white; }
.average-none { background: var(--border); color: var(--text-secondary); }

/* Actions */
.actions-cell {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    flex-wrap: wrap;
}

.btn-share {
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--primary) 100%);
    color: white;
}

.btn-delete {
    background: #fee2e2;
    color: var(--note-1);
}

.btn-delete:hover {
    background: #fecaca;
}

/* Header de categorie */
.category-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.category-drag-handle {
    cursor: grab;
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: -2px;
    opacity: 0.4;
    transition: opacity 0.2s;
    user-select: none;
}

.category-drag-handle:hover {
    opacity: 1;
}

.category-drag-handle:active {
    cursor: grabbing;
}

th[draggable="true"] {
    cursor: default;
    transition: background 0.2s, transform 0.2s;
}

th[draggable="true"].dragging {
    opacity: 0.5;
    background: var(--primary-light);
}

th[draggable="true"].drag-over {
    background: #e0e7ff;
    transform: scale(1.02);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.category-scale {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--border);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.category-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.category-action-btn {
    background: var(--border);
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.category-action-btn:hover {
    background: #e5e7eb;
    transform: scale(1.1);
}

.category-delete-btn:hover {
    background: #fee2e2;
}

.category-add-sub-btn:hover {
    background: #dcfce7;
}

/* Sous-categories */
.col-subcategory {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 2px dashed var(--border);
}

.subcategory-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.subcategory-info {
    text-align: center;
}

.subcategory-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.subcategory-parent {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

.subcategory-cell {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

/* Input pour notes > 20 */
.grade-input-group {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.grade-input {
    width: 50px;
    padding: 4px 6px;
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.grade-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.grade-input-btn {
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.grade-input-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
    display: none;
}

.empty-state.visible {
    display: block;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.empty-hint {
    font-size: 0.9rem;
    margin-top: var(--spacing-sm);
}

/* ========================================
   Modals
   ======================================== */
.modal {
    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;
    padding: var(--spacing-md);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
}

/* Scrollbar pour les modals */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: var(--radius-full);
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}

.modal-small {
    max-width: 320px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--border);
    border-radius: var(--radius-full);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--text-secondary);
    color: white;
}

.modal-content form,
.modal-content > p {
    padding: var(--spacing-lg);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    padding: var(--spacing-lg);
    padding-top: 0;
}

/* Textarea pour messages */
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    transition: all 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Apercu du message */
.message-preview {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius-md);
    border-left: 4px solid #f59e0b;
}

.message-preview .preview-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: var(--spacing-xs);
}

.message-preview .preview-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* ========================================
   Export PDF - Sélection matières
   ======================================== */
.export-categories-selection {
    padding: var(--spacing-md) var(--spacing-lg);
}

.selection-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.select-all-row {
    padding: var(--spacing-sm);
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
}

.categories-checkbox-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.checkbox-label:hover {
    background: var(--bg-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.95rem;
}

.category-checkbox-item {
    border-bottom: 1px solid var(--border);
}

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

/* ========================================
   Toast Notification
   ======================================== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-full);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--secondary);
}

.toast.error {
    background: var(--note-1);
}

/* ========================================
   Authentification
   ======================================== */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: var(--spacing-xl);
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px var(--shadow);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.auth-switch {
    text-align: center;
    margin-top: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-error {
    background: #fff7ed;
    border: 1px solid var(--note-1);
    color: var(--note-1);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-md);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* Barre utilisateur dans le header */
.user-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.user-email {
    font-size: 0.9rem;
    opacity: 0.9;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Bouton Export */
.btn-export {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
}

.btn-export:hover {
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Modal Export */
.export-options {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
}

.btn-export-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-export-option:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    transform: translateY(-2px);
}

.export-icon {
    font-size: 2rem;
}

.export-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.export-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ========================================
   Responsive - Tablet
   ======================================== */
@media (min-width: 768px) {
    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .header h1 {
        font-size: 2rem;
    }

    .user-bar {
        margin-top: 0;
    }

    .main-container {
        padding: var(--spacing-xl);
    }

    .btn {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: 1rem;
    }

    .grades-table th,
    .grades-table td {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .student-avatar {
        width: 40px;
        height: 40px;
    }
}

/* ========================================
   Responsive - Desktop
   ======================================== */
@media (min-width: 1024px) {
    .header {
        padding: var(--spacing-xl);
    }

    .header h1 {
        font-size: 2.5rem;
    }

    .actions-bar {
        gap: var(--spacing-md);
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.grades-table tbody tr {
    animation: fadeIn 0.3s ease;
}

/* ========================================
   Scrollbar personnalisee
   ======================================== */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: var(--radius-full);
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent-purple) 100%);
    border-radius: var(--radius-full);
}

/* ========================================
   Bouton Parametres
   ======================================== */
.btn-settings {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
}

.btn-settings:hover {
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

/* ========================================
   Modal Parametres
   ======================================== */
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.toggle-text {
    font-weight: 600;
}

.legend-config {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.legend-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.legend-field {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.legend-field:last-child {
    margin-bottom: 0;
}

.legend-number {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.legend-range-badge {
    min-width: 50px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
    flex-shrink: 0;
}

.legend-field input {
    flex: 1;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

.legend-field input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Legende affichee */
.legend-display {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-badge {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
}

/* ========================================
   Sous-categories - Layout Vertical
   ======================================== */
.subcategory-count {
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    margin-left: 4px;
}

.grades-cell-vertical {
    min-width: 180px;
    padding: var(--spacing-sm) !important;
}

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

.subcategory-row-vertical {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    border-left: 3px solid var(--primary);
    transition: all 0.2s ease;
}

.subcategory-row-vertical:hover {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-left-color: var(--primary-dark);
}

.subcategory-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px dashed var(--border);
}

.subcategory-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.subcategory-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-delete-sub {
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0;
}

.subcategory-row-vertical:hover .btn-delete-sub {
    opacity: 0.6;
}

.btn-delete-sub:hover {
    background: #fee2e2;
    color: var(--note-1);
    opacity: 1 !important;
}

.subcategory-avg {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    min-width: 35px;
    text-align: center;
}

.subcategory-avg.average-low { background: var(--note-1); color: white; }
.subcategory-avg.average-medium-low { background: var(--note-2); color: white; }
.subcategory-avg.average-medium { background: var(--note-3); color: #166534; }
.subcategory-avg.average-high { background: var(--note-4); color: white; }
.subcategory-avg.average-libre { background: var(--primary); color: white; }
.subcategory-avg.average-none { background: var(--border); color: var(--text-secondary); }

.subcategory-grades-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: var(--spacing-xs);
}

.subcategory-grades-row .grades-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
    min-height: 24px;
    align-items: center;
}

.subcategory-grades-row .grade-buttons {
    margin-top: 0;
    margin-left: auto;
}

/* Moyenne globale de la matiere */
.category-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm);
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius-sm);
    border: 2px solid #f59e0b;
}

.total-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.total-value {
    font-size: 1rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.total-value.average-low { background: var(--note-1); color: white; }
.total-value.average-medium-low { background: var(--note-2); color: white; }
.total-value.average-medium { background: var(--note-3); color: #166534; }
.total-value.average-high { background: var(--note-4); color: white; }
.total-value.average-libre { background: var(--primary); color: white; }
.total-value.average-none { background: var(--border); color: var(--text-secondary); }

/* Message aucun theme */
.no-subcategories {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-secondary);
}

.no-sub-text {
    display: block;
    font-size: 0.8rem;
    margin-bottom: var(--spacing-xs);
}

.btn-add-sub-inline {
    background: var(--primary);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-sub-inline:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Styles des notes petites */
.grade-buttons-small .grade-btn,
.grade-btn-small {
    min-width: 20px;
    height: 20px;
    font-size: 0.65rem;
}

.grade-buttons-small .grade-dropdown,
.grade-dropdown.grade-btn-small {
    padding: 2px 4px;
    font-size: 0.7rem;
}

.grade-buttons-small .grade-input-group,
.grade-input-group.grade-btn-small {
    transform: scale(0.85);
    transform-origin: left center;
}

.grade-chip-small {
    padding: 3px 8px;
    font-size: 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.grade-chip-small .grade-remove {
    font-size: 0.65rem;
    margin-left: 2px;
    opacity: 0.7;
}

.grade-chip-small:hover .grade-remove {
    opacity: 1;
}

/* ========================================
   Configuration URL Site
   ======================================== */
.site-url-preview {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid var(--secondary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.preview-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.preview-url {
    display: block;
    font-size: 0.8rem;
    background: white;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    word-break: break-all;
    color: var(--primary);
    font-weight: 600;
}

.site-url-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    font-size: 0.85rem;
    color: #92400e;
}

/* ========================================
   Print styles
   ======================================== */
@media print {
    .header {
        background: white;
        color: black;
        box-shadow: none;
    }

    .actions-bar,
    .col-actions,
    .modal {
        display: none !important;
    }

    .table-wrapper {
        box-shadow: none;
        overflow: visible;
    }

    .grades-table {
        min-width: auto;
    }
}
