:root {
    --app-primary: #1e40af;
    --app-primary-soft: #e0e7ff;
    --app-accent: #f59e0b;
    --app-bg: #f4f6fb;
    --app-sidebar: #0f172a;
    --app-sidebar-text: #cbd5e1;
    --app-radius: .9rem;
    --app-orange: #fd7e14;
    --bs-primary: #1e40af;
    --bs-primary-rgb: 30, 64, 175;
    --bs-link-color: #1e40af;
    --bs-link-color-rgb: 30, 64, 175;
}

body {
    background: var(--app-bg);
    font-size: .975rem;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: #1e3a8a;
    --bs-btn-hover-border-color: #1e3a8a;
    --bs-btn-active-bg: #1e3a8a;
}

.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary);
}

.text-orange { color: var(--app-orange) !important; }
.bg-orange { background-color: var(--app-orange) !important; }

/* ---------- Estrutura ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    background: var(--app-sidebar);
    color: var(--app-sidebar-text);
    width: 260px;
}

@media (min-width: 992px) {
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        flex-shrink: 0;
        overflow-y: auto;
        background-color: var(--app-sidebar) !important;
    }
    /* o offcanvas-lg do Bootstrap esconde o cabeçalho no desktop */
    .sidebar .offcanvas-header { display: flex !important; }
}

.sidebar .offcanvas-header,
.sidebar .offcanvas-body { color: var(--app-sidebar-text); }

.sidebar .brand {
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .6rem;
    line-height: 1.1;
}

.sidebar .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: .7rem;
    background: linear-gradient(135deg, #2563eb, #f59e0b);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    color: #fff;
}

.sidebar .brand small { display: block; font-weight: 400; color: #94a3b8; font-size: .72rem; }

.sidebar .nav-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    margin: 1.2rem .75rem .35rem;
}

.sidebar .nav-link {
    color: var(--app-sidebar-text);
    border-radius: .6rem;
    padding: .55rem .75rem;
    display: flex;
    align-items: center;
    gap: .65rem;
}

.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active { background: var(--app-primary); color: #fff; }
.sidebar .nav-link .badge { margin-left: auto; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid #e5e7eb;
    padding: .55rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar .page-title {
    font-weight: 600;
    font-size: 1.02rem;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content { padding: 1.1rem; max-width: 1280px; width: 100%; margin: 0 auto; }

@media (max-width: 575.98px) {
    .content { padding: .8rem; }
}

/* ---------- Cartões ---------- */
.card {
    border: 0;
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .04);
}

.card-header { background: transparent; border-bottom: 1px solid #eef0f4; font-weight: 600; }

.eyebrow {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
    font-weight: 600;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: .8rem; color: #64748b; }

.hero-today {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 55%, #2563eb 100%);
    color: #fff;
}

.hero-today .eyebrow { color: #bfdbfe; }
.hero-today .text-secondary-light { color: #dbeafe; }

.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li { display: flex; gap: .75rem; align-items: flex-start; padding: .55rem 0; }
.step-list li + li { border-top: 1px dashed rgba(255, 255, 255, .25); }

.step-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .15);
}

.step-icon.done { background: #22c55e; }

.subject-dot {
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ---------- Desempenho ---------- */
.badge-perf { font-weight: 600; }
.badge-perf-excellent { background: #dcfce7; color: #166534; }
.badge-perf-good { background: #fef9c3; color: #854d0e; }
.badge-perf-attention { background: #ffedd5; color: #9a3412; }
.badge-perf-review { background: #fee2e2; color: #991b1b; }

.progress-thin { height: .5rem; }

.bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 3fr auto; gap: .6rem; align-items: center; }
.bar-row + .bar-row { margin-top: .6rem; }

/* ---------- Cronograma ---------- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .4rem;
}

.calendar-weekday {
    text-align: center;
    font-size: .72rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
}

.calendar-day {
    display: block;
    min-height: 92px;
    border-radius: .7rem;
    padding: .45rem .5rem;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 2px solid transparent;
    transition: transform .1s ease;
    overflow: hidden;
}

.calendar-day:hover { transform: translateY(-2px); }
.calendar-day .num { font-weight: 700; font-size: .95rem; }
.calendar-day .title { font-size: .72rem; line-height: 1.2; color: #334155; margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.calendar-day.is-empty { background: transparent; min-height: 0; }
.calendar-day.status-completed { background: #dcfce7; border-color: #86efac; }
.calendar-day.status-today { background: #fef9c3; border-color: #facc15; }
.calendar-day.status-late { background: #fee2e2; border-color: #fca5a5; }
.calendar-day.status-future { background: #fff; border-color: #e2e8f0; }
.calendar-day.is-exam { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.calendar-day.is-exam .title { color: #dbeafe; }

@media (max-width: 767.98px) {
    .calendar-grid.as-list { grid-template-columns: 1fr; }
    .calendar-grid.as-list .calendar-weekday,
    .calendar-grid.as-list .calendar-day.is-empty { display: none; }
    .calendar-grid.as-list .calendar-day { min-height: 0; display: flex; gap: .75rem; align-items: center; }
    .calendar-grid.as-list .calendar-day .num { flex: 0 0 5.2rem; white-space: nowrap; }
    .calendar-grid.as-list .calendar-day .title { -webkit-line-clamp: 2; margin: 0; font-size: .82rem; }
}

/* ---------- Player ---------- */
.video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--app-radius);
    overflow: hidden;
}

.video-frame iframe,
.video-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- Questões ---------- */
.question-statement { font-size: 1.02rem; line-height: 1.6; }
.question-statement pre,
.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: .8rem 1rem;
    border-radius: .6rem;
    font-size: .85rem;
    overflow-x: auto;
    white-space: pre;
}

.question-statement code:not(pre code) { background: #eef2ff; color: #3730a3; padding: .05rem .3rem; border-radius: .3rem; }

.option {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .8rem .9rem;
    border: 2px solid #e2e8f0;
    border-radius: .75rem;
    background: #fff;
    cursor: pointer;
    transition: border-color .1s ease, background .1s ease;
    margin-bottom: .55rem;
}

.option:hover { border-color: #93c5fd; }
.option input { display: none; }

.option .letter {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: #f1f5f9;
    color: #334155;
}

.option.is-selected,
.option:has(input:checked) { border-color: var(--app-primary); background: var(--app-primary-soft); }
.option.is-selected .letter,
.option:has(input:checked) .letter { background: var(--app-primary); color: #fff; }

.option.is-correct { border-color: #22c55e; background: #f0fdf4; }
.option.is-correct .letter { background: #22c55e; color: #fff; }
.option.is-wrong { border-color: #ef4444; background: #fef2f2; }
.option.is-wrong .letter { background: #ef4444; color: #fff; }
.option.is-locked { cursor: default; }

.feedback-box { border-radius: var(--app-radius); padding: 1rem 1.1rem; }
.feedback-box.ok { background: #f0fdf4; border: 1px solid #bbf7d0; }
.feedback-box.fail { background: #fef2f2; border: 1px solid #fecaca; }

.q-nav { display: flex; flex-wrap: wrap; gap: .35rem; }
.q-nav a {
    width: 34px;
    height: 34px;
    border-radius: .5rem;
    display: grid;
    place-items: center;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #334155;
    border: 2px solid transparent;
}

.q-nav a.ok { background: #dcfce7; color: #166534; }
.q-nav a.fail { background: #fee2e2; color: #991b1b; }
.q-nav a.current { border-color: var(--app-primary); }

.origin-badge { font-size: .72rem; }

/* ---------- Simulado ---------- */
.sim-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.sim-sheet { position: sticky; top: 70px; }
.sim-question { scroll-margin-top: 80px; }

/* ---------- Flashcards ---------- */
.flashcard {
    min-height: 260px;
    perspective: 1200px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 260px;
    transition: transform .45s ease;
    transform-style: preserve-3d;
}

.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: var(--app-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #fff;
    box-shadow: 0 6px 24px rgba(15, 23, 42, .08);
    overflow-y: auto;
}

.flashcard-face.back { transform: rotateY(180deg); background: #f8fafc; }

/* ---------- Cronômetro ---------- */
.timer-chip {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.timer-big {
    font-size: clamp(2.8rem, 10vw, 4.5rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

/* ---------- Login ---------- */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, #1e40af 0%, #0f172a 60%);
    padding: 1rem;
}

.auth-card { width: 100%; max-width: 410px; }

/* ---------- Tabelas ---------- */
.table > :not(caption) > * > * { padding: .6rem .7rem; }
.table-responsive { border-radius: var(--app-radius); }

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chart-box { position: relative; height: 280px; }

/* Admin */
.admin-nav { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.admin-nav .btn { white-space: nowrap; }
