/* ============================================
   StudyBoard — Styles v1.1
   Dark mode, animations, mobile-first
   ============================================ */

/* --- Font --- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/inter.woff2') format('woff2');
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-page: #F8F9FB;
    --bg-card: #FFFFFF;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04);
    --card-border: 1px solid rgba(226,232,240,0.6);
    --card-radius: 12px;
    --accent: #4F46E5;
    --accent-light: #EEF2FF;
    --accent-hover: #4338CA;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --success: #059669;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --violet: #7c3aed;
    --violet-light: #f5f3ff;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --transition: 150ms ease;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
    --bg-page: #0f1117;
    --bg-card: #1a1d27;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --card-border: 1px solid rgba(255,255,255,0.06);
    --accent: #6366f1;
    --accent-light: rgba(99,102,241,0.12);
    --accent-hover: #818cf8;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --success: #34d399;
    --success-light: rgba(52,211,153,0.1);
    --danger: #f87171;
    --danger-light: rgba(248,113,113,0.1);
    --warning: #fbbf24;
    --warning-light: rgba(251,191,36,0.1);
    --violet: #a78bfa;
    --violet-light: rgba(167,139,250,0.1);
    --border: rgba(255,255,255,0.08);
}

/* Dark mode — Profile */
[data-theme="dark"] .profile-hero-bg {
    background: linear-gradient(135deg, #3730a3 0%, #5b21b6 50%, #7e22ce 100%);
}
[data-theme="dark"] .profile-edit-panel {
    box-shadow: -8px 0 30px rgba(0,0,0,0.4);
}
[data-theme="dark"] .profile-edit-overlay.active {
    background: rgba(0,0,0,0.6);
}
[data-theme="dark"] .profile-info-card:hover,
[data-theme="dark"] .profile-stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

[data-theme="dark"] .grades-table tbody tr:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .grades-table tfoot td { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .grades-table tbody tr.ue-subtotal { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .grades-table tbody tr.ue-subtotal:hover { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .grades-table tbody tr.validated { background: rgba(52,211,153,0.08); }
[data-theme="dark"] .grades-table tbody tr.validated:hover { background: rgba(52,211,153,0.12); }
[data-theme="dark"] .grades-table tbody tr.validated .note-input { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.2); }
[data-theme="dark"] .deadline-item:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .note-input { background: var(--bg-page) !important; color: var(--text-primary); }
[data-theme="dark"] .form-input { color: var(--text-primary); }
[data-theme="dark"] select.form-input option { background: var(--bg-card); color: var(--text-primary); }

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    transition: background 300ms ease, color 300ms ease;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

.animate-target {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger animation for cards */
.stats-grid .animate-in:nth-child(1) { transition-delay: 0ms; }
.stats-grid .animate-in:nth-child(2) { transition-delay: 80ms; }
.stats-grid .animate-in:nth-child(3) { transition-delay: 160ms; }
.stats-grid .animate-in:nth-child(4) { transition-delay: 240ms; }

.task-list .task-card,
.exam-list .exam-card {
    animation: fadeInUp 300ms ease backwards;
}

.task-list .task-card:nth-child(1) { animation-delay: 0ms; }
.task-list .task-card:nth-child(2) { animation-delay: 50ms; }
.task-list .task-card:nth-child(3) { animation-delay: 100ms; }
.task-list .task-card:nth-child(4) { animation-delay: 150ms; }
.task-list .task-card:nth-child(5) { animation-delay: 200ms; }
.task-list .task-card:nth-child(6) { animation-delay: 250ms; }
.task-list .task-card:nth-child(7) { animation-delay: 300ms; }
.task-list .task-card:nth-child(8) { animation-delay: 350ms; }

.exam-list .exam-card:nth-child(1) { animation-delay: 0ms; }
.exam-list .exam-card:nth-child(2) { animation-delay: 50ms; }
.exam-list .exam-card:nth-child(3) { animation-delay: 100ms; }
.exam-list .exam-card:nth-child(4) { animation-delay: 150ms; }
.exam-list .exam-card:nth-child(5) { animation-delay: 200ms; }

.deadline-list .deadline-item {
    animation: fadeInUp 300ms ease backwards;
}
.deadline-list .deadline-item:nth-child(1) { animation-delay: 0ms; }
.deadline-list .deadline-item:nth-child(2) { animation-delay: 40ms; }
.deadline-list .deadline-item:nth-child(3) { animation-delay: 80ms; }
.deadline-list .deadline-item:nth-child(4) { animation-delay: 120ms; }
.deadline-list .deadline-item:nth-child(5) { animation-delay: 160ms; }
.deadline-list .deadline-item:nth-child(6) { animation-delay: 200ms; }
.deadline-list .deadline-item:nth-child(7) { animation-delay: 240ms; }
.deadline-list .deadline-item:nth-child(8) { animation-delay: 280ms; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: background 300ms ease, border-color 300ms ease, transform 300ms ease;
}

.sidebar-header {
    padding: 24px 20px 16px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.sidebar-logo svg {
    width: 24px;
    height: 24px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: transform 200ms ease;
}

.nav-link:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

.nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.nav-link svg {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    padding: 14px 16px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 300ms ease;
}

.sidebar-footer .btn-icon {
    color: var(--text-secondary);
}

.sidebar-user {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 1px;
}

.sidebar-logout-form {
    display: inline-flex;
    margin: 0;
}

.nav-section {
    margin: 14px 12px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.sidebar-overlay {
    display: none;
}

/* --- Hamburger (mobile) --- */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: var(--card-border);
    box-shadow: var(--card-shadow);
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition);
}

.hamburger-btn svg {
    width: 20px;
    height: 20px;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    max-width: calc(1200px + 64px);
    animation: fadeInUp 400ms ease-out;
    transition: margin-left 300ms ease;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header .subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 2px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 200ms ease;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    transition: opacity 150ms ease;
}

.btn:active::after {
    opacity: 0.1;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: var(--card-border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 1px 2px rgba(239,68,68,0.3);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.btn-danger:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 6px;
    border-radius: 6px;
    color: var(--text-tertiary);
    transition: all 200ms ease;
}

.btn-icon:hover {
    background: var(--bg-page);
    color: var(--text-primary);
    transform: scale(1.1);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: background 300ms ease, border-color 300ms ease, box-shadow 300ms ease, transform 200ms ease;
}

.card-body {
    padding: 20px;
}

/* --- Loading State --- */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

.loading-state p {
    font-size: 0.85rem;
    animation: pulse 1.5s ease infinite;
}

/* --- Stat Cards (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 20px;
    transition: all 200ms ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.stat-card a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.stat-card .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: transform 200ms ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1);
}

.stat-card .stat-icon svg {
    width: 18px;
    height: 18px;
}

.stat-card .stat-icon.indigo {
    background: var(--accent-light);
    color: var(--accent);
}

.stat-card .stat-icon.amber {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card .stat-icon.emerald {
    background: var(--success-light);
    color: var(--success);
}

.stat-card .stat-icon.violet {
    background: var(--violet-light);
    color: var(--violet);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
    animation: countUp 500ms ease;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-progress {
    margin-top: 10px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.stat-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--success);
    transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:nth-child(4) .stat-progress-fill {
    background: var(--violet);
}

.stat-countdown {
    margin-top: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--warning);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clickable stat cards */
.stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* --- Sections --- */
.section {
    margin-bottom: 28px;
}

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

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
}

/* --- Tabs / Filters --- */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-page);
    padding: 4px;
    border-radius: 10px;
    width: fit-content;
    transition: background 300ms ease;
}

.tab {
    padding: 7px 16px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 200ms ease;
    cursor: pointer;
    position: relative;
}

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

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transform: scale(1.02);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all var(--transition);
}

.badge-indigo {
    background: var(--accent-light);
    color: var(--accent);
}

.badge-emerald {
    background: var(--success-light);
    color: var(--success);
}

.badge-red {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-amber {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-violet {
    background: var(--violet-light);
    color: var(--violet);
}

.badge-gray {
    background: #f1f5f9;
    color: var(--text-secondary);
}

[data-theme="dark"] .badge-gray {
    background: rgba(255,255,255,0.08);
}

/* --- Priority dots --- */
.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 200ms ease;
}

.priority-dot.high { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low { background: var(--text-tertiary); }

/* --- Sort Bar --- */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.sort-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sort-label svg {
    width: 14px;
    height: 14px;
}

.sort-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.sort-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.sort-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.12);
}

.sort-btn.active {
    color: white;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.sort-btn.active:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.sort-arrow {
    display: inline-flex;
    align-items: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    width: 0;
    overflow: hidden;
}

.sort-arrow.visible {
    opacity: 1;
    transform: scale(1);
    width: 14px;
}

.sort-arrow svg {
    width: 12px;
    height: 12px;
}

/* --- Task Cards --- */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    transition: all 200ms ease;
}

.task-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.task-card .task-info {
    flex: 1;
    min-width: 0;
}

.task-card .task-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.task-card .task-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* --- Status Switcher --- */
.status-switcher {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--bg-page);
    border-radius: 10px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-tertiary);
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    white-space: nowrap;
}

.status-pill svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.status-pill span {
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 250ms cubic-bezier(0.4, 0, 0.2, 1), opacity 200ms ease, margin 250ms ease;
    margin-left: 0;
}

.status-pill:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
    border-color: var(--border);
}

.status-pill:hover span {
    max-width: 70px;
    opacity: 1;
    margin-left: 2px;
}

.status-pill:active {
    transform: scale(0.92);
}

.status-pill.active span {
    max-width: 70px;
    opacity: 1;
    margin-left: 2px;
}

/* Todo active */
.status-pill[data-status="todo"].active {
    color: var(--text-secondary);
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* In progress active */
.status-pill[data-status="in_progress"].active {
    color: var(--warning);
    background: var(--warning-light);
    border-color: var(--warning);
    box-shadow: 0 1px 6px rgba(217, 119, 6, 0.15);
}

.status-pill[data-status="in_progress"].active svg {
    animation: spinSlow 2.5s linear infinite;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Done active */
.status-pill[data-status="done"].active {
    color: var(--success);
    background: var(--success-light);
    border-color: var(--success);
    box-shadow: 0 1px 6px rgba(5, 150, 105, 0.15);
}

.status-pill[data-status="done"].active svg {
    animation: popIn 350ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
    0% { transform: scale(0.5) rotate(-20deg); }
    60% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Task done state */
.task-card.task-done .task-title {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.task-card.task-done .task-meta {
    opacity: 0.5;
}

.task-card.task-done {
    opacity: 0.7;
}

.task-card.task-done:hover {
    opacity: 1;
}

.task-card .task-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.task-card:hover .task-actions {
    opacity: 1;
}

.task-card .overdue {
    color: var(--danger);
    font-weight: 600;
}

/* --- Exam Cards --- */
.exam-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exam-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    transition: all 200ms ease;
}

.exam-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.exam-card.past {
    opacity: 0.5;
}

.exam-card .exam-date-block {
    text-align: center;
    min-width: 48px;
}

.exam-card .exam-date-block .day {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
}

.exam-card .exam-date-block .month {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.exam-card .exam-info {
    flex: 1;
}

.exam-card .exam-subject {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.exam-card .exam-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.exam-card .exam-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.exam-card .exam-meta svg {
    width: 13px;
    height: 13px;
}

.exam-card .exam-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.exam-card:hover .exam-actions {
    opacity: 1;
}

/* --- Calendar --- */
.calendar-wrapper {
    overflow: hidden;
}

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

.calendar-header .month-title {
    font-weight: 600;
    font-size: 1rem;
}

.calendar-nav {
    display: flex;
    gap: 4px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-grid .day-header {
    padding: 10px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}

.calendar-grid .day-cell {
    min-height: 80px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    position: relative;
    transition: background 200ms ease;
}

.calendar-grid .day-cell:hover {
    background: var(--accent-light);
}

.calendar-grid .day-cell:nth-child(7n) {
    border-right: none;
}

.calendar-grid .day-cell .day-number {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.calendar-grid .day-cell.today .day-number {
    background: var(--accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-grid .day-cell.other-month .day-number {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.calendar-grid .day-cell .exam-dot {
    display: block;
    padding: 2px 6px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 200ms ease;
}

.calendar-grid .day-cell .exam-dot:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.02);
}

/* --- Grades Table --- */
.grades-table-wrapper {
    overflow-x: auto;
}

.grades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.grades-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.grades-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    transition: background 200ms ease;
}

.grades-table tbody tr:hover {
    background: #fafbfc;
}

.grades-table .ue-badge {
    font-weight: 700;
}

.grades-table .note-input {
    width: 72px;
    padding: 6px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    transition: all 200ms ease;
    background: var(--bg-page);
    -moz-appearance: textfield;
}

.grades-table .note-input::-webkit-inner-spin-button,
.grades-table .note-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.grades-table .note-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    transform: scale(1.05);
}

.grades-table .moyenne {
    font-weight: 600;
}

.grades-table .moyenne.pass { color: var(--success); }
.grades-table .moyenne.fail { color: var(--danger); }

/* --- Validated row --- */
.grades-table tbody tr.validated {
    background: #ecfdf5;
}

.grades-table tbody tr.validated:hover {
    background: #d1fae5;
}

.grades-table tbody tr.validated .note-input {
    background: #d1fae5;
    border-color: #a7f3d0;
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0.8;
}

.grades-table tbody tr.validated td {
    color: var(--success);
}

.grades-table tbody tr.validated .moyenne.fail {
    color: var(--danger);
}

.btn-validate {
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 200ms ease;
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-validate:hover {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-light);
    transform: scale(1.05);
}

.btn-validate.active {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

.grades-table tbody tr.ue-subtotal {
    background: #f8fafc;
    border-top: 2px solid var(--border);
}

.grades-table tbody tr.ue-subtotal:hover {
    background: #f1f5f9;
}

.grades-table tfoot td {
    padding: 12px 14px;
    font-weight: 700;
    border-top: 2px solid var(--border);
    background: #fafbfc;
}

/* Note save flash animation */
@keyframes noteSaved {
    0% { box-shadow: 0 0 0 0 rgba(5,150,105,0.4); }
    50% { box-shadow: 0 0 0 4px rgba(5,150,105,0.2); }
    100% { box-shadow: 0 0 0 0 rgba(5,150,105,0); }
}

.note-saved {
    animation: noteSaved 600ms ease;
}

/* --- Grade Summary Cards --- */
.grade-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.grade-summary .summary-card {
    text-align: center;
    padding: 24px;
    transition: all 200ms ease;
}

.grade-summary .summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.grade-summary .summary-card .summary-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
    transition: color 300ms ease;
}

.grade-summary .summary-card .summary-value.pass { color: var(--success); }
.grade-summary .summary-card .summary-value.fail { color: var(--danger); }
.grade-summary .summary-card .summary-value.neutral { color: var(--text-primary); }

.grade-summary .summary-card .summary-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Deadline List (Dashboard) --- */
.deadline-list {
    display: flex;
    flex-direction: column;
}

.deadline-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    transition: all 200ms ease;
}

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

.deadline-item:hover {
    background: #fafbfc;
    padding-left: 22px;
}

.deadline-item .deadline-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 200ms ease;
}

.deadline-item:hover .deadline-icon {
    transform: scale(1.1);
}

.deadline-item .deadline-icon svg {
    width: 16px;
    height: 16px;
}

.deadline-item .deadline-icon.task {
    background: var(--accent-light);
    color: var(--accent);
}

.deadline-item .deadline-icon.exam {
    background: var(--warning-light);
    color: var(--warning);
}

.deadline-item .deadline-info {
    flex: 1;
}

.deadline-item .deadline-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.deadline-item .deadline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    margin: 16px;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

/* Confirm modal specific */
.confirm-modal .confirm-modal-box {
    max-width: 400px;
}

.confirm-modal .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--warning);
}

.confirm-modal .modal-header h2 svg {
    width: 20px;
    height: 20px;
}

.confirm-modal .modal-body p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Form --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 200ms ease;
    background: var(--bg-card);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

select.form-input {
    cursor: pointer;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

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

/* =============================================
   Profile Page — Redesigned
   ============================================= */

/* --- Hero Card --- */
.profile-page {
    max-width: 800px;
    margin: 0 auto;
}

.profile-hero {
    position: relative;
    border-radius: var(--card-radius);
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    margin-bottom: 20px;
}

.profile-hero-bg {
    height: 120px;
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 50%, #a855f7 100%);
    position: relative;
    overflow: hidden;
}

.profile-hero-bg::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(ellipse at 30% 50%, rgba(255,255,255,0.15) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 80%, rgba(255,255,255,0.1) 0%, transparent 50%);
    animation: heroShimmer 8s ease-in-out infinite alternate;
}

.profile-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

@keyframes heroShimmer {
    0%   { transform: translateX(-10%) rotate(0deg); }
    100% { transform: translateX(10%) rotate(3deg); }
}

.profile-hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 24px 28px;
    margin-top: -50px;
    position: relative;
    z-index: 1;
}

.profile-hero-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 700;
    border: 4px solid var(--bg-card);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow: hidden;
    flex-shrink: 0;
    animation: profileAvatarIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.profile-hero-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-hero-initial {
    font-size: 2.2rem;
    font-weight: 700;
}

.profile-hero-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 12px;
    color: var(--text-primary);
    animation: profileFadeUp 400ms ease both 100ms;
}

.profile-hero-sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
    animation: profileFadeUp 400ms ease both 180ms;
}

.profile-edit-btn {
    margin-top: 16px;
    gap: 6px;
    animation: profileFadeUp 400ms ease both 260ms;
}

.profile-edit-btn svg {
    width: 16px;
    height: 16px;
}

/* --- Info Cards Grid --- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.profile-info-card {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    padding: 20px;
    opacity: 0;
    transform: translateY(12px);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.profile-info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.profile-card-enter {
    animation: profileCardIn 400ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.profile-info-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.profile-info-icon svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

/* Colored icons per card */
#infoCardDegree .profile-info-icon { background: var(--violet-light); }
#infoCardDegree .profile-info-icon svg { color: var(--violet); }
#infoCardYear .profile-info-icon { background: var(--warning-light); }
#infoCardYear .profile-info-icon svg { color: var(--warning); }
#infoCardProgram .profile-info-icon { background: var(--accent-light); }
#infoCardProgram .profile-info-icon svg { color: var(--accent); }
#infoCardUniversity .profile-info-icon { background: var(--success-light); }
#infoCardUniversity .profile-info-icon svg { color: var(--success); }

.profile-info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Stats Row --- */
.profile-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.profile-stat-card {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    padding: 20px;
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.profile-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.profile-stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.profile-stat-accent {
    color: var(--accent);
}

.profile-stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-top: 6px;
}

.profile-stat-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.profile-stat-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.profile-stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7c3aed);
    border-radius: 2px;
    width: 0%;
    transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1) 400ms;
}

.profile-stat-bar-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

/* --- Next Exam Card --- */
.profile-next-exam {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    opacity: 0;
    transform: translateY(12px);
}

.profile-next-exam.profile-card-enter {
    animation: profileCardIn 400ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

.profile-next-exam-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--warning-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-next-exam-icon svg {
    width: 22px;
    height: 22px;
    color: var(--warning);
}

.profile-next-exam-icon.urgent {
    background: var(--danger-light);
    animation: pulseUrgent 2s ease-in-out infinite;
}

.profile-next-exam-icon.urgent svg {
    color: var(--danger);
}

.profile-next-exam-info {
    flex: 1;
    min-width: 0;
}

.profile-next-exam-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-next-exam-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.profile-next-exam-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.profile-next-exam-badge.soon {
    background: var(--warning-light);
    color: var(--warning);
}

.profile-next-exam-badge.urgent {
    background: var(--danger-light);
    color: var(--danger);
}

.profile-next-exam-badge.calm {
    background: var(--success-light);
    color: var(--success);
}

@keyframes pulseUrgent {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* --- Body scroll lock when edit panel open --- */
body.profile-edit-open {
    overflow: hidden;
}

/* --- Edit Panel (slide-in from right) --- */
.profile-edit-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0);
    pointer-events: none;
    transition: background 300ms ease;
}

.profile-edit-overlay.active {
    background: rgba(0,0,0,0.4);
    pointer-events: auto;
}

.profile-edit-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 90vw);
    background: var(--bg-card);
    box-shadow: -8px 0 30px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 1001;
}

.profile-edit-overlay.active .profile-edit-panel {
    transform: translateX(0);
}

.profile-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.profile-edit-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.profile-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.profile-edit-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* --- Edit Avatar --- */
.edit-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.edit-avatar-preview {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 200ms ease;
    border: 3px solid var(--bg-page);
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.edit-avatar-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.edit-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.edit-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease;
    border-radius: 50%;
}

.edit-avatar-preview:hover .edit-avatar-overlay {
    opacity: 1;
}

.edit-avatar-overlay svg {
    width: 24px;
    height: 24px;
    color: white;
}

.edit-avatar-actions {
    display: flex;
    gap: 8px;
}

/* --- Profile Animations --- */
@keyframes profileAvatarIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

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

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

/* --- Profile Responsive --- */
@media (max-width: 600px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
    .profile-stats-row {
        grid-template-columns: 1fr;
    }
    .profile-hero-avatar {
        width: 80px;
        height: 80px;
        font-size: 1.8rem;
        margin-top: -40px;
    }
    .profile-hero-bg {
        height: 90px;
    }
    .profile-hero-content {
        margin-top: -40px;
    }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--text-primary);
    color: white;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    z-index: 2000;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 350ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
}

.toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.toast.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

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

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

/* --- View Toggle --- */
.view-toggle {
    display: flex;
    background: var(--bg-page);
    padding: 3px;
    border-radius: 8px;
}

.view-toggle button {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 200ms ease;
}

.view-toggle button svg {
    width: 14px;
    height: 14px;
}

.view-toggle button.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* --- Responsive (tablette) --- */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grade-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 300ms ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .hamburger-btn {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-top: 64px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .task-card .task-actions,
    .exam-card .exam-actions {
        opacity: 1;
    }

    .modal {
        margin: 12px;
        max-height: 90vh;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
    }
}

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

    .page-header h1 {
        font-size: 1.3rem;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
}

/* ============================================
   MODULE RÉVISIONS
   ============================================ */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 8px;
    transition: color var(--transition);
}
.back-link:hover { color: var(--accent); }
.back-link i { width: 16px; height: 16px; }

/* --- Hub des matières --- */
.rev-subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.rev-subject-card {
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 24px;
    text-decoration: none;
    color: inherit;
    display: flex;
    gap: 16px;
    transition: all 200ms ease;
    position: relative;
    overflow: hidden;
}
.rev-subject-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: var(--subject-color, var(--accent));
}
.rev-subject-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
    border-color: var(--subject-color, var(--accent));
}

.rev-subject-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--subject-color, var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rev-subject-icon i { width: 26px; height: 26px; }

.rev-subject-icon-inline {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rev-subject-icon-inline i { width: 22px; height: 22px; }

.rev-subject-body { flex: 1; min-width: 0; }
.rev-subject-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.rev-subject-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 14px;
}
.rev-subject-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}
.rev-subject-stats span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.rev-subject-stats i { width: 14px; height: 14px; }

.rev-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    flex: 1;
}
.rev-progress-fill {
    height: 100%;
    background: var(--subject-color, var(--accent));
    border-radius: 3px;
    transition: width 300ms ease;
}
.rev-subject-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}
.rev-progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.rev-subject-score {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* --- Tabs (Fiches / Flashcards / QCM) --- */
.rev-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 24px;
    width: fit-content;
}
.rev-tab {
    background: transparent;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
}
.rev-tab:hover { color: var(--text-primary); }
.rev-tab.active {
    background: var(--accent);
    color: white;
}
.rev-tab i { width: 16px; height: 16px; }

/* --- Mode FICHES : layout en 2 colonnes --- */
.rev-fiches-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.rev-fiches-list {
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 8px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.rev-fiche-link {
    display: block;
    padding: 12px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.rev-fiche-link:hover { background: var(--bg-page); color: var(--text-primary); }
.rev-fiche-link.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
}
.rev-fiche-link-chapter {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.rev-fiche-content {
    padding: 32px;
    line-height: 1.65;
    color: var(--text-primary);
}
.rev-fiche-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.rev-fiche-content .rev-fiche-summary {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.rev-fiche-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 10px;
    color: var(--text-primary);
}
.rev-fiche-content p { margin-bottom: 12px; }
.rev-fiche-content ul, .rev-fiche-content ol {
    margin-left: 22px;
    margin-bottom: 12px;
}
.rev-fiche-content li { margin-bottom: 6px; }
.rev-fiche-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 18px;
    font-size: 0.88rem;
}
.rev-fiche-content th, .rev-fiche-content td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.rev-fiche-content th {
    background: var(--bg-page);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.rev-fiche-content td:first-child { white-space: nowrap; }
.rev-fiche-content blockquote {
    border-left: 3px solid var(--accent);
    background: var(--accent-light);
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    margin: 16px 0;
    font-size: 0.92rem;
    color: var(--text-primary);
}
.rev-fiche-content em { color: var(--text-secondary); }
.rev-fiche-content strong { color: var(--text-primary); font-weight: 600; }
.rev-fiche-content code {
    background: var(--bg-page);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* --- Mode FLASHCARDS --- */
.rev-flashcard-stage {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.rev-flashcard-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.rev-stats-divider { color: var(--text-tertiary); }
.rev-stats-known { color: var(--success); display:inline-flex; align-items:center; gap:4px; }
.rev-stats-learning { color: var(--warning); display:inline-flex; align-items:center; gap:4px; }
.rev-stats-known i, .rev-stats-learning i { width: 14px; height: 14px; }

.rev-flashcard {
    perspective: 1000px;
    width: 100%;
    height: 360px;
    cursor: pointer;
    margin-bottom: 24px;
}
.rev-flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 600ms;
    transform-style: preserve-3d;
}
.rev-flashcard.flipped .rev-flashcard-inner { transform: rotateY(180deg); }
.rev-flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--bg-card);
    border: var(--card-border);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
}
.rev-flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--bg-card) 100%);
}
.rev-flashcard-text {
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--text-primary);
    margin: 0;
    font-weight: 500;
}
.rev-flashcard-chapter {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.rev-flashcard-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-top: auto;
}

.rev-flashcard-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 14px;
}
.btn-success-outline, .btn-danger-outline {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-success-outline { color: var(--success); border-color: var(--success); }
.btn-success-outline:hover { background: var(--success); color: white; }
.btn-danger-outline { color: var(--warning); border-color: var(--warning); }
.btn-danger-outline:hover { background: var(--warning); color: white; }

.rev-flashcard-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* --- Mode QCM --- */
.rev-quiz-stage { max-width: 720px; margin: 0 auto; }

.rev-quiz-welcome {
    padding: 40px;
    text-align: center;
}
.rev-quiz-welcome h2 { font-size: 1.4rem; margin-bottom: 12px; }
.rev-quiz-welcome p { color: var(--text-secondary); margin-bottom: 24px; }
.rev-quiz-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 28px;
}
.rev-quiz-options label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: left;
}
.rev-quiz-options select { min-width: 200px; }

.rev-quiz-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rev-quiz-question-card { padding: 32px; }
.rev-quiz-chapter {
    display: inline-block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 14px;
}
.rev-quiz-question-card h3 {
    font-size: 1.15rem;
    line-height: 1.5;
    margin-bottom: 22px;
    color: var(--text-primary);
}

.rev-quiz-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}
.rev-quiz-choice {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}
.rev-quiz-choice:hover { border-color: var(--accent); background: var(--accent-light); }
.rev-quiz-choice .rev-choice-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-page);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.rev-quiz-choice.selected { border-color: var(--accent); background: var(--accent-light); }
.rev-quiz-choice.correct {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}
.rev-quiz-choice.wrong {
    border-color: var(--danger);
    background: var(--danger-light);
    color: var(--danger);
}
.rev-quiz-choice.correct .rev-choice-letter {
    background: var(--success); color: white; border-color: var(--success);
}
.rev-quiz-choice.wrong .rev-choice-letter {
    background: var(--danger); color: white; border-color: var(--danger);
}
.rev-quiz-choice:disabled { cursor: default; }

.rev-quiz-explanation {
    background: var(--bg-page);
    border-left: 3px solid var(--accent);
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 18px;
}
.rev-quiz-actions { text-align: right; }

.rev-quiz-end {
    padding: 40px;
    text-align: center;
}
.rev-quiz-score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--score, 0) * 1%), var(--border) 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}
.rev-quiz-score-circle::before {
    content: '';
    position: absolute;
    inset: 12px;
    background: var(--bg-card);
    border-radius: 50%;
}
.rev-quiz-score-circle span {
    position: relative;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}
.rev-quiz-end h2 { font-size: 1.4rem; margin-bottom: 8px; }
.rev-quiz-end p { color: var(--text-secondary); margin-bottom: 24px; }
.rev-quiz-end-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.rev-quiz-review {
    margin-top: 32px;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}
.rev-quiz-review h4 { margin-bottom: 12px; font-size: 0.95rem; color: var(--text-secondary); }
.rev-quiz-review-item {
    background: var(--bg-page);
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid var(--danger);
}
.rev-quiz-review-item .rqr-q { font-weight: 500; margin-bottom: 6px; }
.rev-quiz-review-item .rqr-a { font-size: 0.85rem; color: var(--text-secondary); }
.rev-quiz-review-item .rqr-correct { color: var(--success); font-weight: 500; }

.rev-loading { padding: 32px; text-align: center; color: var(--text-tertiary); }

@media (max-width: 800px) {
    .rev-fiches-layout {
        grid-template-columns: 1fr;
    }
    .rev-fiches-list {
        position: static;
        max-height: none;
    }
    .rev-fiche-content { padding: 22px; }
    .rev-flashcard { height: 320px; }
    .rev-flashcard-face { padding: 28px; }
    .rev-flashcard-text { font-size: 1.05rem; }
}

/* --- Filtre par chapitre (chips) --- */
.rev-chapter-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}
.rev-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
}
.rev-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.rev-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ============================================
   FICHES ÉDITION + IMPRESSION + CAS PRATIQUES
   ============================================ */

.rev-fiche-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.rev-edit-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.rev-edit-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.rev-edit-textarea {
    min-height: 400px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    resize: vertical;
}

/* Cas pratiques */
.rev-cas-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.rev-cas-meta {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.72rem;
}
.rev-cas-meta i { width: 12px; height: 12px; }

.rev-cas-meta-line {
    display: flex;
    gap: 14px;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.rev-cas-meta-line i { width: 14px; height: 14px; }

.rev-cas-diff {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.rev-cas-diff.diff-easy, .rev-cas-diff.diff-facile { background: var(--success-light); color: var(--success); }
.rev-cas-diff.diff-med, .rev-cas-diff.diff-moyen { background: var(--warning-light); color: var(--warning); }
.rev-cas-diff.diff-hard, .rev-cas-diff.diff-difficile { background: var(--danger-light); color: var(--danger); }

.rev-cas-enonce {
    background: var(--bg-page);
    padding: 18px 22px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    margin-bottom: 18px;
    font-size: 0.92rem;
    line-height: 1.65;
}

.rev-cas-corrige-toggle {
    text-align: center;
    margin: 22px 0 18px;
}

.rev-cas-corrige {
    background: linear-gradient(135deg, var(--success-light) 0%, var(--bg-card) 100%);
    padding: 20px 24px;
    border-radius: 10px;
    border-left: 3px solid var(--success);
    font-size: 0.92rem;
    line-height: 1.65;
}
.rev-cas-corrige h3 { margin-top: 0; }

@media (max-width: 800px) {
    .rev-cas-layout {
        grid-template-columns: 1fr;
    }
}

/* Print rules */
@media print {
    .sidebar, .hamburger-btn, .sidebar-overlay,
    .page-header, .rev-tabs, .no-print,
    .rev-fiches-list, .rev-cas-corrige-toggle { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; max-width: none !important; }
    .rev-fiche-content { box-shadow: none !important; border: none !important; padding: 0 !important; }
}
