/* =============================================================
   Concurseiro — estilos globais
   ============================================================= */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --accent: #0ea5e9;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #2563eb;
    --info-light: #dbeafe;
    --text: #1e293b;
    --text-muted: #64748b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 4px 14px rgba(15, 23, 42, .06);
    --shadow-lg: 0 12px 30px rgba(15, 23, 42, .12);
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 78px;
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ---------------- Estrutura app (sidebar + conteúdo) ---------------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-w);
    transition: margin-left .25s ease;
}

body.sidebar-collapsed .app { margin-left: var(--sidebar-w-collapsed); }

/* ---------------- Sidebar ---------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: width .25s ease, transform .25s ease;
}

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.brand-logo { display: block; height: 38px; width: auto; max-width: 100%; }
.brand-mini { display: none; height: 38px; width: auto; }

.sidebar-close {
    display: none;
    border: none;
    background: var(--bg);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

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

.nav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 10px 12px 6px;
    white-space: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.nav-link i {
    width: 20px;
    flex: 0 0 auto;
    text-align: center;
    font-size: 16px;
}

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

.nav-exit { color: var(--danger); }
.nav-exit:hover { background: var(--danger-light); color: var(--danger); }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.sidebar-user:hover { background: var(--bg); }

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 700;
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Estado recolhido (somente ícones) */
body.sidebar-collapsed .brand-logo { display: none; }
body.sidebar-collapsed .brand-mini { display: block; }
body.sidebar-collapsed .nav-label { display: none; }
body.sidebar-collapsed .sidebar-nav { padding-left: 12px; padding-right: 12px; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .nav-link .nav-text { display: none; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 8px 0; }
body.sidebar-collapsed .sidebar-user-info { display: none; }
body.sidebar-collapsed .sidebar-foot .nav-exit { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .sidebar-head { justify-content: center; }

.avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 18px;
}

/* ---------------- Topbar (barra superior do conteúdo) ---------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    transition: background .15s, border-color .15s;
}

.menu-toggle:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.topbar-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border-radius: 50%;
}

.topbar-user:hover { box-shadow: 0 0 0 4px var(--primary-light); }

.topbar-auth {
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.topbar-auth .brand { padding: 0; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 55;
    opacity: 0;
    transition: opacity .25s ease;
}

/* ---------------- Layout ---------------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 26px 20px 60px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0;
}

.page-subtitle {
    color: var(--text-muted);
    margin: 6px 0 0;
    font-size: 14px;
}

/* ---------------- Cards ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------------- Stat cards ---------------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: var(--primary-light);
    color: var(--primary);
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border .15s, color .15s, transform .05s;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--bg); }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-link { background: transparent; color: var(--info); padding: 0; border: none; font-weight: 600; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 7px;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="url"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

textarea { min-height: 120px; resize: vertical; }

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

.form-inline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline .form-group { margin-bottom: 0; flex: 1 1 180px; }

.help { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ---------------- Alerts ---------------- */
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: #15803d; border-color: #bbf7d0; }
.alert-erro, .alert-danger { background: var(--danger-light); color: #b91c1c; border-color: #fecaca; }
.alert-info { background: var(--info-light); color: #1d4ed8; border-color: #bfdbfe; }
.alert-warning { background: var(--warning-light); color: #b45309; border-color: #fde68a; }

.alert-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    line-height: 1;
    padding: 0 4px;
}

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #15803d; }
.badge-warning { background: var(--warning-light); color: #b45309; }
.badge-danger { background: var(--danger-light); color: #b91c1c; }
.badge-muted { background: var(--bg); color: var(--text-muted); }
.badge-accent { background: #e0f2fe; color: #0369a1; }
.badge-info { background: #ede9fe; color: #6d28d9; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------------- Progress ---------------- */
.progress {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 999px;
    transition: width .3s;
}

.meta-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------------- Stars / importância ---------------- */
.stars { color: #f59e0b; font-size: 15px; letter-spacing: 1px; }
.stars-muted { color: #cbd5e1; }

/* ---------------- Timer ---------------- */
.timer {
    text-align: center;
    padding: 26px 20px;
}

.timer-display {
    font-size: 54px;
    font-weight: 800;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    margin: 4px 0 18px;
}

.timer-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.timer-running .timer-display { color: var(--success); }

/* ---------------- Calendar ---------------- */
.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav .btn { padding: 8px 12px; }
.cal-nav .btn i { font-size: 12px; }

.cal-month {
    min-width: 152px;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    padding: 0 4px;
}

.cal-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-summary .chip { margin: 0; }

/* Em telas estreitas a tabela rola na horizontal em vez de espremer os dias */
.cal-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    background: var(--surface);
}

.calendar {
    width: 100%;
    min-width: 620px;
    /* Colunas de tamanho igual: o conteúdo de um dia não alarga a coluna */
    table-layout: fixed;
    border-collapse: collapse;
}

.calendar th {
    padding: 9px 6px;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    font-weight: 700;
}

.calendar th.is-fim-semana { color: #94a3b8; }

.calendar td {
    border: 1px solid var(--border);
    padding: 0;
    width: 14.2857%;
    vertical-align: top;
    background: var(--surface);
    font-size: 13px;
}

.calendar td.other { background: #f8fafc; }

/* Célula do dia: nada do conteúdo consegue vazar para a célula vizinha */
.cal-day {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 108px;
    padding: 5px 6px 7px;
    min-width: 0;
    overflow: hidden;
}

.cal-daynum { display: flex; align-items: center; gap: 6px; min-width: 0; }

.day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12.5px;
    flex: 0 0 auto;
}

.calendar td.other .day-num { color: #cbd5e1; }
.calendar td.today .day-num { background: var(--primary); color: #fff; }

.cal-day-hoje {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--primary);
    white-space: nowrap;
}

.cal-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.cal-event {
    /* --ev / --ev-soft vêm inline com a cor da disciplina */
    --ev: var(--primary);
    --ev-soft: var(--primary-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: 100%;
    overflow: hidden;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.3;
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--ev-soft);
    color: #1e293b;
    border-left: 3px solid var(--ev);
    text-decoration: none;
}

.cal-event time { font-weight: 700; font-variant-numeric: tabular-nums; }

.cal-event.done {
    --ev: var(--success);
    --ev-soft: var(--success-light);
    color: #15803d;
    text-decoration: line-through;
}

a.cal-event:hover { box-shadow: 0 0 0 1px var(--ev); }

/* Arrastar o estudo para outro dia (mouse) */
.cal-event[draggable="true"] { cursor: grab; }
.cal-event[draggable="true"]:active { cursor: grabbing; }
.cal-event.is-arrastado { opacity: .38; }

.calendar.is-arrastando td.cal-cell { transition: background .12s, box-shadow .12s; }

.calendar.is-arrastando td.cal-cell.is-alvo {
    background: var(--primary-light);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar.is-arrastando td.cal-cell.is-alvo .day-num { background: var(--primary); color: #fff; }

/* Enquanto a mudança de data é gravada */
.calendar.is-enviando { opacity: .55; pointer-events: none; }

@media (hover: none) {
    .cal-event[draggable="true"],
    .cal-event[draggable="true"]:active { cursor: pointer; }
}

.alerta-calendario {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 999;
    max-width: min(92vw, 420px);
    padding: 10px 16px;
    border-radius: 999px;
    background: #1e293b;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

/* Modais (dialog) do sistema */
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog.card { margin: auto; max-height: 90vh; overflow: auto; }

.cal-more {
    align-self: flex-start;
    max-width: 100%;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-more:hover { background: var(--primary-light); color: var(--primary); }

.cal-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.cal-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .dot { width: 9px; height: 9px; }

/* ---------------- Agenda (lista de estudos do mês) ---------------- */
.cal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(310px, 1fr);
    gap: 18px;
    align-items: start;
}

/* O formulário acompanha a rolagem só quando há altura suficiente na tela */
.cal-form { align-self: start; }

@media (min-width: 981px) and (min-height: 760px) {
    .cal-form { position: sticky; top: 84px; }
}

/* Os cartões da grade já ficam separados pelo gap */
.cal-layout > .card { margin-bottom: 0; }

/* Cartão da lista: recolhível (a classe só é aplicada pelo JS) */
.agenda-card.is-collapsed { padding-top: 14px; padding-bottom: 14px; }

.agenda-head { cursor: pointer; border-radius: 10px; flex-wrap: wrap; }
.agenda-card.is-collapsed .agenda-head { margin-bottom: 0; }
.agenda-head:hover .card-title { color: var(--primary); }
.agenda-head:hover .agenda-toggle { border-color: var(--primary); color: var(--primary); }

.agenda-corpo { animation: agendaIn .18s ease; }
.agenda-corpo[hidden] { display: none; }
.agenda-card.is-collapsed .agenda-corpo { display: none; }

.agenda-toggle i { transition: transform .18s ease; }
.agenda-card.is-collapsed .agenda-toggle i { transform: rotate(-90deg); }

@keyframes agendaIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .agenda-toggle i { transition: none; }
    .agenda-corpo { animation: none; }
}

.agenda { display: flex; flex-direction: column; gap: 12px; }

.agenda-dia {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    scroll-margin-top: 88px;
}

.agenda-dia.is-hoje { border-color: #c7d2fe; }

.agenda-dia-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 9px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.agenda-dia.is-hoje .agenda-dia-head { background: var(--primary-light); border-bottom-color: #c7d2fe; }

.agenda-dia-data {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 700;
    font-size: 13px;
}

.agenda-dia-data .badge { font-size: 10.5px; padding: 2px 8px; }

.agenda-dia-meta {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.agenda-dia-prog {
    flex: 0 0 auto;
    width: 84px;
    height: 6px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.agenda-dia-prog > i { display: block; height: 100%; background: var(--success); border-radius: 999px; }

.agenda .list { padding: 0 12px; }
.agenda .list-item { gap: 10px; padding: 11px 0; }

.agenda .list-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 14px;
    /* Nomes longos quebram em vez de estourar o cartão */
    overflow-wrap: anywhere;
}

.agenda .list-title .dot { flex: 0 0 auto; }
.agenda .list-title a { min-width: 0; }
.agenda .list-sub { font-size: 12.5px; overflow-wrap: anywhere; }
.agenda .list-actions { gap: 6px; }
.agenda .list-actions .btn-sm { padding: 6px 9px; }

/* ---------------- Lists ---------------- */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

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

.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 700; }
.list-sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.list-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.chip {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    margin: 2px 4px 2px 0;
}

/* ---------------- Materiais: ícone que abre o arquivo/link ---------------- */
.material-ref { margin-top: 6px; }

.material-open {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    padding: 5px 11px 5px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.material-open:hover,
.material-open:focus-visible {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    outline: none;
}

.material-open i {
    font-size: 15px;
    color: var(--primary);
}

.material-open .material-open-label {
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.material-open.is-pdf i { color: #dc2626; }
.material-open.is-doc i,
.material-open.is-docx i { color: #1d4ed8; }
.material-open.is-jpg i,
.material-open.is-jpeg i,
.material-open.is-png i { color: #7c3aed; }
.material-open.is-zip i { color: #b45309; }
.material-open.is-txt i { color: #475569; }
.material-open.is-video i { color: #dc2626; }

/* ---------------- Auth pages ---------------- */
.auth-wrap {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 34px 30px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 18px;
}

.auth-logo .brand-icon { width: 54px; height: 54px; font-size: 25px; border-radius: 14px; }
.auth-logo-img {
    display: block;
    width: auto;
    max-width: 210px;
    height: auto;
    margin: 0 auto 2px;
}
@media (max-width: 420px) {
    .auth-logo-img { max-width: 170px; }
}
.auth-title { text-align: center; font-size: 22px; font-weight: 800; margin: 10px 0 4px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-muted); }
.auth-alt a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 34px 16px;
    font-size: 14px;
}

.empty i { font-size: 32px; margin-bottom: 10px; color: #cbd5e1; display: block; }

.footer {
    margin-top: auto;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 18px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.footer p { margin: 0; }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1; }

/* ---------------- Matérias recolhíveis ---------------- */
.disc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.disc-toolbar-info {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.disc-toolbar-info strong { color: var(--text); }

.disc-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 1 1 auto;
    flex-wrap: wrap;
}

.disc-busca {
    width: auto;
    flex: 1 1 190px;
    max-width: 320px;
    padding: 8px 12px;
    font-size: 13px;
}

.disc-card { scroll-margin-top: 90px; }
/* Matéria liberada pelo administrador: só leitura para o aluno. */
.disc-card-compartilhada { border-left: 4px solid #8b5cf6; }

.disc-card.is-collapsed { padding-top: 14px; padding-bottom: 14px; }
.disc-card[hidden] { display: none; }

.disc-head {
    cursor: pointer;
    margin-bottom: 16px;
    border-radius: 10px;
    flex-wrap: wrap;
}

.disc-card.is-collapsed .disc-head { margin-bottom: 0; }

.disc-head-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}

.disc-head:hover .card-title { color: var(--primary); }
.disc-head:hover .disc-toggle { border-color: var(--primary); color: var(--primary); }

/* Prévia dos assuntos: aparece só com o cartão recolhido */
.disc-preview {
    display: none;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.disc-card.is-collapsed .disc-preview { display: block; flex: 1 1 140px; }

.disc-toggle i { transition: transform .18s ease; }
.disc-card.is-collapsed .disc-toggle i { transform: rotate(-90deg); }

.disc-body { animation: discIn .18s ease; }

@keyframes discIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: none; }
}

.disc-card.is-collapsed .disc-body { display: none; }

@media (prefers-reduced-motion: reduce) {
    .disc-toggle i { transition: none; }
    .disc-body { animation: none; }
}

/* ---------------- Notas ricas (HTML) ---------------- */
.note-body {
    margin-top: 8px;
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
}
.note-body p { margin: 0 0 1em; }
.note-body p:last-child, .note-body ul:last-child, .note-body ol:last-child { margin-bottom: 0; }
.note-body ul, .note-body ol { margin: 0 0 1em; padding-left: 1.4em; }
.note-body a { color: var(--info); }
.note-body h1, .note-body h2, .note-body h3, .note-body h4, .note-body h5, .note-body h6 { margin: .6em 0 .4em; line-height: 1.3; }
.note-body blockquote { margin: 0 0 1em; padding: .4em 1em; border-left: 3px solid var(--primary); background: var(--primary-light); border-radius: 6px; }
.note-body table { border-collapse: collapse; margin-bottom: 1em; }
.note-body th, .note-body td { border: 1px solid var(--border); padding: 6px 10px; }
.note-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.note-body img { max-width: 100%; height: auto; border-radius: 8px; }

/* TinyMCE */
.tox-tinymce { border: 1px solid var(--border) !important; border-radius: 10px !important; }
.tox .tox-editor-header { border-bottom: 1px solid var(--border) !important; }

@media (max-width: 980px) {
    .cal-layout { grid-template-columns: 1fr; }
    .cal-form { position: static; }

    /* A sidebar vira um painel deslizante por cima do conteúdo */
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
    .sidebar-close { display: inline-flex; }
    .app { margin-left: 0 !important; }

    /* Mesmo com a preferência de recolher, no celular o menu fica completo */
    body.sidebar-collapsed .brand-logo { display: block; }
    body.sidebar-collapsed .brand-mini { display: none; }
    body.sidebar-collapsed .nav-label { display: block; }
    body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 10px 12px; }
    body.sidebar-collapsed .nav-link .nav-text { display: inline; }
    body.sidebar-collapsed .sidebar-user { justify-content: flex-start; padding: 8px 10px; }
    body.sidebar-collapsed .sidebar-user-info { display: flex; }
    body.sidebar-collapsed .sidebar-foot .nav-exit { justify-content: flex-start; padding: 10px 12px; }
    body.sidebar-collapsed .sidebar-head { justify-content: space-between; }
}

@media (max-width: 720px) {
    .form-row, .form-inline { grid-template-columns: 1fr; display: grid; }
    .cal-day { min-height: 92px; padding: 4px 4px 6px; }
    .cal-event { font-size: 10.5px; padding: 2px 4px; border-left-width: 2px; }
    .agenda-dia-meta { margin-left: 0; flex: 1 1 100%; }
    .agenda-dia-prog { flex: 1 1 100%; width: auto; }
    .timer-display { font-size: 42px; }
}

/* ---------------- Chat (dúvidas) ---------------- */
.chat-msgs {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 6px 0;
    max-height: 60vh;
    overflow-y: auto;
}
.chat-msg {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 78%;
}
.chat-msg.me {
    align-items: flex-end;
    align-self: flex-end;
}
.chat-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 4px 4px;
}
.chat-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: var(--shadow);
}
.chat-msg.me .chat-bubble {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-form textarea {
    flex: 1;
    resize: vertical;
    min-height: 64px;
}

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
body.sidebar-collapsed .nav-link .nav-badge { display: none; }

/* ---------------- Questões de concurso ---------------- */
.q-card { margin-bottom: 16px; }
.q-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.q-enunciado { font-size: 15px; line-height: 1.6; margin-bottom: 14px; white-space: pre-wrap; }
.q-opcoes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.q-opcao {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.q-opcao:hover { background: var(--bg); }
.q-opcao input { margin-top: 4px; }
.q-letra {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.q-letra.mini { width: 22px; height: 22px; font-size: 12px; }
.q-texto { flex: 1; }
.q-icone { margin-left: 6px; font-size: 16px; }
.q-opcao.correta { border-color: var(--success); background: var(--success-light); }
.q-opcao.correta .q-letra { background: var(--success); color: #fff; }
.q-opcao.errada { border-color: var(--danger); background: var(--danger-light); }
.q-opcao.errada .q-letra { background: var(--danger); color: #fff; }
.q-resultado {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 10px;
    margin-top: 12px;
}
.q-resultado.ok { background: var(--success-light); color: #15803d; }
.q-resultado.erro { background: var(--danger-light); color: #b91c1c; }
.q-explicacao { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.q-explicacao summary {
    cursor: pointer;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.q-explicacao summary::-webkit-details-marker { display: none; }
.q-explicacao-body { padding: 0 14px 14px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.q-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
