/* ============================================================
   QUIZZ APP - Styles personnalisés
   By ALXSystems - Tous droits réservés
   ============================================================ */

/* ---- Variables ---- */
:root {
    --sidebar-width: 260px;
    --color-bg: #0a0f1e;
    --color-surface: #111827;
    --color-surface-2: #1e293b;
    --color-border: #1e2d45;
    --color-border-2: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #64748b;
    --color-text-secondary: #94a3b8;
    --color-brand: #6366f1;
    --color-brand-2: #0ea5e9;
    --radius: 0.875rem;
    --radius-sm: 0.5rem;
    --shadow: 0 4px 24px rgba(0,0,0,.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: 'DM Sans', sans-serif;
    line-height: 1.6;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-surface); }
::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-module {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.sidebar-module:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    transform: translateX(3px);
}

.sidebar-module.active {
    background: linear-gradient(135deg, rgba(99,102,241,.2), rgba(14,165,233,.15));
    color: #a5b4fc;
    border-left: 3px solid var(--color-brand);
    padding-left: calc(0.875rem - 3px);
}

/* Sidebar mobile toggle */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 40;
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        z-index: 50;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ #sidebar-overlay { display: block; }
    .sidebar-toggle { display: flex !important; }
    .main-content { margin-left: 0 !important; }
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-2);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover { background: #334155; color: var(--color-text); }

/* ---- Stat cards (dashboard KPI) ---- */
.stat-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--grad-a, #6366f1) 0%, var(--grad-b, #0ea5e9) 100%);
    opacity: 0.06;
    transition: opacity 0.2s;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--grad-a, #6366f1), var(--grad-b, #0ea5e9));
    opacity: 0.08;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,.35);
    border-color: color-mix(in srgb, var(--grad-a, #6366f1) 40%, transparent);
}

.stat-card:hover::before { opacity: 0.1; }

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

.fade-in-up {
    animation: fadeInUp 0.4s ease both;
}

.fade-in { animation: fadeIn 0.35s ease both; }

.delay-1 { animation-delay: 0.07s; }
.delay-2 { animation-delay: 0.14s; }
.delay-3 { animation-delay: 0.21s; }
.delay-4 { animation-delay: 0.28s; }

/* ---- Data table ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead tr {
    background: rgba(15,23,42,.6);
    border-bottom: 1px solid var(--color-border-2);
}

.data-table th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    color: var(--color-text-secondary);
    border-bottom: 1px solid rgba(30,41,59,.6);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.12s;
}

.data-table tbody tr:hover { background: rgba(255,255,255,.025); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInUp 0.25s ease both;
    box-shadow: var(--shadow);
}

/* ---- Card ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover { border-color: var(--color-border-2); }
.card-sm { padding: 1rem; }

/* ---- Buttons ---- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.375rem;
    background: linear-gradient(135deg, #6366f1, #0ea5e9);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
    box-shadow: 0 2px 12px rgba(99,102,241,.25);
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99,102,241,.4);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--color-surface-2);
    color: var(--color-text-secondary);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-2);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.btn-secondary:hover {
    background: #334155;
    color: var(--color-text);
    transform: translateY(-1px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(239,68,68,.12);
    color: #fca5a5;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239,68,68,.25);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.btn-danger:hover { background: rgba(239,68,68,.25); color: #fecaca; transform: translateY(-1px); }

.btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(34,197,94,.12);
    color: #86efac;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(34,197,94,.25);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.btn-success:hover { background: rgba(34,197,94,.25); color: #bbf7d0; transform: translateY(-1px); }

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    animation: fadeInUp 0.3s ease both;
}

.alert-error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.25);  color: #86efac; }
.alert-info    { background: rgba(14,165,233,.12); border: 1px solid rgba(14,165,233,.25); color: #7dd3fc; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.25); color: #fde68a; }

/* ---- Form inputs ---- */
.input-field {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-2);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    font-family: inherit;
}

.input-field:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.input-field::placeholder { color: var(--color-text-muted); }

.label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green  { background: rgba(34,197,94,.15);  color: #86efac;  border: 1px solid rgba(34,197,94,.2); }
.badge-yellow { background: rgba(245,158,11,.15); color: #fde68a;  border: 1px solid rgba(245,158,11,.2); }
.badge-orange { background: rgba(249,115,22,.15); color: #fdba74;  border: 1px solid rgba(249,115,22,.2); }
.badge-red    { background: rgba(239,68,68,.15);  color: #fca5a5;  border: 1px solid rgba(239,68,68,.2); }
.badge-blue   { background: rgba(99,102,241,.15); color: #a5b4fc;  border: 1px solid rgba(99,102,241,.2); }
.badge-gray   { background: rgba(100,116,139,.15);color: #94a3b8;  border: 1px solid rgba(100,116,139,.2);}

/* ---- Progress bar ---- */
.progress-bar {
    height: 6px;
    background: var(--color-border-2);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, var(--color-brand), var(--color-brand-2));
    transition: width 0.6s ease;
}

/* ---- Quiz answer choices ---- */
.answer-card {
    position: relative;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    user-select: none;
}

.answer-card:hover {
    border-color: var(--color-brand);
    background: rgba(99,102,241,.06);
    transform: translateX(3px);
}

.answer-card.selected {
    border-color: var(--color-brand);
    background: rgba(99,102,241,.1);
}

.answer-card.correct {
    border-color: #22c55e;
    background: rgba(34,197,94,.1);
}

.answer-card.wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,.1);
}

/* ---- Fireworks canvas ---- */
.firework-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    width: 100%;
    height: 100%;
}

/* ---- Page header section ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

/* ---- Divider ---- */
.divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.5rem 0;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ---- Tooltip ---- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    border: 1px solid var(--color-border-2);
    color: var(--color-text);
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 999;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ---- Light mode overrides ---- */
html.light-mode {
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-2: #f1f5f9;
    --color-border: #e2e8f0;
    --color-border-2: #cbd5e1;
    --color-text: #0f172a;
    --color-text-muted: #94a3b8;
    --color-text-secondary: #475569;
}

html.light-mode body { background: var(--color-bg); color: var(--color-text); }
html.light-mode .input-field { background: #fff; color: #0f172a; }
html.light-mode .data-table th { color: #475569; }
html.light-mode .data-table td { color: #334155; }
html.light-mode .data-table tbody tr:hover { background: rgba(0,0,0,.025); }

/* ---- Responsive utilitaires ---- */
@media (max-width: 640px) {
    .page-title { font-size: 1.375rem; }
    .modal-box  { padding: 1.25rem; }
    .card       { padding: 1rem; }
    .stat-card  { padding: 1rem; }
    .data-table th,
    .data-table td { padding: 0.625rem 0.75rem; }
}

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}
.badge-blue   { background: rgba(14,165,233,.15); color: #7dd3fc; }
.badge-gray   { background: rgba(100,116,139,.15); color: #94a3b8; }

/* ---- Calculator ---- */
.calc-display {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-size: 1.25rem;
    color: #f1f5f9;
    text-align: right;
    margin-bottom: 0.75rem;
    min-height: 3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
}

.calc-btn {
    padding: 0.625rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    color: #f1f5f9;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s;
    text-align: center;
}

.calc-btn:hover { background: #1e293b; }
.calc-btn.equals { background: linear-gradient(135deg, #6366f1, #0ea5e9); border: none; }

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.3s ease both; }

/* ---- Firework canvas ---- */
.firework-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    width: 100%;
    height: 100%;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ===================================================================
   THÈME CLAIR
   Stratégie : html.light-mode — surcharge les classes Tailwind
   et les classes personnalisées. La sidebar reste sombre.
   =================================================================== */

html.light-mode body {
    background-color: #f1f5f9;
    color: #1e293b;
}

/* -- Structure page -- */
html.light-mode .bg-slate-950  { background-color: #f1f5f9 !important; }
html.light-mode .bg-slate-900  { background-color: #e9f0f7 !important; }
html.light-mode .bg-slate-800  { background-color: #dce6f0 !important; }
html.light-mode .bg-slate-700  { background-color: #ccd8e8 !important; }
html.light-mode .bg-slate-600  { background-color: #b8c9d9 !important; }

/* -- Textes -- */
html.light-mode .text-white    { color: #0f172a !important; }
html.light-mode .text-slate-100 { color: #0f172a !important; }
html.light-mode .text-slate-200 { color: #1e293b !important; }
html.light-mode .text-slate-300 { color: #334155 !important; }
html.light-mode .text-slate-400 { color: #64748b !important; }
html.light-mode .text-slate-500 { color: #94a3b8 !important; }
html.light-mode .text-slate-600 { color: #94a3b8 !important; }

/* -- Bordures -- */
html.light-mode .border-slate-800 { border-color: #dce6f0 !important; }
html.light-mode .border-slate-700 { border-color: #c8d5e3 !important; }
html.light-mode .border-slate-600 { border-color: #a8bcd0 !important; }

/* -- Dividers / separateurs -- */
html.light-mode .divide-slate-800 > * + * { border-color: #dce6f0 !important; }

/* -- Timeout overlay (fond de session expirée) -- */
html.light-mode #timeout-overlay { background: rgba(241, 245, 249, 0.97) !important; }

/* -- Composants personnalisés (app.css) -- */
html.light-mode .card       { background: #ffffff; border-color: #dce6f0; }
html.light-mode .modal-box  { background: #ffffff; border-color: #dce6f0; }

html.light-mode .input-field {
    background: #f8fafc;
    border-color: #c8d5e3;
    color: #0f172a;
}
html.light-mode .input-field::placeholder { color: #94a3b8; }
html.light-mode .input-field:focus        { border-color: #6366f1; }

html.light-mode .label { color: #475569; }

html.light-mode .btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #c8d5e3;
}
html.light-mode .btn-secondary:hover { background: #e2e8f0; color: #1e293b; }

html.light-mode .btn-danger {
    background: rgba(239, 68, 68, .1);
    color: #dc2626;
    border-color: rgba(239, 68, 68, .25);
}
html.light-mode .btn-danger:hover { background: rgba(239, 68, 68, .2); }

html.light-mode .btn-success {
    background: rgba(34, 197, 94, .1);
    color: #16a34a;
    border-color: rgba(34, 197, 94, .25);
}
html.light-mode .btn-success:hover { background: rgba(34, 197, 94, .2); }

html.light-mode .calc-display {
    background: #f8fafc;
    border-color: #c8d5e3;
    color: #0f172a;
}
html.light-mode .calc-btn {
    background: #f1f5f9;
    border-color: #c8d5e3;
    color: #0f172a;
}
html.light-mode .calc-btn:hover { background: #e2e8f0; }

html.light-mode ::-webkit-scrollbar-thumb       { background: #c8d5e3; }
html.light-mode ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Bouton toggle thème dans le footer */
html.light-mode #theme-toggle {
    border-color: #c8d5e3;
    color: #64748b;
}
html.light-mode #theme-toggle:hover { border-color: #94a3b8; color: #1e293b; }

/* ---- Restauration palette sombre dans la sidebar ---- */
/* (priorité plus haute grâce au sélecteur parent .sidebar) */
html.light-mode .sidebar                   { background: #0f172a; border-right-color: #1e293b; }
html.light-mode .sidebar .text-white       { color: #f1f5f9 !important; }
html.light-mode .sidebar .text-slate-100   { color: #f1f5f9 !important; }
html.light-mode .sidebar .text-slate-200   { color: #e2e8f0 !important; }
html.light-mode .sidebar .text-slate-300   { color: #cbd5e1 !important; }
html.light-mode .sidebar .text-slate-400   { color: #94a3b8 !important; }
html.light-mode .sidebar .text-slate-500   { color: #64748b !important; }
html.light-mode .sidebar .text-slate-600   { color: #475569 !important; }
html.light-mode .sidebar .bg-slate-800     { background-color: #1e293b !important; }
html.light-mode .sidebar .bg-slate-900     { background-color: #0f172a !important; }
html.light-mode .sidebar .bg-slate-950     { background-color: #020617 !important; }
html.light-mode .sidebar .border-slate-800 { border-color: #1e293b !important; }
html.light-mode .sidebar .border-slate-700 { border-color: #334155 !important; }
html.light-mode .sidebar-module            { color: #94a3b8; }
html.light-mode .sidebar-module:hover,
html.light-mode .sidebar-module.active     { background: #1e293b; color: #f1f5f9; }
