/* ════════════════════════════════════════════════════════════
   SISTEMA DE REGISTRO DE ASISTENCIA — Estilos
   Aesthetic: Clean institutional with warm accents
   ════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────── */
:root {
    /* Paleta principal */
    --ink:        #1a1a2e;
    --ink-light:  #3a3a5c;
    --ink-muted:  #6b6b8d;
    --surface:    #faf9f7;
    --surface-2:  #f2f0ec;
    --surface-3:  #e8e5df;
    --white:      #ffffff;
    --border:     #d8d5cf;
    --border-light:#ece9e3;

    /* Acentos */
    --teal:       #0d7377;
    --teal-soft:  #e6f5f5;
    --teal-dark:  #095456;
    --amber:      #d4860b;
    --amber-soft: #fef3e2;
    --red:        #c0392b;
    --red-soft:   #fde8e6;
    --green:      #1b8c5a;
    --green-soft: #e4f5ed;

    /* Tipografía */
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body:    'DM Sans', -apple-system, sans-serif;

    /* Espaciado */
    --gap: 1rem;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(26,26,46,.06);
    --shadow-md: 0 4px 16px rgba(26,26,46,.08);
    --shadow-lg: 0 8px 32px rgba(26,26,46,.12);

    --header-height: 72px;
    --nav-height: 52px;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Loading Screen ────────────────────────────────────── */
.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .5s ease, visibility .5s ease;
}
.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-content { text-align: center; }
.loading-icon {
    width: 72px; height: 72px;
    background: var(--teal-soft);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    color: var(--teal);
    animation: pulse-icon 2s ease-in-out infinite;
}
@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.loading-text {
    font-size: .95rem;
    color: var(--ink-muted);
    margin-bottom: 1.25rem;
}
.loading-bar {
    width: 200px; height: 3px;
    background: var(--surface-3);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}
.loading-bar-fill {
    height: 100%;
    width: 40%;
    background: var(--teal);
    border-radius: 4px;
    animation: loading-sweep 1.4s ease-in-out infinite;
}
@keyframes loading-sweep {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ─── Header ────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: .875rem; }
.brand-icon {
    width: 46px; height: 46px;
    background: var(--teal);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    color: var(--white);
    flex-shrink: 0;
}
.brand-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -.02em;
    line-height: 1.2;
}
.brand-subtitle {
    font-size: .8rem;
    color: var(--ink-muted);
    font-weight: 400;
    margin-top: 1px;
}

.connection-status {
    display: flex; align-items: center; gap: .5rem;
    padding: .4rem .85rem;
    background: var(--surface-2);
    border-radius: 100px;
    font-size: .78rem;
    color: var(--ink-muted);
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--amber);
    animation: blink 1.5s ease infinite;
}
.connection-status.connected .status-dot {
    background: var(--green);
    animation: none;
}
.connection-status.error .status-dot {
    background: var(--red);
    animation: none;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .3; }
}

/* ─── Section Nav ───────────────────────────────────────── */
.section-nav {
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: var(--header-height);
    z-index: 90;
}
.section-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    gap: .25rem;
    height: var(--nav-height);
}
.nav-tab {
    display: flex; align-items: center; gap: .5rem;
    padding: 0 1rem;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    color: var(--ink-muted);
    cursor: pointer;
    position: relative;
    transition: color .2s ease;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { color: var(--teal); }
.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: .75rem; right: .75rem;
    height: 2.5px;
    background: var(--teal);
    border-radius: 2px 2px 0 0;
}

/* ─── Main Content ──────────────────────────────────────── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}
.content-section { display: none; }
.content-section.active { display: block; }

/* ─── Classroom Selector ────────────────────────────────── */
.classroom-selector { margin-bottom: 1.25rem; }
.selector-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
    margin-bottom: .75rem;
    color: var(--ink-light);
}
.classroom-tabs {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.classroom-tab {
    padding: .6rem 1.25rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    color: var(--ink-light);
    cursor: pointer;
    transition: all .2s ease;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.classroom-tab:hover {
    border-color: var(--teal);
    color: var(--teal);
    background: var(--teal-soft);
}
.classroom-tab.active {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(13,115,119,.25);
}
.classroom-tab .tab-count {
    font-size: .7rem;
    padding: .1rem .45rem;
    border-radius: 100px;
    background: rgba(255,255,255,.2);
    font-weight: 600;
}
.classroom-tab:not(.active) .tab-count {
    background: var(--surface-2);
    color: var(--ink-muted);
}

/* ─── Date Picker ───────────────────────────────────────── */
.date-picker-wrapper {
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.date-label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--ink-light);
}
.date-input {
    padding: .5rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .85rem;
    color: var(--ink);
    background: var(--white);
    cursor: pointer;
    transition: border-color .2s ease;
}
.date-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13,115,119,.1);
}

/* ─── Attendance Container ──────────────────────────────── */
.attendance-container {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.table-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.table-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 400;
}
.table-subtitle {
    font-size: .8rem;
    color: var(--ink-muted);
    margin-top: .2rem;
}

.table-stats {
    display: flex;
    gap: .75rem;
}
.stat {
    text-align: center;
    padding: .5rem .875rem;
    border-radius: var(--radius-sm);
    min-width: 72px;
}
.stat-present { background: var(--green-soft); }
.stat-late    { background: var(--amber-soft); }
.stat-absent  { background: var(--red-soft); }

.stat-number {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-present .stat-number { color: var(--green); }
.stat-late .stat-number    { color: var(--amber); }
.stat-absent .stat-number  { color: var(--red); }

.stat-label {
    font-size: .65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-muted);
}

/* ─── Quick Actions ─────────────────────────────────────── */
.quick-actions {
    padding: .75rem 1.5rem;
    display: flex;
    gap: .5rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface);
}
.quick-btn {
    display: flex; align-items: center; gap: .4rem;
    padding: .4rem .85rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--teal);
    color: var(--white);
    font-family: var(--font-body);
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}
.quick-btn:hover { background: var(--teal-dark); }
.quick-btn-outline {
    background: var(--white);
    color: var(--ink-light);
    border: 1px solid var(--border);
}
.quick-btn-outline:hover {
    background: var(--surface-2);
    border-color: var(--ink-muted);
}

/* ─── Table ─────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }

.attendance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.attendance-table th {
    background: var(--surface);
    padding: .7rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.attendance-table td {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.attendance-table tbody tr {
    transition: background .15s ease;
}
.attendance-table tbody tr:hover {
    background: var(--surface);
}
.attendance-table tbody tr.row-absent {
    background: var(--red-soft);
}
.attendance-table tbody tr.row-absent:hover {
    background: #fbd5d1;
}
.attendance-table tbody tr.row-late {
    background: var(--amber-soft);
}
.attendance-table tbody tr.row-late:hover {
    background: #fde9c8;
}

.col-index { width: 50px; text-align: center; }
.col-name  { min-width: 220px; }
.col-status { width: 200px; }
.col-reason { min-width: 240px; }

.student-name {
    font-weight: 500;
    color: var(--ink);
}

/* ─── Status Toggle (triple) ──────────────────────────── */
.status-toggle {
    display: flex;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
.status-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .4rem .5rem;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    color: var(--ink-muted);
    position: relative;
}
.status-option:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0; top: 20%; bottom: 20%;
    width: 1px;
    background: var(--border);
}
.status-option:hover { background: rgba(0,0,0,.04); }

.status-option.active-present {
    background: var(--green);
    color: var(--white);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.status-option.active-present::after { display: none; }
.status-option.active-late {
    background: var(--amber);
    color: var(--white);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.status-option.active-late::after { display: none; }
.status-option.active-absent {
    background: var(--red);
    color: var(--white);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.15);
}
.status-option.active-absent::after { display: none; }

/* ─── Reason Input ──────────────────────────────────────── */
.reason-input {
    width: 100%;
    padding: .45rem .65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .82rem;
    color: var(--ink);
    background: var(--white);
    transition: all .2s ease;
}
.reason-input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13,115,119,.1);
}
.reason-input:disabled {
    background: var(--surface-2);
    color: var(--ink-muted);
    cursor: not-allowed;
    opacity: .5;
}

/* ─── Save Section ──────────────────────────────────────── */
.save-section {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
}
.save-btn {
    display: flex; align-items: center; gap: .5rem;
    padding: .7rem 2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--teal);
    color: var(--white);
    font-family: var(--font-body);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s ease;
    box-shadow: 0 2px 8px rgba(13,115,119,.3);
}
.save-btn:hover:not(:disabled) {
    background: var(--teal-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13,115,119,.35);
}
.save-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.save-btn.saving {
    pointer-events: none;
    opacity: .7;
}

/* ─── Empty & Coming Soon ───────────────────────────────── */
.empty-state, .coming-soon {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--ink-muted);
}
.empty-state svg, .coming-soon svg {
    margin-bottom: 1rem;
    opacity: .4;
}
.empty-state p, .coming-soon p {
    font-size: .9rem;
    margin-top: .25rem;
}
.coming-soon h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--ink-light);
}
.retry-btn {
    margin-top: 1rem;
    padding: .5rem 1.25rem;
    border: 1.5px solid var(--teal);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--teal);
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
}
.retry-btn:hover {
    background: var(--teal);
    color: var(--white);
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(26,26,46,.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all .25s ease;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    transform: scale(.95) translateY(10px);
    transition: transform .25s ease;
}
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}
.modal-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}
.modal-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 400;
}
.modal-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--ink-muted);
    transition: all .15s ease;
}
.modal-close:hover { background: var(--surface-3); color: var(--ink); }
.modal-body {
    padding: 1.25rem 1.5rem;
    font-size: .9rem;
    line-height: 1.7;
    color: var(--ink-light);
}
.modal-body .summary-line {
    display: flex;
    justify-content: space-between;
    padding: .35rem 0;
    border-bottom: 1px solid var(--border-light);
}
.modal-body .summary-value { font-weight: 600; }
.modal-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    border-top: 1px solid var(--border-light);
}
.modal-btn {
    padding: .5rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}
.modal-btn-cancel {
    background: var(--surface-2);
    color: var(--ink-light);
}
.modal-btn-cancel:hover { background: var(--surface-3); }
.modal-btn-confirm {
    background: var(--teal);
    color: var(--white);
}
.modal-btn-confirm:hover { background: var(--teal-dark); }

/* ─── Toast Notifications ───────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.toast {
    padding: .85rem 1.25rem;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 500;
    color: var(--white);
    box-shadow: var(--shadow-lg);
    animation: toast-in .35s ease;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: .65rem;
}
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }
.toast.toast-info    { background: var(--teal); }
.toast.toast-warning { background: var(--amber); }
.toast.removing {
    animation: toast-out .3s ease forwards;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-8px) scale(.95); }
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-inner { padding: 0 1rem; }
    .brand-title { font-size: 1.2rem; }
    .main-content { padding: 1rem; }
    .table-header { flex-direction: column; }
    .table-stats { width: 100%; }
    .stat { flex: 1; }
    .col-name { min-width: 160px; }
    .col-reason { min-width: 180px; }
    .quick-actions { flex-wrap: wrap; }
    .save-btn { width: 100%; justify-content: center; }
    .classroom-tabs { gap: .35rem; }
    .classroom-tab { padding: .5rem .85rem; font-size: .8rem; }
}

@media (max-width: 480px) {
    :root { --header-height: 60px; --nav-height: 44px; }
    .brand-icon { width: 38px; height: 38px; }
    .brand-icon svg { width: 22px; height: 22px; }
    .brand-subtitle { display: none; }
    .connection-status .status-text { display: none; }
    .table-header { padding: 1rem; }
    .quick-actions { padding: .6rem 1rem; }
    .attendance-table th,
    .attendance-table td { padding: .5rem .65rem; }
    .save-section { padding: 1rem; }
}
