/* ==========================================================================
   SISTEM WARNA DINAMIS SAKLAR GELAP/TERANG (HANYA VARIABEL)
   ========================================================================== */
:root {
    --bg-main: #f8fafc; 
    --bg-card: #ffffff; 
    --bg-nav: #ffffff; 
    --accent-glow: #0c9cea; 
    --accent-gradient: linear-gradient(135deg, #1e40af, #06b6d4); 
    --text-primary: #1e293b; 
    --text-secondary: #64748b; 
    --border-color: #e2e8f0; 
}

/* --- SAKLAR KELAS JAVASCRIPT: MODE GELAP (DARK THEME) --- */
body.dark-theme {
    --bg-main: #0f172a;       /* Latar belakang malam pekat */
    --bg-card: #1e293b;       /* Kartu kuis menjadi abu gelap */
    --bg-nav: #0f172a;        /* Navbar menjadi abu gelap */
    --text-primary: #f8fafc;   /* Teks utama menjadi putih bersih */
    --text-secondary: #94a3b8; /* Teks deskripsi abu lembut */
    --border-color: #334155;   /* Pembatas garis gelap */
}

/* ==========================================================================
   PERBAIKAN TERAKHIR: ADAPTASI WARNA RAPOR & QUIZ DI DARKMODE
   ========================================================================== */

/* 1. SINKRONISASI ELEMEN TABEL RAPOR (profile.html) */
body.dark-theme #tabelRiwayatBody tr {
    border-bottom: 1px solid var(--border-color);
}

body.dark-theme #tabelRiwayatBody tr:hover {
    background: rgba(255, 255, 255, 0.05) !important; /* Efek hover gelap yang lembut */
}

body.dark-theme table thead tr {
    background: #1e293b !important; /* Mengubah kepala tabel menjadi abu gelap pekat */
}

body.dark-theme table thead th {
    color: var(--text-primary) !important; /* Memastikan teks judul tabel tetap putih */
}

/* 2. SINKRONISASI LEMBAR SOAL & ASIDE SIDEBAR (quiz.html) */
body.dark-theme main.main-card,
body.dark-theme aside.main-card {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Mengubah warna teks input, opsi pilihan ganda, atau teks soal agar tidak buram di mode malam */
body.dark-theme .question-text,
body.dark-theme .option-label,
body.dark-theme h2 {
    color: var(--text-primary) !important;
}

/* Otomatis aktifkan juga jika device/HP siswa disetel ke mode gelap dari sistem */
/* --- OTOMATIS MENGIKUTI TEMA SISTEM BAWAAN HP --- */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        --bg-main: #0f172a;
        --bg-card: #1e293b;
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --border-color: #334155;
    }

    body:not(.light-theme) #tabelRiwayatBody tr:hover {
        background: rgba(255, 255, 255, 0.05) !important;
    }
    body:not(.light-theme) table thead tr {
        background: #1e293b !important;
    }
    body:not(.light-theme) table thead th {
        color: var(--text-primary) !important;
    }
    body:not(.light-theme) main.main-card,
    body:not(.light-theme) aside.main-card {
        background-color: var(--bg-card) !important;
        color: var(--text-primary) !important;
        border-color: var(--border-color) !important;
    }
}

/* Tombol Sakelar Kustom yang Berada di Bawah dekat Copyright */
.footer-toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    margin: 15px auto;
    display: block;
    transition: all 0.2s ease;
}
.footer-toggle-btn:hover {
    transform: translateY(-1px);
    border-color: #06b6d4;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease; /* Transisi warna halus saat ganti tema */
}

/* ==========================================================================
   BAR ATAS (OPTIMAL UNTUK PC)
   ========================================================================== */
.top-navbar {
    width: 100%;
    min-height: 70px;
    max-height: 10%;
    background: var(--bg-nav); /* GANTI INI: Agar otomatis mengikuti tema terang/gelap */
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 30px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    transition: background 0.3s ease, border-color 0.3s ease; /* Transisi halus */
}

.nav-logo-area {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.nav-logo-icon img {
    display: block;
    width: auto;
    height: 80px; /* Diperkecil dari 100px agar proporsional dengan tinggi navbar 70px */
    object-fit: contain;
}

.nav-menu ul {
    display: flex;
    gap: 24px;
    list-style: none;
}

.nav-menu ul li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-menu ul li a:hover {
    color: var(--text-primary);
}

.active-nav {
    color: #1e40af !important;
    font-weight: 600 !important;
}

/* ==========================================================================
   TAMPILAN SATU TINGKAT SUPER KETAT KHUSUS HP (MAX-WIDTH: 600px)
   ========================================================================== */
@media (max-width: 600px) {
    .top-navbar {
        display: flex !important;
        flex-direction: row !important; /* MEMAKSA tetap kiri-kanan, anti dua tingkat */
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 12px !important; /* Memperkecil padding kiri-kanan */
        min-height: 60px !important;
        max-height: 65px !important;
        overflow: hidden !important;
        gap: 12px;
        text-align: center;
    }

    .nav-logo-area {
        display: flex !important;
        align-items: center !important;
        flex: 0 0 auto !important; /* Mengunci ukuran logo agar tidak memakan ruang menu */
        max-width: 35% !important; /* Logo maksimal hanya boleh memakai 35% lebar layar */
    }

    .nav-logo-icon img {
        height: 70px !important; /* Mengecilkan logo lebih ramping lagi */
        width: auto !important;
    }

    .nav-menu {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex: 1 1 auto !important;
        max-width: 65% !important; /* Sisa 65% ruang layar sepenuhnya untuk menu */
        overflow-x: auto !important; /* PENGAMAN: Jika layar terlalu sempit, menu bisa di-swipe geser kanan-kiri, anti turun bawah */
        scrollbar-width: none; /* Menghilangkan scrollbar di Firefox */
    }

    /* Menghilangkan scrollbar di Chrome/Safari agar tetap estetik */
    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-menu ul {
        display: flex !important;
        flex-direction: row !important; /* MEMAKSA menu berbarir horizontal */
        gap: 12px !important; /* Jarak antar-menu dipersempit */
        padding-left: 10px !important;
        justify-content: center;
    }

    .nav-menu ul li a {
        font-size: 12px !important; /* Mengecilkan ukuran teks agar muat sebaris */
        padding: 4px 0 !important;
    }

    /* Menyesuaikan kembali jarak atas konten utama */
    .hero-section,
    .login-wrapper {
        margin-top: 100px !important;
    }

    #copyright {
        font-size: 10px !important;
    }
}
/* ==========================================================================
   KOMPONEN TOMBOL & KARTU UTAMA
   ========================================================================== */
.main-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 35px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.03);
}

.btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 112, 211, 0.25);
}

.btn-primary:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: #94a3b8;
    background-color: var(--bg-main);
}

@media (max-width: 600px) {
    .btn-kelas {
        font-size: 9px;
    }
}

body.dark-theme .btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.status-badge {
    display: inline-block;
    background: rgba(12, 153, 234, 0.1);
    color: var(--accent-glow);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(12, 138, 234, 0.2);
}

/* ==========================================================================
   HALAMAN BERANDA (INDEX)
   ========================================================================== */
.hero-section {
    width: 100%;
    max-width: 1100px;
    margin: 120px auto 40px auto;
    padding: 0 20px;
    text-align: center;
}

.hero-content h1 {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 15px 0 20px 0;
}

.hero-content h1 span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto 30px auto;
}

.hero-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.landing-container {
    width: 100%;
    max-width: 1100px;
    padding: 0 20px;
    margin-bottom: 60px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 60px;
    text-align: center;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
}

.stat-card h3 {
    font-size: 28px;
    font-weight: 700;
    color: #06b6d4;
    margin-bottom: 5px;
}

.stat-card p {
    color: var(--text-secondary);
    font-size: 14px;
}

.section-header {
    text-align: center;
    margin-bottom: 35px;
}

.section-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

.feature-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    margin-bottom: 20px;
}

.feature-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
    flex-grow: 1;
}

.feature-link {
    color: #06b6d4;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

/* ==========================================================================
   HALAMAN MASUK (LOGIN)
   ========================================================================== */
.login-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 140px auto 40px auto;
    padding: 0 20px;
}

.login-card {
    padding: 40px !important;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    background-color: var(--bg-main);
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus {
    border-color: #06b6d4;
    background-color: var(--bg-main);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

/* Pastikan input tetap gelap di dark mode meski di-autofill browser */
body.dark-theme .form-group input:-webkit-autofill,
body.dark-theme .form-group input:-webkit-autofill:hover,
body.dark-theme .form-group input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-main) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
}

.remember-me-container {
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input {
    accent-color: #06b6d4;
    width: 16px;
    height: 16px;
}

.form-link {
    color: var(--text-secondary);
    font-weight: bold;
    text-decoration: none;
}

@media (min-width: 768px) {
    .form-link {
        font-size: 13px;
        margin-left: 115px;
    }
}

.form-link:hover, .form-link-highlight:hover {
    color: #0689a0;
}

.form-link-highlight {
    color: #0aa1bb;
    text-decoration: none;
    font-weight: 600;
}

.btn-block {
    width: 100%;
    padding: 14px !important;
    font-size: 15px;
}

.login-footer {
    margin-top: 25px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINT (HP / MOBILE SCREEN)
   ========================================================================== */
@media (max-width: 768px) {
    .features-grid, .stats-grid {
        grid-template-columns: 1fr;
    }
    .hero-content h1 {
        font-size: 32px;
    }
    .hero-buttons {
        flex-direction: column;
    }
}

/* ==========================================================================
   PERBAIKAN TOTAL MODAL KUSTOM (MELAYANG DI TENGAH LAYAR)
   ========================================================================== */
.modal-overlay {
    position: fixed; /* Membuat modal melayang di atas semua elemen */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6); /* Efek gelap di belakang modal */
    backdrop-filter: blur(4px);
    z-index: 9999; /* Memastikan modal berada di paling depan */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Class ini akan dipicu oleh JavaScript untuk memunculkan modal */
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-card, #ffffff);
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    padding: 30px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-box {
    transform: translateY(0);
}

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    margin: 0 auto 20px auto;
    font-weight: bold;
}

.modal-icon.warning {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger, #ef4444);
}

.modal-icon.info {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success, #10b981);
}

.modal-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.modal-body-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 25px;
}

/* ==========================================================================
   STYLE KHUSUS INDIKATOR LOADING PADA TOMBOL LOGIN
   ========================================================================== */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Animasi Spinner Putar di Dalam Tombol */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: putarSaja 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes putarSaja {
    to { transform: rotate(360deg); }
}

/* Penyelarasan Grid untuk Halaman 13 Pelajaran */
#quiz-subjects-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
}

.subject-card {
    cursor: pointer;
    transition: all 0.25s ease !important;
}

.subject-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 20px 30px -10px rgba(6, 182, 212, 0.15) !important;
    border-color: #06b6d4 !important;
}

.score-circle-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 30px auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.score-text-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Kunci mati posisi teks tepat di tengah-tengah bundaran */
    text-align: center;
    width: 100%;
}

#tabelRiwayatBody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

#tabelRiwayatBody tr:hover {
    background: #f8fafc;
}

#tabelRiwayatBody td {
    padding: 14px 15px;
    vertical-align: middle;
}

#tabelRiwayatBody th {
    padding: 12px 15px;
}

.bold {
    font-weight: 600;
}

.italic {
    font-style: italic;
}