/* Portal de alumnos · Colegio San Agustín */

:root {
    --navy: #0a3871;
    --navy-dark: #062753;
    --accent: #0ba5de;
    --bg: #f2f4f8;
    --card: #ffffff;
    --text: #18212f;
    --muted: #5b6676;
    --line: #e2e6ed;

    --ok: #136c3e;
    --ok-bg: #e5f3eb;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --warn: #8a5300;
    --warn-bg: #fff3dc;
    --neutral: #3d4757;
    --neutral-bg: #eceff4;

    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
    margin: 0;
    font: 16px/1.5 var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
a { color: var(--navy); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.text-bad { color: var(--bad); }
.text-ok { color: var(--ok); }

/* ---------- Marca ---------- */

.brand { display: inline-flex; align-items: center; color: #fff; text-decoration: none; }
.brand__logo { height: 44px; width: auto; display: block; }
.brand--large .brand__logo { height: 110px; }
.brand__text {
    display: flex;
    flex-direction: column;
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.05;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.brand__text small { font-size: inherit; }
.brand__text--large { font-size: clamp(2rem, 6vw, 3.25rem); }

/* ---------- Encabezado ---------- */

.topbar { background: var(--navy); color: #fff; }
.topbar__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.topbar__user { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar__user strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__user span { font-size: .85rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__logout {
    color: #fff;
    text-decoration: none;
    font-size: .9rem;
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 8px;
}
.topbar__logout:hover { background: rgba(255, 255, 255, .1); }

.tabs {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 12px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs a {
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    font-weight: 500;
    padding: 12px 10px;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}
.tabs a:hover { color: #fff; }
.tabs a[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }

/* ---------- Página ---------- */

.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 40px; display: grid; gap: 20px; }
.page__head h1 { font-size: clamp(1.4rem, 3vw, 1.85rem); line-height: 1.2; }
.page__head .muted { margin-top: 4px; }
.page__head--row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 4px;
}

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 20px 32px; }

.grid { display: grid; gap: 16px; }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--compact { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ---------- Tarjetas ---------- */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--alert { box-shadow: var(--shadow), inset 4px 0 0 var(--bad); }
.card__label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card__title { font-size: 1.1rem; margin-bottom: 8px; }
.card__value { font-size: 2rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.card__value--sm { font-size: 1.15rem; }
.card__link { margin-top: auto; padding-top: 8px; font-weight: 500; font-size: .92rem; text-decoration: none; }
.card__link:hover { text-decoration: underline; }

.stat {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat__label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat__value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: .85rem; color: var(--muted); }
.stat--bad .stat__value { color: var(--bad); }

.details { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 24px; }
.details dt { font-size: .8rem; color: var(--muted); }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.details + .muted { margin-top: 12px; }

/* ---------- Avisos, insignias ---------- */

.notice { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.notice--error { background: var(--bad-bg); color: var(--bad); box-shadow: none; }
.notice--ok { background: var(--ok-bg); color: var(--ok); box-shadow: none; }

.badge {
    display: inline-block;
    font-size: .78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--neutral { background: var(--neutral-bg); color: var(--neutral); }

.tag {
    display: inline-block;
    margin-left: 6px;
    font-size: .72rem;
    font-weight: 500;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 6px;
    vertical-align: 1px;
}

/* ---------- Tablas ---------- */

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
    background: #f7f8fb;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; }
.table .subject { font-weight: 500; }
.table .final { font-weight: 700; }
.table tfoot th, .table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; text-align: right; }
.grade { display: block; }
.absences { display: block; font-size: .75rem; color: var(--warn); }
.row--vencido .subject { box-shadow: inset 3px 0 0 var(--bad); }

/* ---------- Formularios y botones ---------- */

.btn {
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}
.btn:hover { border-color: #c7cdd8; }
.btn--primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-dark); }
.btn--block { width: 100%; padding: 12px; font-size: 1rem; }
.actions { display: flex; justify-content: flex-end; }

.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .92rem; }
.field small { color: var(--muted); font-size: .8rem; }
.field input, .period-picker select {
    font: inherit;
    padding: 10px 12px;
    border: 1px solid #cdd3dd;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    width: 100%;
}
.field input:focus, .period-picker select:focus { outline: 3px solid rgba(11, 165, 222, .3); border-color: var(--accent); }

.period-picker { display: flex; align-items: center; gap: 8px; }
.period-picker label { font-size: .85rem; color: var(--muted); }
.period-picker select { width: auto; padding: 8px 10px; }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: flex; flex-direction: column; }
.login__hero {
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, .035) 0 28px, transparent 28px 56px),
        linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 64px 20px 120px;
}
.login__card {
    width: min(420px, calc(100% - 32px));
    margin: -72px auto 40px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(10, 30, 70, .14);
    padding: 28px;
    display: grid;
    gap: 14px;
}
.login__card h1 { font-size: 1.4rem; }
.login__help { font-size: .85rem; color: var(--muted); text-align: center; }

/* ---------- Móvil: tablas como tarjetas ---------- */

@media (max-width: 760px) {
    .topbar__inner { gap: 14px; padding: 12px 16px; }
    .topbar__user span { display: none; }
    .page { padding: 20px 16px 32px; }
    .grid--compact { grid-template-columns: 1fr 1fr; gap: 10px; }
    .grid--compact .stat:first-child { grid-column: 1 / -1; }
    .stat { padding: 12px 14px; }
    .stat__value { font-size: 1.25rem; }

    .table thead { display: none; }
    .table, .table tbody, .table tfoot, .table tr { display: block; }
    .table tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table tbody tr:last-child { border-bottom: 0; }
    .table th, .table td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; }
    .table td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; font-weight: 400; }
    .table .subject { display: block; font-size: 1rem; padding-bottom: 8px; }
    .table .num { text-align: right; }
    .grade, .absences { display: inline; }
    .absences { margin-left: 8px; }
    .row--vencido { box-shadow: inset 3px 0 0 var(--bad); }
    .row--vencido .subject { box-shadow: none; }
    .table tfoot tr { padding: 12px 16px; border-top: 2px solid var(--line); }
    .table tfoot th, .table tfoot td { border: 0; padding: 0; }
    .table tfoot th[colspan] { display: none; }
    .table tfoot td:empty { display: none; }
}

/* ---------- Impresión ---------- */

@media print {
    body { background: #fff; font-size: 12px; }
    .tabs, .topbar__logout, .no-print, .footer { display: none !important; }
    .topbar { background: none; color: #000; border-bottom: 2px solid #000; }
    .brand { color: #000; }
    .card, .stat { box-shadow: none; border: 1px solid #ccc; }
    .table tbody tr:hover { background: none; }
    .page { padding: 16px 0; }
}
