@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --bg: #0f1117;
    --card: #1a1d27;
    --border: #2a2d3a;
    --green: #16a34a;
    --green-light: #4ade80;
    --green-dark: #052e16;
    --blue: #60a5fa;
    --blue-dark: #0c1a3a;
    --red: #ef4444;
    --red-light: #f87171;
    --red-dark: #2d0a0a;
    --orange: #f59e0b;
    --text: #e5e7eb;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --sidebar-w: 220px;
}

/* ============================================================
   BASE RESET
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    display: flex;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ============================================================
   SIDEBAR (ADMIN)
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo .mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo .icon {
    width: 32px;
    height: 32px;
    background: var(--green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo span {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

/* ============================================================
   NAVIGATION (SIDEBAR)
   ============================================================ */
.sidebar nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 16px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav-link.active {
    background: rgba(22, 163, 74, 0.15);
    color: var(--green-light);
    font-weight: 600;
}

.nav-link .nav-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* ============================================================
   SIDEBAR USER SECTION (BOTTOM)
   ============================================================ */
.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-user .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--green-dark);
    border: 1px solid var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--green-light);
    flex-shrink: 0;
}

.sidebar-user .user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user .user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-user .logout-link {
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.sidebar-user .logout-link:hover {
    color: var(--red-light);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.topbar .badge {
    background: var(--green-dark);
    color: var(--green-light);
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 99px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.content {
    padding: 24px;
    flex: 1;
}

/* ============================================================
   HAMBURGER BUTTON (MOBILE)
   ============================================================ */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    padding: 4px 8px;
    line-height: 1;
    margin-right: 12px;
}

/* ============================================================
   SIDEBAR OVERLAY (MOBILE)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.sidebar-overlay.open {
    display: block;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.15s;
    min-height: 38px;
    font-family: inherit;
    white-space: nowrap;
}

.btn:hover {
    opacity: 0.85;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--green);
    color: #fff;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-warning {
    background: var(--orange);
    color: #000;
}

.btn-blue {
    background: #2563eb;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
    min-height: 46px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid #1f2233;
    color: var(--text);
    vertical-align: middle;
}

tr:hover td {
    background: #1f2233;
}

.badge-grado {
    background: #1e3a5f;
    color: var(--blue);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
}

.badge-status {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 99px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green { background: var(--green-dark); color: var(--green-light); }
.badge-red { background: var(--red-dark); color: var(--red-light); }
.badge-orange { background: #1c1107; color: var(--orange); }
.badge-blue { background: var(--blue-dark); color: var(--blue); }
.badge-muted { background: #1f2233; color: var(--text-muted); }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=time],
input[type=date],
input[type=search],
select,
textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    padding: 10px 12px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
    min-height: 44px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

select option {
    background: var(--card);
    color: var(--text);
}

textarea {
    min-height: 90px;
    resize: vertical;
}

label {
    display: block;
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr;
}

.form-row-3 {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr 1fr 1fr;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert-error {
    background: var(--red-dark);
    border: 1px solid #dc2626;
    color: var(--red-light);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-ok {
    background: var(--green-dark);
    border: 1px solid var(--green);
    color: var(--green-light);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-warning {
    background: #1c1107;
    border: 1px solid var(--orange);
    color: var(--orange);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-info {
    background: var(--blue-dark);
    border: 1px solid #2563eb;
    color: var(--blue);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: var(--green);
    color: #fff;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s;
    z-index: 999;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.toast.toast-error {
    background: var(--red);
}

.toast.toast-warning {
    background: var(--orange);
    color: #000;
}

/* ============================================================
   STATS / METRIC CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop, .modal-overlay, .modal-wrap {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.modal-backdrop.open, .modal-overlay.show, .modal-wrap.open {
    display: flex !important;
    animation: modalBackdropFadeIn 0.2s ease forwards;
}

.modal, .modal-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
    opacity: 0;
    transform: scale(0.97);
}

.modal-backdrop.open .modal, .modal-overlay.show .modal-box, .modal-wrap.open .modal-box {
    animation: modalBoxScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 16px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

@keyframes modalBackdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalBoxScaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================================
   MAESTRO PANEL
   ============================================================ */
.maestro-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.maestro-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.maestro-header-brand {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.maestro-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.maestro-content {
    padding: 20px;
    max-width: 960px;
    margin: 0 auto;
}

/* ============================================================
   PHOTO GRID (TEACHER ATTENDANCE)
   ============================================================ */
.foto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.foto-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    position: relative;
}

.foto-card:hover {
    border-color: var(--green);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.foto-card.estado-presente {
    border-color: var(--green);
    background: #0a2f18;
}

.foto-card.estado-ausente {
    border-color: var(--red);
    background: #2d0e0e;
}

.foto-card.estado-sin-confirmar {
    border-color: var(--orange);
    background: #22140a;
}

.foto-card.estado-justificado {
    border-color: var(--blue);
    background: #0d223f;
}

.foto-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 8px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--text-muted);
    overflow: hidden;
}

.foto-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.foto-nombre {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.foto-estado-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 14px;
    line-height: 1;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green-light); }
.text-red { color: var(--red-light); }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue); }
.text-white { color: #fff; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }
.rounded { border-radius: 8px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
.print-only { display: none; }

@media print {
    .sidebar,
    .topbar,
    .hamburger,
    .sidebar-overlay,
    .no-print,
    .btn,
    nav,
    .nav-link {
        display: none !important;
    }

    .main {
        margin-left: 0 !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .card {
        border: 1px solid #ccc;
        background: #fff;
    }

    table {
        font-size: 11px;
    }

    th,
    td {
        border: 1px solid #ccc;
        padding: 6px;
    }

    .print-only {
        display: block !important;
    }

    @page {
        margin: 1cm;
    }
}

/* ============================================================
   RESPONSIVE — TABLET/MOBILE (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .topbar {
        padding: 12px 16px;
    }

    .content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .maestro-content {
        padding: 16px;
    }
}

/* ============================================================
   RESPONSIVE — SMALL MOBILE (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 15px;
    }

    table {
        font-size: 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 12px;
    }

    .foto-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .foto-avatar {
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .foto-nombre {
        font-size: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .modal {
        margin: 8px;
        padding: 18px;
    }
}
