/* ==========================================================================
   EDU SNECHEESS - PREMIUM DARK GLASSMORPHISM DESIGN SYSTEM
   Complete Rewrite: Responsive, Accessible, Modern
   ========================================================================== */

/* ---------- CSS VARIABLES ---------- */
:root {
    --bg-base: #0a0f1d;
    --bg-card: rgba(22, 33, 52, 0.85);
    --bg-card-hover: rgba(30, 45, 68, 0.75);
    --bg-input: rgba(15, 23, 42, 0.9);
    --bg-header: rgba(10, 15, 29, 0.95);
    --border-light: rgba(255, 255, 255, 0.18);
    --border-focus: rgba(0, 200, 255, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-cyan: #22d3ee;
    --accent-blue: #3b82f6;
    --accent-teal: #14b8a6;
    --accent-green: #10b981;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --accent-purple: #a855f7;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(34,211,238,0.3); }

.scrollbar-thin::-webkit-scrollbar { width: 4px; height: 4px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ---------- GLASSMORPHISM CARDS ---------- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

/* ---------- GLASS INPUT (CRITICAL: Fix white-on-white) ---------- */
.glass-input {
    background: var(--bg-input) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    color: var(--text-primary) !important;
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.glass-input::placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

.glass-input:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(34,211,238,0.1) !important;
    outline: none !important;
}

/* FIX: Select dropdown white-on-white issue */
select.glass-input,
.glass-input select,
select {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    cursor: pointer;
}

select option,
.glass-input option,
select.glass-input option {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    padding: 8px 12px;
}

select option:checked {
    background: #334155 !important;
    color: #22d3ee !important;
}

/* Textarea */
textarea.glass-input,
textarea {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
}

textarea::placeholder {
    color: var(--text-muted) !important;
}

textarea:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(34,211,238,0.1) !important;
    outline: none !important;
}

/* Number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
}

/* ---------- BUTTONS ---------- */
.btn-primary {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #0284c7, #0891b2) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(6,182,212,0.3);
}

.btn-secondary {
    background: rgba(255,255,255,0.05) !important;
    color: var(--text-secondary) !important;
    border: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.1) !important;
    color: var(--text-primary) !important;
    border-color: rgba(255,255,255,0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-danger:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b) !important;
    box-shadow: 0 4px 16px rgba(220,38,38,0.3);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #047857) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-success:hover {
    background: linear-gradient(135deg, #047857, #065f46) !important;
    box-shadow: 0 4px 16px rgba(5,150,105,0.3);
}

.btn-teal {
    background: linear-gradient(135deg, #14b8a6, #0d9488) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-teal:hover {
    background: linear-gradient(135deg, #0d9488, #0f766e) !important;
    box-shadow: 0 4px 16px rgba(20,184,166,0.3);
}

/* ---------- SIDEBAR ---------- */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: left;
    background: none;
    line-height: 1.4;
}

.sidebar-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-item.active {
    color: var(--accent-cyan);
    background: rgba(34,211,238,0.12);
    border-color: rgba(34,211,238,0.4);
    font-weight: 600;
}

.sidebar-item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.sidebar-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Sidebar dropdown items hidden class */
.sidebar-item.hidden {
    display: none;
}

/* ---------- STATUS BADGES ---------- */
.status-validated {
    background: rgba(16,185,129,0.15);
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.25);
    font-size: 0.6875rem;
    padding: 2px 8px;
    border-radius: 50px;
}

.status-pending {
    background: rgba(234,179,8,0.15);
    color: #facc15;
    border: 1px solid rgba(234,179,8,0.25);
    font-size: 0.6875rem;
    padding: 2px 8px;
    border-radius: 50px;
}

.status-hadir {
    background: rgba(16,185,129,0.15);
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.25);
}

.status-alfa {
    background: rgba(239,68,68,0.15);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.25);
}

.status-izin {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
    border: 1px solid rgba(59,130,246,0.25);
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fadeIn { animation: fadeIn 0.35s ease-out forwards; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-slideUp { animation: slideUp 0.4s ease-out forwards; }

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(34,211,238,0.2); }
    50% { box-shadow: 0 0 20px rgba(34,211,238,0.4); }
}

/* Toast Animations */
.toast-enter {
    animation: toastSlideIn 0.3s ease-out forwards;
}
.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}
@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Progress bar */
.progress-bar-mesra {
    transition: width 0.5s ease-out;
    border-radius: 0 4px 4px 0;
}

/* ---------- TABLE RESPONSIVE & PROPORTIONAL CELL FIXES ---------- */
.table-max-w-2xl,
.table-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
}

table th {
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.95);
    z-index: 2;
    white-space: nowrap;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 10px;
}

table td {
    white-space: normal;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    hyphens: manual;
    vertical-align: middle;
    font-size: 0.75rem;
    line-height: 1.45;
    padding: 8px 10px;
}

/* Allow clean wrapping for long content cells without chopping words */
table td.wrap-cell,
table th.wrap-cell {
    white-space: normal;
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

table th, table td {
    padding: 8px 10px;
}

/* ---------- PAGINATION ---------- */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    background: rgba(15,23,42,0.5);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    font-size: 0.8125rem;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.pagination-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.15);
}

.pagination-btn.active {
    background: rgba(34,211,238,0.15);
    color: var(--accent-cyan);
    border-color: rgba(34,211,238,0.3);
}

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

.per-page-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.per-page-select select {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- MOBILE SIDEBAR ---------- */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 49;
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */

/* Tablet and below */
@media (max-width: 1024px) {
    table th, table td {
        padding: 6px 8px;
        font-size: 0.6875rem;
    }

    table th {
        font-size: 0.625rem;
    }

    /* Allow scroll only if truly needed on tablet */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important;
    }

    /* Sidebar: hidden by default on mobile, shown via JS toggle */
    aside {
        position: fixed !important;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    aside.sidebar-mobile-open {
        transform: translateX(0);
    }

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

    table th, table td {
        padding: 5px 6px;
        font-size: 0.625rem;
    }

    table th {
        font-size: 0.5625rem;
    }

    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 8px;
        padding: 12px 16px;
    }

    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .glass-card {
        border-radius: var(--radius-md);
    }

    table th, table td {
        padding: 6px 8px;
        font-size: 0.625rem;
    }
}

/* ---------- REKAP TABLE: Single-line NISN & Nama ---------- */
.cell-nowrap {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-name {
    white-space: nowrap !important;
    min-width: 140px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-nisn {
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums;
    min-width: 90px;
}

/* Compact score columns in rekap */
.cell-score {
    white-space: nowrap !important;
    text-align: center;
    min-width: 45px;
}

/* ---------- MISC UTILITIES ---------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ensure links are visible */
a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Fix checkbox visibility */
input[type="checkbox"] {
    accent-color: var(--accent-cyan);
    width: 16px;
    height: 16px;
}

/* Fix date input on dark theme */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

/* Fix file input */
input[type="file"] {
    color: var(--text-secondary);
}

/* Print styles */
@media print {
    body { background: #fff; color: #000; }
    .glass-card { background: #fff; border: 1px solid #ddd; box-shadow: none; }
}

/* ============================================================
   SMARTPHONE RESPONSIVE UI & PROPORTIONAL HEADER FIXES
   ============================================================ */

/* Clock Pill Header Fix for Mobile */
#header-realtime-clock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 640px) {
    /* Compact Top Header on Mobile */
    header {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        gap: 0.5rem !important;
    }

    header marquee {
        display: none !important;
    }

    /* Date and Time Header Box Mobile Proportion */
    #header-realtime-clock {
        font-size: 0.6875rem !important; /* 11px font */
        letter-spacing: -0.01em;
        white-space: normal !important;
        word-break: break-word;
        text-align: center;
        width: 100%;
    }

    /* Proportional Banner Headers on Smartphone */
    .bg-gradient-to-br.from-blue-600.to-teal-500 {
        padding: 0.875rem 1rem !important; /* ~14px top/bottom, 16px left/right */
        border-radius: 1rem !important;
        gap: 0.75rem !important;
    }

    /* Proportional Banner Titles on Smartphone */
    .bg-gradient-to-br.from-blue-600.to-teal-500 h2 {
        font-size: 1.125rem !important; /* 18px */
        line-height: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    .bg-gradient-to-br.from-blue-600.to-teal-500 p {
        font-size: 0.75rem !important; /* 12px */
        line-height: 1.125rem !important;
    }

    /* Filter Dropdowns Grid Layout on Smartphone */
    .bg-gradient-to-br.from-blue-600.to-teal-500 .flex-wrap {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    /* Full width inputs/selects inside mobile filter grid */
    .bg-gradient-to-br.from-blue-600.to-teal-500 select,
    .bg-gradient-to-br.from-blue-600.to-teal-500 input,
    .bg-gradient-to-br.from-blue-600.to-teal-500 .relative {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.6875rem !important; /* 11px */
        padding: 0.375rem 0.5rem !important;
        border-radius: 0.5rem !important;
        box-sizing: border-box !important;
    }

    /* Action buttons inside filter section on smartphone */
    .bg-gradient-to-br.from-blue-600.to-teal-500 button {
        width: 100% !important;
        font-size: 0.6875rem !important;
        padding: 0.375rem 0.5rem !important;
        justify-content: center !important;
        border-radius: 0.5rem !important;
    }

    /* Make last button span full width if odd count */
    .bg-gradient-to-br.from-blue-600.to-teal-500 .flex-wrap > button:last-child {
        grid-column: span 2 / span 2;
    }

    /* Section Cards & Tables on Smartphone */
    .glass-card {
        padding: 0.875rem 1rem !important;
    }

    .glass-card h3 {
        font-size: 0.9375rem !important; /* 15px */
        margin-bottom: 0.75rem !important;
    }

    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 0.5rem !important;
    }
}

/* ---------- RESPONSIVE MODAL ---------- */
#modal-content {
    transition: max-width 0.3s ease;
}

/* Wide modal responsive adjustments */
#modal-content.max-w-3xl {
    max-width: 48rem; /* 768px */
}

#modal-content.max-w-4xl {
    max-width: 56rem; /* 896px */
}

/* Jurnal Modal body improvements */
.jurnal-modal-body label {
    user-select: none;
}

/* Kehadiran Siswa items - ensure full name visible */
#absen-siswa-container label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

#absen-siswa-container label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Tablet responsive modal */
@media (max-width: 1024px) {
    #modal-content.max-w-3xl {
        max-width: 90vw;
    }
    #modal-content.max-w-4xl {
        max-width: 92vw;
    }
}

/* Mobile responsive modal */
@media (max-width: 768px) {
    #modal-content {
        max-width: 95vw !important;
        padding: 1rem 0.875rem !important;
        border-radius: 1rem !important;
        max-height: 92vh !important;
    }

    /* Stack jurnal modal grids on mobile */
    .jurnal-modal-body .grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Kehadiran container: single column on mobile for full names */
    #absen-siswa-container {
        grid-template-columns: 1fr !important;
        max-height: 200px !important;
    }

    /* Modal title smaller on mobile */
    #modal-content h3 {
        font-size: 1rem !important;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    #modal-content {
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0.875rem 0.75rem !important;
        border-radius: 0.75rem !important;
        max-height: 95vh !important;
    }

    /* Reduce spacing in jurnal modal */
    .jurnal-modal-body {
        gap: 0.625rem !important;
    }

    .jurnal-modal-body input,
    .jurnal-modal-body select,
    .jurnal-modal-body textarea {
        font-size: 0.8125rem !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .jurnal-modal-body button {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        font-size: 0.875rem !important;
    }
}

/* ---------- LINE CLAMP & TEXT TRUNCATION UTILITIES ---------- */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- KEPALA SEKOLAH DASHBOARD & TABLE UTILITIES ---------- */
.table-action-btn-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    flex-wrap: wrap;
}

