:root {
    --primary: #FF6600;
    --primary-dark: #cc5200;
    --text: #212121;
    --bg: #F5F5F5;
    --white: #FFFFFF;
    --gray-lines: #E0E0E0;
    --success: #2E7D32;
    --warning: #F9A825;
    --danger: #C62828;
    --font-main: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Utility: Hide elements */
.hidden {
    display: none !important;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg);
    color: var(--text);
    padding-top: 100px;
    /* Base space for Sticky Header */
    overflow-x: hidden;
    width: 100%;
    -webkit-text-size-adjust: 100%;
}

html {
    overflow-x: hidden;
    width: 100%;
}


/* --- LOGIN SCREEN REDESIGN --- */
/* --- LOGIN SCREEN REDESIGN (Responsive Fix v10.1.7) --- */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    /* Use min-height to allow growth, but fixed for full screen background */
    height: 100%;
    display: flex;
    justify-content: center;
    /* Use baseline/stretch or safe centering to avoid top-crop */
    /* safe center is not fully supported, so we toggle align-items via query or use margin:auto on child */
    align-items: center;
    background-color: #000 !important;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
    /* Enable vertical scroll for the container */
    -webkit-overflow-scrolling: touch;
}

/* Fix for mobile/small screens where content is taller than viewport */
@media (max-height: 900px),
(max-width: 768px) {
    .login-container {
        align-items: flex-start;
        /* Start from top so top isn't cropped */
        padding-top: 20px;
        padding-bottom: 20px;
    }

    .login-box {
        margin: auto;
        /* Centers horizontally and vertically if space exists */
        padding: 30px 20px;
        /* Reduced padding for mobile */
    }
}

.login-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%) !important;
    z-index: -1;
}



/* Background glow for depth */
.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: var(--primary);
    filter: blur(180px);
    opacity: 0.15;
    pointer-events: none;
}

.login-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    padding: 50px 30px;
    border-radius: 32px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 480px;
    text-align: center;
    position: relative;
    z-index: 10;
    animation: premiumSlide 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
    width: 100%;
    max-width: 220px !important;
    height: auto !important;
    margin: 0 auto 30px;
    display: block;
    aspect-ratio: auto;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.1));
}

.login-box h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 800;
    color: #111;
    letter-spacing: -0.5px;
}

.login-box p {
    color: #666;
    margin-bottom: 35px;
    font-size: 1rem;
}

.role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.role-card {
    background: #ffffff !important;
    border: 1px solid #ddd;
    padding: 24px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    color: #333 !important;
    /* Ensure text is visible */
}

.role-card:hover {
    border-color: var(--primary);
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(255, 102, 0, 0.15);
}

.role-icon {
    font-size: 2.5rem;
}

.role-card span:not(.role-icon) {
    font-weight: 700;
    font-size: 0.85rem;
    color: #333;
}

@keyframes premiumSlide {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mobile responsive fixes */
@media (max-width: 480px) {
    .login-box {
        padding: 40px 20px;
    }

    .login-logo {
        max-width: 150px !important;
        margin-bottom: 10px !important;
    }

    .version-tag {
        font-size: 0.75rem;
        color: #999;
        margin-bottom: 25px;
        display: block;
    }
}


/* --- HEADER --- */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 80px;
    height: auto;
    background-color: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    border-bottom: 4px solid var(--primary);
    padding: 10px 0;
}

.header-container {
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.school-identity {
    display: flex;
    align-items: center;
    gap: 15px;
}

.school-logo {
    height: 50px;
    width: auto;
}

.school-names h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.school-names h2 {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
}

/* --- NAV --- */
.main-nav {
    display: flex;
    gap: 5px;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 10px 15px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.nav-btn:hover {
    background-color: #fff0e6;
    color: var(--primary);
}

.nav-btn.active {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
}

/* LOGOUT BUTTON DECOUPLED (v25.5) */
.logout-btn {
    background: transparent;
    border: none;
    padding: 10px 15px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.logout-btn:hover {
    background-color: #ffebee;
    color: #d32f2f;
}

/* v14.2 ISOLATION CLASS (Manual Navigation) */
.nav-btn-manual {
    background: transparent;
    border: none;
    padding: 10px 15px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
}

.nav-btn-manual:hover {
    background-color: #fff0e6;
    color: var(--primary);
}

.nav-btn-manual.active {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
}

/* --- GENERAL LAYOUT --- */
main {
    width: 95%;
    max-width: 1200px;
    margin: 20px auto;
    padding-bottom: 50px;
}

.view-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- DASHBOARD --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    text-align: center;
    border-left: 5px solid var(--primary);
}

.stat-card.success {
    border-color: var(--success);
}

.stat-card.warning {
    border-color: var(--danger);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text);
}

.actions-card,
.alerts-list-card {
    grid-column: span 3;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.buttons-row {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.btn-export {
    background: #f8f9fa;
    border: 1px solid #dfe6e9;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-export:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: white;
}

/* --- FORMS --- */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 95%;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

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




.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.form-divider {
    grid-column: span 2;
    margin-top: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--bg);
    font-weight: 700;
    color: var(--primary);
}

.btn-primary-large {
    width: 100%;
    margin-top: 30px;
    padding: 15px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
}

.btn-primary-large:hover {
    background-color: var(--primary-dark);
}

/* --- ASISTENCIA & LISTS --- */
.student-row {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #ddd;
}

.student-row.ok {
    border-left-color: var(--success);
}

.student-row.warning {
    border-left-color: var(--warning);
}

.student-row.danger {
    border-left-color: var(--danger);
}

/* 🕒 ATTENDANCE HISTORY GRID v25.20 */
.attendance-history-container {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 10px;
    background: #fdfdfd;
    border-radius: 12px;
    margin: 10px 0;
    max-width: 100%;
    border: 1px solid #eee;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.calendar-day-box {
    min-width: 32px;
    height: 42px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.calendar-day-box .day-num {
    font-size: 0.9rem;
    margin-bottom: -2px;
}

.calendar-day-box .day-mon {
    font-size: 0.5rem;
    opacity: 0.7;
    text-transform: uppercase;
}

.day-present {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #c8e6c9;
}

.day-late {
    background: #fff8e1;
    color: #f9a825;
    border-color: #ffecb3;
}

.day-absent {
    background: #ffebee;
    color: #c62828;
    border-color: #ffcdd2;
}

.day-empty {
    background: #ffffff;
    color: #bbb;
    border: 1px dashed #ddd;
}

.day-today {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.2);
}

/* ⚡ VERTICAL ACTIONS */
.actions-cell-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 10px;
    border-left: 1px solid #eee;
}

.actions-cell-vertical button {
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.actions-cell-vertical button:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.12);
}

.actions-cell-vertical button.active-attendance {
    outline: 3px solid #1976d2;
    outline-offset: 2px;
    transform: scale(1.05);
}

.actions-cell button {
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.actions-cell button:hover {
    transform: scale(1.1);
}

.btn-present {
    background: #E8F5E9;
    color: var(--success);
}

.btn-late {
    background: #FFF8E1;
    color: var(--warning);
}

.btn-absent {
    background: #FFEBEE;
    color: var(--danger);
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .header-container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .school-identity {
        flex-direction: column;
        gap: 5px;
    }

    body {
        padding-top: 180px;
        /* More space for stacked header */
    }

    .form-container {
        padding: 20px 15px;
        width: 100%;
        border-radius: 0;
        /* Full bleed on small mobile */
    }

    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .form-divider {
        grid-column: 1;
    }

    .nav-btn span.icon {
        display: none;
    }
}


/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-top: 5px solid var(--primary);
}

.modal-header h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

.modal-body p {
    margin-bottom: 10px;
    color: #555;
    line-height: 1.5;
}

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

.btn-secondary {
    background: #eee;
    color: #666;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}


.item-full {
    grid-column: 1 / -1;
}

/* Filter Buttons for Attendance */
.shift-filters {
    display: flex;
    gap: 10px;
}

.btn-filter {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-filter.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.course-header-row {
    background: #e0e0e0;
    padding: 12px;
    margin-top: 25px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-weight: 700;
    color: #333;
    font-size: 1.1rem;
    border-left: 5px solid var(--primary);
}

/* Birthday Highlight */
.birthday-highlight {
    background-color: #fff3e0 !important;
    /* Naranja muy clarito */
    border-left-color: #ff9800 !important;
    position: relative;
}

.birthday-highlight::after {
    content: "🎂";
    position: absolute;
    right: 15px;
    font-size: 1.2rem;
}

/* New: Round student photos - BIGGER per user request */
.student-photo {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid #ddd;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.photo-cell {
    width: 200px;
    height: 200px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    margin-right: 25px !important;
    /* Force margin override */
}


/* --- MODULE: GRADES (Notas v25 RECOVERY) --- */
.grades-table-container {
    overflow-x: auto;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    background: white;
}

table.grades-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
}

table.grades-table th {
    background-color: #212121;
    color: white;
    padding: 12px 8px;
    font-size: 0.85rem;
    text-align: center;
    border-right: 1px solid #424242;
    white-space: nowrap;
}

table.grades-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
    text-align: center;
    vertical-align: middle;
    background: white;
}

/* Zebra Striping */
table.grades-table tr:nth-child(even) td {
    background-color: #fafafa;
}

/* Input Fields in Grades */
.grade-input {
    width: 50px;
    padding: 8px 0;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.2s;
    background: #fff;
}

.grade-input:focus {
    border-color: #ff6600;
    background-color: #fff3e0;
    outline: none;
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Invalid Grade Red Highlight */
.grade-input.invalid-grade {
    border-color: #d32f2f;
    background-color: #ffebee;
    color: #d32f2f;
}

/* Special Columns */
.col-def {
    background-color: #e3f2fd !important;
    /* Light Blue */
    font-weight: bold;
    color: #0d47a1;
}

.col-performance {
    font-weight: bold;
}

.col-performance[data-val="BAJO"] {
    color: #d32f2f;
}

.col-performance[data-val="BÁSICO"] {
    color: #f57c00;
}

.col-performance[data-val="ALTO"] {
    color: #388e3c;
}

.col-performance[data-val="SUPERIOR"] {
    color: #1976d2;
}

.col-student-name {
    text-align: left !important;
    font-weight: 600;
    color: #333;
    padding-left: 15px !important;
    min-width: 250px;
}