:root {
    --app-surface: #ffffff;
    --app-bg: #f4f6fa;
    --app-border: rgba(15, 23, 42, .09);
}

[data-bs-theme="dark"] {
    --app-surface: #161b22;
    --app-bg: #0d1117;
    --app-border: rgba(255, 255, 255, .1);
}

body {
    background-color: var(--app-bg);
}

.app-navbar {
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

.app-navbar .navbar-brand {
    font-weight: 600;
    letter-spacing: -.01em;
}

.card {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: .75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--app-border);
    padding-block: .875rem;
}

/* ------------------------------------------------------------ stat cards */

.stat-card {
    position: relative;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background-color: var(--stat-accent, var(--bs-primary));
}

.stat-card .card-body {
    padding: 1rem 1rem 1rem 1.25rem;
}

.stat-card .stat-label {
    font-size: .78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -.02em;
    word-break: break-word;
}

.stat-card .stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: .625rem;
    font-size: 1.05rem;
    color: var(--stat-accent, var(--bs-primary));
    background-color: color-mix(in srgb, var(--stat-accent, #0d6efd) 14%, transparent);
}

.stat-card .stat-hint {
    font-size: .75rem;
    color: var(--bs-secondary-color);
}

.stat-variation {
    font-size: .75rem;
    font-weight: 600;
}

/* ------------------------------------------------------------- datatable */

table.dataTable thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
    border-bottom-width: 1px;
    white-space: nowrap;
}

table.dataTable tbody td {
    font-size: .875rem;
    vertical-align: middle;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    padding: .25rem .5rem;
}

/* O select de paginacao do DataTables nasce estreito demais no tema BS5 */
.dataTables_wrapper .dataTables_length select {
    min-width: 4.75rem;
    padding-right: 1.75rem;
    background-position: right .5rem center;
}

.dataTables_wrapper .dataTables_filter input {
    min-width: 14rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    font-size: .8125rem;
}

.dataTables_wrapper .dataTables_paginate .page-link {
    font-size: .8125rem;
}

.badge-status {
    font-weight: 500;
    font-size: .75rem;
    padding: .35em .6em;
}

.cell-mono {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --------------------------------------------- linha de detalhe (alunos) */

th.col-control,
td.dt-control {
    width: 2.5rem;
}

td.dt-control {
    cursor: pointer;
    color: var(--bs-primary);
    user-select: none;
}

/* O tema bootstrap5 do DataTables desenha o proprio marcador de expandir;
   aqui usamos o icone do Bootstrap Icons, entao o padrao e suprimido. */
table.dataTable td.dt-control::before {
    display: none !important;
}

td.dt-control i {
    transition: transform .15s ease;
}

tr.shown td.dt-control i {
    transform: rotate(45deg);
}

tr.shown {
    background-color: var(--bs-tertiary-bg);
}

.detalhe-alunos {
    padding: .75rem 1rem;
    margin: 0 0 0 2.5rem;
    border-left: 3px solid var(--bs-primary);
    background-color: var(--bs-tertiary-bg);
    border-radius: .5rem;
}

.detalhe-titulo {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    margin-bottom: .5rem;
}

.detalhe-alunos table th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
}

.detalhe-alunos table td {
    font-size: .8125rem;
    vertical-align: middle;
}

/* contadores da linha de turma */

.contador {
    display: inline-block;
    min-width: 2.25rem;
    padding: .15rem .5rem;
    border-radius: .375rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: .8125rem;
}

.contador-total    { background-color: rgba(13, 110, 253, .12); color: #0d6efd; }
.contador-ativos   { background-color: rgba(25, 135, 84, .14);  color: #198754; }
.contador-evadidos { background-color: rgba(220, 53, 69, .12);  color: #dc3545; }

[data-bs-theme="dark"] .contador-total    { color: #6ea8fe; }
[data-bs-theme="dark"] .contador-ativos   { color: #75b798; }
[data-bs-theme="dark"] .contador-evadidos { color: #ea868f; }

/* ------------------------------------------------------ ficha do aluno */

.ficha-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ficha-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background-color: var(--bs-primary);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
}

.ficha-nome {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
}

.ficha-item {
    border-left: 2px solid var(--app-border);
    padding-left: .75rem;
}

.ficha-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color);
}

.ficha-valor {
    font-size: .9375rem;
    font-weight: 500;
    word-break: break-word;
}

/* Nomes de turma/curso do SAE sao longos — limita a largura das colunas
   para a tabela nao esticar alem da viewport. */

#tabelaTurmas th:nth-child(2),
#tabelaTurmas td:nth-child(2) {
    min-width: 15rem;
    max-width: 24rem;
}

#tabelaTurmas th:nth-child(3),
#tabelaTurmas td:nth-child(3) {
    min-width: 14rem;
    max-width: 26rem;
}

.celula-curso {
    display: block;
    line-height: 1.3;
}

/* Com menos colunas, a tabela de detalhe nao precisa ocupar a largura toda —
   as celulas passam a acompanhar o conteudo. */

.detalhe-alunos table {
    width: auto;
    min-width: 38rem;
}

.detalhe-alunos table th,
.detalhe-alunos table td {
    padding-right: 2rem;
}

.detalhe-alunos table th:last-child,
.detalhe-alunos table td:last-child {
    padding-right: .25rem;
}

/* ------------------------------------------------------------------ login */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 26rem;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.login-brand i {
    color: var(--bs-primary);
}

.login-card .input-group-text {
    background-color: transparent;
    border-color: var(--app-border);
}

/* O item de sair vive dentro de um <form> (POST + CSRF) — sem isso o botao
   nao ocuparia a largura do dropdown. */
.dropdown-menu form {
    margin: 0;
}
