/* =====================================================================
   PÁGINA DE ESTUDANTES — estudantes.html / js/estudantes-page.js
   Gestão do cadastro + resumo de desempenho por estudante.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

body.gobarito-students-page {
    margin: 0;
    background: #eef3fb;
    color: #0f172a;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.est-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 18px 48px;
}

/* ─── Portão (sem login) ──────────────────────────────────────────── */
.est-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.est-gate[hidden] { display: none; }

.est-gate-card {
    background: #fff;
    border: 1px solid #d6e3fb;
    border-radius: 16px;
    padding: 36px 32px;
    text-align: center;
    max-width: 400px;
}

.est-gate-card i { font-size: 2.4rem; color: #0b5ed7; }
.est-gate-card h1 { margin: 10px 0 6px; font-size: 1.3rem; }
.est-gate-card p { margin: 0; font-size: 0.88rem; color: #64748b; line-height: 1.5; }

.est-shell[hidden] { display: none; }

/* ─── Cabeçalho ───────────────────────────────────────────────────── */
.est-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.est-header-text h1 { margin: 0; font-size: 1.45rem; }
.est-header-text p { margin: 2px 0 0; font-size: 0.85rem; color: #64748b; }

.est-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.est-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
}

.est-btn:hover { background: #f1f5f9; }
.est-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.est-btn-primary {
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.est-btn-primary:hover { background: #0a52bd; }

/* ─── Barra de filtros ────────────────────────────────────────────── */
.est-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.est-search {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

.est-search i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1rem;
    pointer-events: none;
}

.est-search input {
    width: 100%;
    padding: 10px 12px 10px 34px;
    font: inherit;
    font-size: 0.88rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    outline: none;
}

.est-search input:focus,
.est-select:focus { border-color: #0b5ed7; box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.12); }

.est-select {
    padding: 10px 12px;
    font: inherit;
    font-size: 0.88rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    outline: none;
    min-width: 170px;
}

.est-count { font-size: 0.8rem; color: #64748b; margin-left: auto; }

/* ─── Layout: lista + detalhe ─────────────────────────────────────── */
.est-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr);
    gap: 14px;
    align-items: start;
}

.est-list-panel,
.est-detail-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
}

.est-list {
    max-height: calc(100vh - 300px);
    min-height: 240px;
    overflow-y: auto;
}

/* ─── Tabela de estudantes ────────────────────────────────────────── */
.est-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.est-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    text-align: left;
    font-size: 0.71rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    z-index: 1;
}

.est-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f1f5f9;
}

.est-table .is-numeric { text-align: right; }

.est-row { cursor: pointer; transition: background 0.12s; }
.est-row:hover { background: #f5f9ff; }
.est-row.is-selected { background: #eaf2ff; box-shadow: inset 3px 0 0 #0b5ed7; }

.est-row-name { display: block; font-weight: 700; }
.est-row-code { display: block; font-size: 0.73rem; color: #94a3b8; margin-top: 1px; }

.est-muted { color: #94a3b8; }
.est-table em { color: #94a3b8; font-style: italic; }

.est-empty {
    padding: 32px 22px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

.est-empty strong { display: block; color: #334155; margin-bottom: 6px; font-size: 0.92rem; }
.est-empty p { margin: 0; line-height: 1.5; max-width: 380px; margin-inline: auto; }

/* ─── Painel de detalhe ───────────────────────────────────────────── */
.est-detail-panel { padding: 18px; min-height: 240px; }

.est-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 200px;
    text-align: center;
    color: #94a3b8;
}

.est-detail-empty i { font-size: 1.8rem; }
.est-detail-empty p { margin: 0; font-size: 0.85rem; max-width: 240px; line-height: 1.5; }

.est-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.est-detail-head h2 { margin: 0; font-size: 1.08rem; }
.est-detail-head p { margin: 3px 0 0; font-size: 0.8rem; color: #64748b; }

.est-detail-actions { display: flex; gap: 4px; }

.est-icon-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 1rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.14s, color 0.14s;
}

.est-icon-btn:hover { background: #eef2f7; color: #0b5ed7; }
.est-icon-btn.is-danger:hover { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* Resumo numérico do desempenho */
.est-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}

.est-stat {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 10px;
    padding: 9px 6px;
    text-align: center;
}

.est-stat strong { display: block; font-size: 0.98rem; font-weight: 800; color: #0f172a; }
.est-stat span { display: block; font-size: 0.68rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 1px; }

.est-detail-subtitle {
    margin: 0 0 8px;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.est-detail-hint { font-size: 0.82rem; line-height: 1.5; margin: 0; }

.est-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.79rem;
}

.est-history-table th {
    text-align: left;
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #94a3b8;
    padding: 5px 7px;
    font-weight: 700;
}

.est-history-table td {
    padding: 6px 7px;
    border-top: 1px solid #f1f5f9;
    color: #334155;
}

.est-history-table .is-numeric { text-align: right; }

/* ─── Status ──────────────────────────────────────────────────────── */
.est-status {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.83rem;
    background: #f1f5f9;
    color: #475569;
}

.est-status[hidden] { display: none; }
.est-status[data-state="success"] { background: #dcfce7; color: #166534; }
.est-status[data-state="error"]   { background: #fee2e2; color: #991b1b; }

/* ─── Modais ──────────────────────────────────────────────────────── */
.est-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.est-modal[hidden] { display: none; }

.est-modal-panel {
    background: #fff;
    border-radius: 16px;
    width: min(520px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.est-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.est-modal-head h2 { margin: 0; font-size: 1.08rem; }

.est-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
}

.est-modal-close:hover { color: #0f172a; }

.est-form { display: flex; flex-direction: column; }

.est-form label {
    font-size: 0.76rem;
    font-weight: 800;
    color: #475569;
    margin: 10px 0 4px;
}

.est-form label:first-child { margin-top: 0; }

.est-form input,
.est-form textarea {
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    font-size: 0.88rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
    outline: none;
}

.est-form textarea {
    resize: vertical;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.est-form input:focus,
.est-form textarea:focus { border-color: #0b5ed7; box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.12); }

.est-form small {
    font-size: 0.74rem;
    color: #94a3b8;
    line-height: 1.45;
    margin-top: 4px;
}

.est-modal-status {
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 0.8rem;
    background: #f1f5f9;
    color: #475569;
}

.est-modal-status[hidden] { display: none; }
.est-modal-status[data-state="success"] { background: #dcfce7; color: #166534; }
.est-modal-status[data-state="error"]   { background: #fee2e2; color: #991b1b; }

.est-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ─── Responsivo ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
    /* Detalhe abaixo da lista: lado a lado nesta largura deixaria as duas
       colunas estreitas demais para a tabela de provas. */
    .est-layout { grid-template-columns: 1fr; }
    .est-list { max-height: 420px; }
}

@media (max-width: 560px) {
    .est-header { align-items: stretch; }
    .est-header-actions { width: 100%; }
    .est-header-actions .est-btn { flex: 1; justify-content: center; }
    .est-count { margin-left: 0; width: 100%; }
    .est-stats { grid-template-columns: repeat(2, 1fr); }
}
