/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary: #0f4c75;    /* Biru Tua Profesional */
    --secondary: #3282b8;  /* Biru Sedang */
    --accent: #bbe1fa;     /* Biru Muda Lembut */
    --white: #ffffff;
    --bg-light: #f4f6f9;
    --text-dark: #333;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --border-color: #ddd;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body { background-color: var(--bg-light); display: flex; height: 100vh; overflow: hidden; }

/* =========================================
   2. LAYOUT (SIDEBAR & MAIN)
   ========================================= */
/* Sidebar */
.sidebar { width: 250px; background: var(--primary); color: var(--white); display: flex; flex-direction: column; transition: 0.3s; z-index: 100; }
.sidebar-header { padding: 20px; text-align: center; font-weight: bold; font-size: 1.2rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.nav-links { list-style: none; padding: 20px 0; }
.nav-links li a { display: block; padding: 15px 25px; color: var(--accent); text-decoration: none; transition: 0.3s; }
.nav-links li a:hover, .nav-links li a.active { background: rgba(255,255,255,0.1); color: var(--white); border-left: 4px solid var(--secondary); }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

/* Topbar */
.topbar { background: var(--white); padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.user-info { font-weight: 600; color: var(--primary); }

/* Content Area */
.content { padding: 20px; overflow-y: auto; flex: 1; }
.card { background: var(--white); padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); margin-bottom: 20px; }

/* =========================================
   3. COMPONENTS (FORMS, BUTTONS, MODAL)
   ========================================= */
/* Forms */
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; color: var(--text-dark); font-weight: 500; }
select, input[type="date"], input[type="number"], input[type="text"] { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 5px; outline: none; transition: 0.3s; }
select:focus, input:focus { border-color: var(--secondary); }

/* Buttons */
.btn { padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; color: var(--white); font-weight: 500; text-decoration: none; display: inline-block; font-size: 14px; transition: 0.2s;}
.btn-primary { background: var(--secondary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 3px; }

/* Modal (Pop-up) */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
.modal-content { background-color: #fff; padding: 25px; border-radius: 8px; width: 400px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); position: relative; animation: slideDown 0.3s ease; }
@keyframes slideDown { from {transform: translateY(-50px); opacity: 0;} to {transform: translateY(0); opacity: 1;} }
.close-btn { position: absolute; top: 10px; right: 15px; font-size: 24px; font-weight: bold; color: #aaa; cursor: pointer; }
.close-btn:hover { color: #000; }
.modal-header { font-size: 18px; font-weight: bold; margin-bottom: 15px; color: #0f4c75; border-bottom: 1px solid #eee; padding-bottom: 10px;}

/* =========================================
   4. FEATURE: ABSENSI (PAPER STYLE)
   ========================================= */
.table-responsive { overflow-x: auto; }

.paper-table { width: 100%; border-collapse: collapse; background-color: #fff; color: #000; font-size: 14px; margin-top: 15px; }
.paper-table th { background-color: #e0e0e0; border: 1px solid #000; padding: 10px; text-align: center; font-weight: bold; }
.paper-table td { border: 1px solid #000; padding: 8px; vertical-align: middle; }
.paper-table tr:nth-child(even) { background-color: #f9f9f9; }
.paper-table tr:hover { background-color: #eef7ff; }

/* Kolom Absensi */
.col-no { width: 40px; text-align: center; }
.col-nis { width: 100px; text-align: center; }
.col-nama { text-align: left; padding-left: 10px; }
.col-absen { width: 250px; text-align: center; }

/* Radio Button Custom */
.radio-options { display: flex; justify-content: center; gap: 20px; font-weight: bold; }
.radio-item { cursor: pointer; display: flex; align-items: center; gap: 5px; }
.radio-item input[type="radio"] { transform: scale(1.3); accent-color: #0f4c75; }

/* =========================================
   5. FEATURE: NILAI (EXCEL PRO STYLE)
   ========================================= */
.table-container-scroll {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid #ccc;
    height: 75vh; /* Tinggi tabel maksimal */
    position: relative;
    background: #fff;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.excel-table {
    min-width: 100%;
    border-collapse: separate; /* PENTING untuk sticky */
    border-spacing: 0;
    font-size: 14px;
}

.excel-table th, .excel-table td {
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 0;
    height: 40px;
    vertical-align: middle;
}

/* Header Excel */
.excel-table th {
    background-color: #f8f9fa;
    color: #333;
    font-weight: 600;
    text-align: center;
    padding: 5px;
    position: sticky;
    top: 0;
    z-index: 10; /* Z-Index header standard */
    box-shadow: 0 2px 2px rgba(0,0,0,0.1);
}

/* Input Excel */
.excel-input {
    width: 100%; height: 100%;
    border: none; text-align: center;
    font-size: 14px; background: transparent; outline: none;
    transition: 0.2s; font-family: 'Consolas', monospace;
}
.excel-input:focus { background-color: #e6f7ff; box-shadow: inset 0 0 0 2px #1890ff; font-weight: bold; }

/* Highlight Baris Aktif */
.tr-active { background-color: #fffbe6 !important; }
.tr-active td { border-bottom: 1px solid #faad14; }
.tr-active .col-fix { background-color: #fffbe6 !important; }

/* Sticky Columns (Kolom Beku di Kiri) */
.col-fix {
    position: sticky;
    z-index: 5; /* Di atas sel biasa */
    background-color: #fff;
    border-right: 2px solid #ccc !important;
}
th.col-fix { z-index: 15; background-color: #f0f0f0; top: 0; } /* Header sticky paling atas */

/* Lebar & Posisi Desktop */
.fix-no { left: 0; width: 40px; text-align: center; }
.fix-nis { left: 40px; width: 100px; text-align: center; }
.fix-nama { left: 140px; width: 220px; text-align: left; padding-left: 8px !important; }

/* Tombol Hapus Kolom */
.del-col-btn { color: #ff4d4f; cursor: pointer; font-size: 10px; opacity: 0.4; margin-left:5px; }
th:hover .del-col-btn { opacity: 1; }

/* =========================================
   6. UTILITIES & RESPONSIVE
   ========================================= */
.hidden { display: none; }
.flex-row { display: flex; gap: 15px; align-items: end; flex-wrap: wrap; }

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar { position: absolute; left: -250px; height: 100%; }
    .sidebar.active { left: 0; } /* Logic toggle sidebar di JS jika diperlukan nanti */
    
    .top-grid { grid-template-columns: 1fr; }
    
    /* Excel Table Mobile Tweak */
    .fix-no, .fix-nis { display: none; } /* Sembunyikan No & NIS */
    .fix-nama {
        left: 0 !important;
        width: 160px !important;
        font-size: 12px;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        border-right: 2px solid #999 !important;
    }
    .excel-input { font-size: 16px; } /* Font besar utk jari */
    .excel-table th { font-size: 12px; padding: 2px; }
}

/* Print Styling */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .card { box-shadow: none; border: none; padding: 0; margin: 0; }
    .main-content { margin: 0; padding: 0; }
    body { background-color: #fff; height: auto; overflow: visible; }
    .table-container-scroll { height: auto; overflow: visible; border: none; }
    .col-fix { position: static; border: 1px solid #000 !important; }
}
/* --- MOBILE NAVIGATION & HAMBURGER MENU --- */

/* Tombol Menu (Default sembunyi di Desktop) */
.hamburger {
    display: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--primary);
    margin-right: 15px;
    line-height: 1;
}

/* Overlay (Layar gelap saat menu terbuka) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99; /* Di bawah sidebar, di atas konten */
    backdrop-filter: blur(2px); /* Efek blur estetik */
}

/* RESPONSIVE LOGIC */
@media (max-width: 768px) {
    /* 1. Munculkan Tombol Menu */
    .hamburger { display: block; }

    /* 2. Sidebar Sembunyi & Fixed */
    .sidebar {
        position: fixed;
        left: -260px; /* Sembunyi di kiri */
        top: 0;
        height: 100vh;
        z-index: 100; /* Paling atas */
        box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    }

    /* 3. Class untuk Memunculkan Sidebar */
    .sidebar.active {
        left: 0;
    }

    /* 4. Tampilkan Overlay saat menu aktif */
    .sidebar-overlay.active {
        display: block;
    }

    /* Penyesuaian Topbar di HP */
    .topbar {
        padding: 10px 15px;
        position: sticky; /* Topbar nempel di atas */
        top: 0;
        z-index: 50;
    }
}
/* =========================================
   SUPER EXCEL TABLE (FIXED LAYOUT & RESPONSIVE)
   ========================================= */

/* Container Utama */
.grade-wrapper {
    position: relative;
    width: 100%;
    height: 75vh;
    overflow: auto; /* Scroll 2 arah */
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.grade-table {
    border-collapse: separate; /* Wajib separate utk sticky */
    border-spacing: 0;
    /* PENTING: table-layout fixed agar browser tidak menebak-nebak lebar */
    table-layout: fixed; 
    width: max-content; /* Lebar tabel mengikuti jumlah kolom */
    min-width: 100%;
    font-size: 14px;
}

.grade-table th, .grade-table td {
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 0;
    height: 40px;
    vertical-align: middle;
    box-sizing: border-box;
    background-color: #fff; /* Pastikan background putih agar tidak transparan */
}

/* --- LOGIKA STICKY (DESKTOP) --- */

/* 1. Header Sticky (Judul Kolom) */
.grade-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f4f6f9;
    color: #333;
    font-weight: 600;
    text-align: center;
    border-top: 1px solid #ddd;
}

/* 2. Kolom Sticky Kiri (Identitas Siswa) */
.sticky-col {
    position: sticky;
    left: 0; /* Default, nanti di-override per kolom */
    z-index: 5;
    background: #fff; /* Wajib solid color */
    border-right: 2px solid #ccc !important; /* Batas pemisah tegas */
}

/* 3. Header Sudut Kiri Atas (Pertemuan Header & Sticky Col) */
.grade-table thead th.sticky-col {
    z-index: 20; /* Paling atas */
    background: #e9ecef;
}

/* --- PENGATURAN LEBAR & POSISI DESKTOP (PRESISI PIXEL) --- */

/* Kolom 1: No */
.col-no {
    left: 0;
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    text-align: center;
}

/* Kolom 2: NIS */
.col-nis {
    left: 50px; /* Sesuai lebar kolom No */
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    text-align: center;
}

/* Kolom 3: Nama Siswa */
.col-nama {
    left: 150px; /* 50px (No) + 100px (NIS) = 150px */
    width: 300px; /* Lebar diperbesar agar nama panjang muat */
    min-width: 300px;
    max-width: 300px;
    text-align: left;
    padding-left: 10px !important;
}

/* Kolom Nilai (TP1, dst) */
.grade-table th:not(.sticky-col), 
.grade-table td:not(.sticky-col) {
    width: 80px;  /* Lebar standar kolom nilai */
    min-width: 80px;
}

/* Input Nilai */
.grade-input {
    width: 100%; height: 100%;
    border: none; text-align: center;
    background: transparent; outline: none;
    font-family: 'Consolas', monospace; font-size: 14px;
}
.grade-input:focus {
    background: #e6f7ff;
    box-shadow: inset 0 0 0 2px #1890ff;
    font-weight: bold;
}

/* Highlight Baris */
.tr-hover:hover td { background-color: #f8f9fa; }
.tr-active td { background-color: #fffbe6 !important; }
/* Pastikan sticky col juga ikut berubah warna saat highlight */
.tr-active .sticky-col { background-color: #fffbe6 !important; }

/* Tombol Hapus Kolom */
.del-col { color: #dc3545; font-size: 10px; cursor: pointer; margin-left: 5px; opacity: 0.3; }
th:hover .del-col { opacity: 1; }


/* --- MOBILE RESPONSIVE (HP) --- */
@media (max-width: 768px) {
    /* Sembunyikan No & NIS di HP */
    .col-no, .col-nis { display: none !important; }

    /* Reset posisi Nama Siswa jadi paling kiri (0px) */
    .col-nama {
        left: 0 !important;
        width: 150px !important; /* Perkecil lebar di HP */
        min-width: 150px !important;
        max-width: 150px !important;
        font-size: 12px;
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis;
        border-right: 2px solid #999 !important;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1); 
    }

    /* Input lebih besar untuk jari */
    .grade-input { font-size: 16px; }
    
    /* Header lebih tipis */
    .grade-table th { font-size: 12px; padding: 2px; height: 35px; }
    
    /* Kolom Nilai di HP lebih kecil dikit biar muat banyak */
    .grade-table th:not(.sticky-col), 
    .grade-table td:not(.sticky-col) {
        width: 70px;
        min-width: 70px;
    }
}
/* --- STYLE LOGO SEKOLAH (SIDEBAR) --- */
.logo-container {
    text-align: center;
    padding-bottom: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.school-logo {
    width: 80px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
    transition: transform 0.3s;
}

.school-logo:hover {
    transform: scale(1.05); /* Efek zoom sedikit saat dihover */
}

.sidebar-header {
    padding-top: 25px; /* Beri jarak atas lebih lega */
}