/* ==========================================================================
   QCM Permis B — Custom overrides on Bootstrap 5.3 dark theme
   Modern, friendly & warm
   ========================================================================== */

/* --- Bootstrap dark theme variable overrides --- */
[data-bs-theme="dark"] {
    --bs-body-bg:         #111318;
    --bs-body-color:      #c9cdd5;
    --bs-secondary-bg:    #181b22;
    --bs-tertiary-bg:     #1e2129;
    --bs-emphasis-color:  #eef1f6;
    --bs-border-color:    rgba(255, 255, 255, .07);
    --bs-link-color:      #7c9cff;
    --bs-link-hover-color:#a0b8ff;

    --bs-primary-rgb:     108, 99, 255;
    --bs-success-rgb:     45, 212, 168;
    --bs-danger-rgb:      240, 108, 117;
    --bs-warning-rgb:     233, 196, 106;
    --bs-info-rgb:        110, 168, 254;

    /* Custom tokens */
    --accent:             #6c63ff;
    --accent-hover:       #564ff0;
    --accent-glow:        rgba(108, 99, 255, .25);
    --success:            #2dd4a8;
    --success-glow:       rgba(45, 212, 168, .25);
    --surface:            #181b22;
    --surface-hover:      #1e2129;
    --surface-elevated:   #232730;
    --glow-sm:            0 2px 12px rgba(0,0,0,.3);
    --glow-md:            0 8px 30px rgba(0,0,0,.35);
    --glow-accent:        0 4px 20px var(--accent-glow);

    /* Theme exam colors */
    --th-int:     #7c83ec;
    --th-ext:     #2dd4a8;
    --th-secu:    #e9c46a;
    --th-secours: #f06c75;
}

/* --- Base --- */
body {
    font-family: 'Inter', var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(180deg, #0d0f14 0%, var(--bs-body-bg) 300px);
    min-height: 100vh;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px) scale(.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fade-in > * {
    animation: fadeInUp .45s ease both;
}
.fade-in > *:nth-child(2) { animation-delay: .06s; }
.fade-in > *:nth-child(3) { animation-delay: .12s; }
.fade-in > *:nth-child(4) { animation-delay: .15s; }
.fade-in > *:nth-child(5) { animation-delay: .20s; }
.fade-in > *:nth-child(6) { animation-delay: .25s; }
.fade-in > *:nth-child(7) { animation-delay: .30s; }
.fade-in > *:nth-child(8) { animation-delay: .35s; }

/* ==========================================================================
   Navbar — glassmorphism
   ========================================================================== */
.navbar-glass {
    background: rgba(13, 15, 20, .7) !important;
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid rgba(255,255,255,.05);
    box-shadow: 0 1px 20px rgba(0,0,0,.4);
    transition: background .3s;
}
.navbar-glass .nav-link {
    color: rgba(255,255,255,.6);
    font-weight: 500;
    font-size: .9rem;
    border-radius: .5rem;
    padding: .5rem .85rem !important;
    transition: all .2s ease;
    position: relative;
}
.navbar-glass .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
}
.navbar-glass .nav-link.active {
    color: #fff;
    background: var(--accent);
    box-shadow: var(--glow-accent);
}

.brand-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform .3s, box-shadow .3s;
}
.navbar-brand:hover .brand-dot {
    transform: scale(1.25);
    box-shadow: 0 0 18px var(--accent-glow);
}

/* ==========================================================================
   Cards — softer, glowing on hover
   ========================================================================== */
.card {
    background: var(--surface) !important;
    border: 1px solid rgba(255,255,255,.06) !important;
    border-radius: .875rem !important;
    box-shadow: var(--glow-sm);
    transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card:hover {
    border-color: rgba(255,255,255,.1) !important;
}
.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--glow-md);
}

/* ==========================================================================
   Buttons — override Bootstrap for vibrancy
   ========================================================================== */
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: #4a42d9;
    --bs-btn-active-border-color: #4a42d9;
    box-shadow: 0 4px 14px var(--accent-glow);
    font-weight: 600;
}
.btn-primary:hover {
    box-shadow: 0 6px 22px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-success {
    --bs-btn-bg: var(--success);
    --bs-btn-border-color: var(--success);
    --bs-btn-hover-bg: #22b892;
    --bs-btn-hover-border-color: #22b892;
    --bs-btn-active-bg: #1a9e7d;
    --bs-btn-active-border-color: #1a9e7d;
    --bs-btn-color: #0a2e24;
    --bs-btn-hover-color: #0a2e24;
    --bs-btn-active-color: #0a2e24;
    box-shadow: 0 4px 14px var(--success-glow);
    font-weight: 600;
}
.btn-success:hover {
    box-shadow: 0 6px 22px var(--success-glow);
    transform: translateY(-1px);
}

.btn-outline-secondary {
    --bs-btn-color: rgba(255,255,255,.6);
    --bs-btn-border-color: rgba(255,255,255,.12);
    --bs-btn-hover-bg: rgba(255,255,255,.06);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-border-color: rgba(255,255,255,.2);
}

.btn {
    border-radius: .625rem;
    transition: all .2s ease;
}
.btn:active {
    transform: scale(.97) !important;
}

/* ==========================================================================
   Theme badges
   ========================================================================== */
.badge-theme {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    padding: .35em .75em;
    border-radius: 999px;
    text-transform: uppercase;
}
.badge-int     { background: var(--th-int) !important; color: #fff !important; }
.badge-ext     { background: var(--th-ext) !important; color: #0a2e24 !important; }
.badge-secu    { background: var(--th-secu) !important; color: #3a2c00 !important; }
.badge-secours { background: var(--th-secours) !important; color: #fff !important; }

/* ==========================================================================
   Quiz question blocks
   ========================================================================== */
.question-block {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: .875rem;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    transition: border-color .2s;
}
.question-block:hover {
    border-color: rgba(255,255,255,.1);
}
.question-enonce {
    color: var(--bs-emphasis-color);
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* ==========================================================================
   QCM Options — custom styling
   ========================================================================== */
.option-label {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .85rem 1rem;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: .75rem;
    margin-bottom: .6rem;
    cursor: pointer;
    background: var(--surface);
    transition: all .2s ease;
    color: var(--bs-body-color);
}
.option-label:hover {
    background: var(--surface-elevated);
    border-color: rgba(108, 99, 255, .35);
    transform: translateX(4px);
}

/* Custom radio */
.option-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,.25);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all .2s ease;
    cursor: pointer;
    background: transparent;
}
.option-label input[type="radio"]:checked {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.option-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 8px; height: 8px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%,-50%);
}
.option-label:has(input:checked) {
    border-color: var(--accent);
    background: rgba(108, 99, 255, .08);
}

/* Result states */
.option-correct {
    border-color: var(--success) !important;
    background: rgba(45, 212, 168, .08) !important;
    border-width: 2px;
}
.option-wrong {
    border-color: rgb(var(--bs-danger-rgb)) !important;
    background: rgba(240, 108, 117, .06) !important;
    border-width: 2px;
}
.option-correct .tick { color: var(--success); }
.option-wrong .tick   { color: rgb(var(--bs-danger-rgb)); }
.tick { margin-left: auto; font-weight: 700; font-size: .85rem; white-space: nowrap; }

/* ==========================================================================
   Photo cards
   ========================================================================== */
.photo-frame {
    background: var(--bs-secondary-bg);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: .75rem;
    padding: .75rem;
    display: inline-block;
    max-width: 100%;
    transition: box-shadow .3s;
}
.photo-frame:hover {
    box-shadow: var(--glow-md);
}
.photo-frame img {
    display: block;
    max-width: 100%;
    max-height: 300px;
    width: auto; height: auto;
    object-fit: contain;
    border-radius: .5rem;
    margin: 0 auto;
}

/* ==========================================================================
   Score section
   ========================================================================== */
.score-display {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -.03em;
    line-height: 1;
    animation: countUp .5s ease both;
}
.score-low  .score-display { color: rgb(var(--bs-danger-rgb)); }
.score-mid  .score-display { color: rgb(var(--bs-warning-rgb)); }
.score-high .score-display { color: var(--success); }

.score-low  .progress-bar { background: rgb(var(--bs-danger-rgb)) !important; }
.score-mid  .progress-bar { background: rgb(var(--bs-warning-rgb)) !important; }
.score-high .progress-bar { background: var(--success) !important; }

/* Animated progress bars */
.progress {
    background: rgba(255,255,255,.06) !important;
    border-radius: 999px !important;
    overflow: hidden;
}
.progress-bar {
    background: var(--accent) !important;
    border-radius: 999px !important;
    transition: width .8s ease;
}
.progress-bar-animated-custom {
    background-size: 200% 100%;
    background-image: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,.15),
        transparent
    );
    animation: shimmer 2s infinite;
}

/* ==========================================================================
   Fiches grid tiles
   ========================================================================== */
.fiche-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: var(--surface-elevated);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: .625rem;
    color: var(--bs-emphasis-color) !important;
    font-weight: 700;
    text-decoration: none !important;
    transition: all .2s ease;
    font-size: .95rem;
}
.fiche-tile:hover {
    background: var(--accent);
    color: #fff !important;
    transform: translateY(-3px) scale(1.04);
    box-shadow: var(--glow-accent);
    border-color: transparent;
}
.fiche-tile:active {
    transform: scale(.95);
}
.fiche-tile.fiche-success {
    border-color: var(--success);
    background: rgba(45, 212, 168, .12);
    color: var(--success) !important;
}
.fiche-tile.fiche-danger {
    border-color: rgb(var(--bs-danger-rgb));
    background: rgba(240, 108, 117, .12);
    color: rgb(var(--bs-danger-rgb)) !important;
}

/* Mode indicator label on tiles */
.fiche-tile.fiche-mode-qcm,
.fiche-tile.fiche-mode-auto,
.fiche-tile.fiche-mode-exam {
    position: relative;
}
.fiche-tile.fiche-mode-qcm::after,
.fiche-tile.fiche-mode-auto::after,
.fiche-tile.fiche-mode-exam::after {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: .5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .02em;
    opacity: .7;
}
.fiche-tile.fiche-mode-qcm::after  { content: 'Q'; color: rgb(var(--bs-primary-rgb)); }
.fiche-tile.fiche-mode-auto::after { content: 'A'; color: rgba(255,255,255,.5); }
.fiche-tile.fiche-mode-exam::after { content: 'E'; color: rgb(var(--bs-info-rgb)); }
.fiche-tile:hover::after { display: none; }

/* Legend dots */
.fiche-mode-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.fiche-mode-dot.fiche-mode-qcm  { background: rgb(var(--bs-primary-rgb)); }
.fiche-mode-dot.fiche-mode-auto { background: rgba(255,255,255,.4); }
.fiche-mode-dot.fiche-mode-exam { background: rgb(var(--bs-info-rgb)); }

/* Revision result indicator */
.revision-result {
    font-size: .875rem;
    font-weight: 500;
}

/* Staggered entrance */
.grid-stagger .fiche-tile {
    animation: scaleIn .3s ease both;
}
.grid-stagger .fiche-tile:nth-child(10n+1) { animation-delay: .02s; }
.grid-stagger .fiche-tile:nth-child(10n+2) { animation-delay: .04s; }
.grid-stagger .fiche-tile:nth-child(10n+3) { animation-delay: .06s; }
.grid-stagger .fiche-tile:nth-child(10n+4) { animation-delay: .08s; }
.grid-stagger .fiche-tile:nth-child(10n+5) { animation-delay: .10s; }
.grid-stagger .fiche-tile:nth-child(10n+6) { animation-delay: .12s; }
.grid-stagger .fiche-tile:nth-child(10n+7) { animation-delay: .14s; }
.grid-stagger .fiche-tile:nth-child(10n+8) { animation-delay: .16s; }
.grid-stagger .fiche-tile:nth-child(10n+9) { animation-delay: .18s; }
.grid-stagger .fiche-tile:nth-child(10n+10){ animation-delay: .20s; }

.fiches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: .6rem;
}

/* ==========================================================================
   Stat cards — accent top border
   ========================================================================== */
.stat-card {
    background: var(--surface-elevated) !important;
    border-top: 3px solid var(--accent) !important;
    border-radius: .75rem !important;
    text-align: center;
    padding: 1.25rem 1rem !important;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-sm);
}
.stat-card.border-success { border-top-color: var(--success) !important; }
.stat-card.border-warning { border-top-color: rgb(var(--bs-warning-rgb)) !important; }
.stat-card.border-primary { border-top-color: var(--accent) !important; }
.stat-card.border-info    { border-top-color: rgb(var(--bs-info-rgb)) !important; }

.stat-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--bs-emphasis-color);
    line-height: 1.2;
}
.stat-lbl {
    font-size: .82rem;
    color: rgba(255,255,255,.5);
    margin-top: .25rem;
}

/* Clickable stat card */
a.stat-card {
    text-decoration: none !important;
    color: inherit !important;
}

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-card {
    background: var(--surface) !important;
    border: 1px solid rgba(255,255,255,.07) !important;
    border-radius: 1rem !important;
    box-shadow: 0 12px 50px rgba(0,0,0,.4);
}
.auth-icon {
    width: 56px;
    height: 56px;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    color: #fff;
    box-shadow: 0 8px 24px var(--accent-glow);
    margin-bottom: .75rem;
}

/* Form inputs — enhance focus */
.form-control, .form-select {
    background: rgba(255,255,255,.04) !important;
    border-color: rgba(255,255,255,.1) !important;
    border-radius: .625rem !important;
    color: var(--bs-emphasis-color) !important;
    padding: .7rem .9rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-glow) !important;
    background: rgba(255,255,255,.05) !important;
}
.form-select option {
    background: #1e2129;
    color: #eef1f6;
}

.form-label {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: rgba(255,255,255,.5);
    margin-bottom: .4rem;
}

/* Custom checkbox */
.form-check-input {
    background-color: rgba(255,255,255,.08) !important;
    border-color: rgba(255,255,255,.2) !important;
    border-radius: .35rem !important;
    width: 1.15em;
    height: 1.15em;
}
.form-check-input:checked {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table {
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255,255,255,.06);
}
.table thead th {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: rgba(255,255,255,.4);
    border-bottom-width: 2px;
}
.table tbody tr {
    transition: background .15s;
}
.table-hover > tbody > tr:hover {
    --bs-table-hover-bg: rgba(255,255,255,.03);
}

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert-info {
    background: rgba(108, 99, 255, .08) !important;
    border-color: rgba(108, 99, 255, .2) !important;
    color: #b4adff !important;
}
.alert-danger {
    background: rgba(240, 108, 117, .08) !important;
    border-color: rgba(240, 108, 117, .25) !important;
    color: #ffb3b8 !important;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.text-accent { color: var(--accent) !important; }
.bg-surface  { background: var(--surface) !important; }
.bg-surface-elevated { background: var(--surface-elevated) !important; }

/* Separator */
.separator {
    border: 0;
    border-top: 1px solid rgba(255,255,255,.06);
}

/* ==========================================================================
   Examiner mode
   ========================================================================== */
.exam-active-block {
    border-color: rgba(108, 99, 255, .2);
}

.exam-correct-answer {
    background: rgba(45, 212, 168, .08);
    border: 2px solid var(--success);
    border-radius: .75rem;
    padding: 1.25rem;
    text-align: center;
}
.exam-correct-label {
    color: var(--success);
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .5rem;
}
.exam-correct-text {
    color: var(--bs-emphasis-color);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.6;
}

.btn-exam-correct {
    background: var(--success);
    color: #0a2e24;
    border: none;
    font-weight: 700;
    padding: .75rem 2rem;
    border-radius: .625rem;
    box-shadow: 0 4px 14px var(--success-glow);
    transition: all .2s ease;
}
.btn-exam-correct:hover {
    background: #22b892;
    color: #0a2e24;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px var(--success-glow);
}

.btn-exam-wrong {
    background: rgb(var(--bs-danger-rgb));
    color: #fff;
    border: none;
    font-weight: 700;
    padding: .75rem 2rem;
    border-radius: .625rem;
    box-shadow: 0 4px 14px rgba(240, 108, 117, .25);
    transition: all .2s ease;
}
.btn-exam-wrong:hover {
    background: #d9565f;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(240, 108, 117, .3);
}

/* Judged question states */
.exam-judged-correct {
    border-color: var(--success) !important;
    background: rgba(45, 212, 168, .06);
}
.exam-judged-wrong {
    border-color: rgb(var(--bs-danger-rgb)) !important;
    background: rgba(240, 108, 117, .06);
}

/* Recap result states */
.exam-recap-correct {
    border-left: 3px solid var(--success) !important;
}
.exam-recap-correct .bi-check-circle-fill {
    color: var(--success);
}
.exam-recap-wrong {
    border-left: 3px solid rgb(var(--bs-danger-rgb)) !important;
}
.exam-recap-wrong .bi-x-circle-fill {
    color: rgb(var(--bs-danger-rgb));
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */
@media (max-width: 576px) {
    .score-display { font-size: 2.4rem; }
    .stat-val { font-size: 1.4rem; }
    .fiches-grid {
        grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
        gap: .5rem;
    }
}
