/*
 * Padrão de tabelas do design system (Brain ADR-003 · protótipo Five-High/popsin-spartan-fit, `.student-table`).
 * Carregado em _CommonMasterLayout para TODAS as marcas e páginas (personal, aluno, academia, admin).
 *
 * Tokens --ds-t-*: escuro neutro por padrão (o Sneat compilado do ProShapeHub já é escuro) e, dentro do
 * shell premium ([data-shell=premium]), as cores do tema da marca (--psh-* de /branding/theme.css).
 * Cabeçalho muted em caixa alta, bordas de 1px, hover sutil, paddings compactos, sem sombra.
 * Fora do padrão: tabelas de impressão/PDF (.listview), .table-dark e .ds-table-plain.
 *
 * Classes opcionais (markup das linhas):
 *   .ds-table-card / .ds-table-card-head / .ds-table-footer  → container arredondado + rodapé (contagem + link)
 *   .ds-cell-user > .ds-avatar + .ds-cell-title/.ds-cell-sub  → avatar circular + nome + subtítulo
 *   .ds-pill.is-ok|is-attention|is-danger|is-primary|is-muted  → status com bolinha
 *   .ds-progress > .ds-progress-track > span + valor           → barra fina de adesão
 *   td.ds-col-chevron + tr[data-href]                          → linha clicável (ver js/ds-tables.js)
 */
:root {
    --ds-t-card: var(--bs-card-bg, #2b2b2b);
    --ds-t-border: rgba(255, 255, 255, .08);
    --ds-t-text: #e9eaeb;
    --ds-t-muted: #9a9ca1;
    --ds-t-head-bg: transparent;
    --ds-t-hover: rgba(255, 255, 255, .035);
    --ds-t-striped: rgba(255, 255, 255, .02);
    --ds-t-avatar-bg: #2a333b;
    --ds-t-track: rgba(255, 255, 255, .1);
    --ds-t-success: #4ec983;
    --ds-t-warning: #e9b452;
    --ds-t-danger: #ff5b4a;
    --ds-t-radius: 8px;
}

[data-shell="premium"] {
    --ds-t-card: var(--psh-card, #141517);
    --ds-t-border: var(--psh-border, #2a2b2e);
    --ds-t-text: var(--psh-text, #f1f2f3);
    --ds-t-muted: var(--psh-muted, #8c8f95);
    --ds-t-hover: color-mix(in oklch, var(--psh-text, #f1f2f3) 4%, transparent);
    --ds-t-striped: color-mix(in oklch, var(--psh-text, #f1f2f3) 2%, transparent);
    --ds-t-avatar-bg: #1f2a33;
    --ds-t-track: color-mix(in oklch, var(--psh-text, #f1f2f3) 10%, transparent);
    --ds-t-success: var(--psh-success, #4ec983);
    --ds-t-warning: var(--psh-warning, #e9b452);
    --ds-t-danger: var(--psh-danger, #ff3e1d);
    --ds-t-radius: var(--psh-radius, 8px);
}

/* ---------- Tabela ---------- */
.table:not(.listview):not(.table-dark):not(.ds-table-plain) {
    --bs-table-color: var(--ds-t-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--ds-t-border);
    --bs-table-striped-color: var(--ds-t-text);
    --bs-table-striped-bg: var(--ds-t-striped);
    --bs-table-hover-color: var(--ds-t-text);
    --bs-table-hover-bg: var(--ds-t-hover);
    --bs-table-active-color: var(--ds-t-text);
    color: var(--ds-t-text);
    border-color: var(--ds-t-border);
    font-size: 13.5px;
}

.table:not(.listview):not(.ds-table-plain) > :not(caption) > * > * {
    padding: 14px 18px;
    border-color: var(--ds-t-border);
    vertical-align: middle;
}

/* Cabeçalho: labels pequenos, caixa alta, letter-spacing, cor muted, sem fundo destacado. */
.table:not(.listview):not(.table-dark):not(.ds-table-plain) > thead > tr > th,
.table:not(.listview):not(.table-dark):not(.ds-table-plain) > thead > tr > td {
    background-color: var(--ds-t-head-bg);
    color: var(--ds-t-muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    white-space: nowrap;
    padding-block: 14px;
    border-bottom: 1px solid var(--ds-t-border);
}

.table:not(.listview):not(.ds-table-plain) > tbody > tr > * {
    padding-block: 16px;
}

/* O core.css do ProShapeHub zebra todas as tabelas (tr:nth-child(odd) #3a3a3a): o padrão é liso, com divisores.
   Quem quiser zebra usa .table-striped (tom sutil via --bs-table-striped-bg). */
.table:not(.listview):not(.table-dark):not(.ds-table-plain) > tbody > tr:nth-child(odd) {
    background-color: transparent;
    color: inherit;
}

.table:not(.listview):not(.ds-table-plain) > tbody > tr:last-child > * {
    border-bottom-width: 0;
}

/* Hover sutil em todas as linhas (o padrão do protótipo não depende de .table-hover). */
.table:not(.listview):not(.table-dark):not(.ds-table-plain) > tbody > tr:hover > * {
    --bs-table-color-state: var(--bs-table-hover-color);
    --bs-table-bg-state: var(--bs-table-hover-bg);
}

.table.table-sm:not(.listview):not(.ds-table-plain) > :not(caption) > * > *,
.table.table-sm:not(.listview):not(.ds-table-plain) > tbody > tr > * {
    padding: 9px 14px;
}

.table.table-sm:not(.listview):not(.ds-table-plain) > thead > tr > th {
    padding-block: 10px;
}

.table.table-bordered:not(.listview):not(.ds-table-plain) > :not(caption) > * > * {
    border-color: var(--ds-t-border);
}

.table:not(.listview) .badge {
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    padding: 4px 9px;
}

/* Cards que só embrulham a tabela: flat, borda de 1px, cantos arredondados (sem sombra). */
.card:has(> .table-responsive > .table:not(.listview)),
.card:has(> .table:not(.listview)) {
    box-shadow: none;
    border: 1px solid var(--ds-t-border);
    border-radius: var(--ds-t-radius);
    overflow: hidden;
}

/* ---------- Container ---------- */
.ds-table-card {
    background: var(--ds-t-card);
    border: 1px solid var(--ds-t-border);
    border-radius: var(--ds-t-radius);
    overflow: hidden;
    min-width: 0; /* dentro de flex/grid: a tabela rola no .table-responsive em vez de esticar a página */
}

.ds-table-card .table { margin-bottom: 0; }

.ds-table-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--ds-t-border);
}

.ds-table-card-head h3 {
    margin: 0;
    font-family: var(--psh-font-display, inherit);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--ds-t-text);
}

.ds-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-top: 1px solid var(--ds-t-border);
    font-size: 12px;
    color: var(--ds-t-muted);
}

.ds-table-footer a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--bs-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.ds-table-footer a .bx { font-size: 18px; }

/* ---------- Células ---------- */
.ds-cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }

.ds-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    object-fit: cover;
    background: var(--ds-t-avatar-bg);
    color: var(--ds-t-text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.ds-cell-title { display: block; font-weight: 600; color: var(--ds-t-text); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-cell-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--ds-t-muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-muted { color: var(--ds-t-muted) !important; }

.ds-pill {
    --ds-pill-color: var(--ds-t-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    color: var(--ds-pill-color);
    background: color-mix(in oklch, var(--ds-pill-color) 12%, transparent);
}

.ds-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.ds-pill.is-ok { --ds-pill-color: var(--ds-t-success); }
.ds-pill.is-attention { --ds-pill-color: var(--ds-t-warning); }
.ds-pill.is-danger { --ds-pill-color: var(--ds-t-danger); }
.ds-pill.is-primary { --ds-pill-color: var(--bs-primary); }
.ds-pill.is-muted { --ds-pill-color: var(--ds-t-muted); }

.ds-progress { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.ds-progress-track { width: 60px; height: 6px; border-radius: 3px; background: var(--ds-t-track); overflow: hidden; flex: 0 0 auto; }
.ds-progress-track > span { display: block; height: 100%; border-radius: 3px; background: var(--ds-t-success); }
.ds-progress-value { font-size: 12.5px; font-weight: 600; color: var(--ds-t-text); }

.table td.ds-col-chevron,
.table th.ds-col-chevron { width: 1%; text-align: right; white-space: nowrap; color: var(--ds-t-muted); position: relative; }
.ds-table-card .table-responsive { position: relative; }
.ds-col-chevron .bx { font-size: 20px; vertical-align: middle; }

.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover .ds-col-chevron { color: var(--ds-t-text); }

/* ---------- Barra de filtros (lista de alunos) ---------- */
.ds-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ds-search { position: relative; flex: 0 1 280px; min-width: 200px; }
.ds-search .bx { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ds-t-muted); font-size: 18px; pointer-events: none; }
.ds-search .form-control { padding-left: 40px; height: 42px; }
.ds-toolbar .form-select { height: 42px; flex: 1 1 220px; }
.ds-count { display: inline-flex; align-items: center; gap: 6px; color: var(--ds-t-muted); font-size: 12px; white-space: nowrap; }
.ds-count .bx { font-size: 16px; }

@media (max-width: 760px) {
    .table:not(.listview):not(.ds-table-plain) > :not(caption) > * > * { padding-inline: 12px; }
    .ds-search { flex-basis: 100%; }
}
