/* =========================================
   1. VARIABEL & SETUP DASAR
   ========================================= */
:root {
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --danger-color: #e74a3b;
    --dark-color: #343a40;
    --light-color: #f8f9fc;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* =========================================
   2. LAYOUT UTAMA (WRAPPER & SIDEBAR)
   ========================================= */
#wrapper {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    background: linear-gradient(180deg, var(--dark-color) 10%, #212529 100%);
    min-height: 100vh;
}

.sidebar-heading {
    font-size: 1rem;
}

.sidebar .nav-item .nav-link {
    color: rgba(255, 255, 255, 0.6);
    padding: 1rem;
    font-weight: 500;
}

.sidebar .nav-item .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-item .nav-link.active {
    color: #fff;
    background-color: var(--primary-color);
}

/* RESPONSIF SIDEBAR (MOBILE) */
@media (max-width: 991.98px) {
    #wrapper {
        position: relative;
        overflow-x: hidden;
    }
    
    #sidebar-wrapper {
        position: fixed;
        left: -260px; /* Sembunyikan default */
        width: 260px;
        height: 100vh;
        transition: left 0.3s ease-in-out;
        z-index: 1050;
    }

    /* Saat tombol toggle diklik (class 'toggled' ditambahkan) */
    #wrapper.toggled #sidebar-wrapper {
        left: 0;
    }
    
    /* Content Wrapper saat sidebar mobile */
    #content-wrapper {
        width: 100%;
    }
}

/* =========================================
   3. KOMPONEN KARTU & TABEL
   ========================================= */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.15rem 1.25rem 0 rgba(58, 59, 69, 0.1);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e3e6f0;
    font-weight: 600;
}

/* Card Border Accent */
.border-left-primary { border-left: 0.25rem solid var(--primary-color) !important; }
.border-left-success { border-left: 0.25rem solid var(--success-color) !important; }
.border-left-info { border-left: 0.25rem solid #36b9cc !important; }
.border-left-warning { border-left: 0.25rem solid #f6c23e !important; }
.border-left-danger { border-left: 0.25rem solid var(--danger-color) !important; }

/* Tabel */
.table-responsive {
    overflow-x: auto;
}

.thead-light th {
    color: #757575;
    background-color: #f8f9fc;
    border-color: #e3e6f0;
    font-size: 0.85rem;
    text-transform: uppercase;
}

/* =========================================
   4. TOMBOL & FORM
   ========================================= */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
}

.form-control:focus, .form-select:focus {
    border-color: #bac8f3;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

/* =========================================
   5. KOMPONEN CUSTOM (AVATAR, TOAST, DLL)
   ========================================= */

/* Avatar Bulat */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
    color: #fff;
}

.avatar-circle-sm {
    width: 35px;
    height: 35px;
    font-size: 0.8rem;
}

/* Ujian Card Hover */
.card-uji-item { 
    transition: transform 0.2s; 
    border-left: 4px solid transparent; 
} 
.card-uji-item:hover { 
    transform: translateY(-5px); 
    border-left-color: var(--primary-color); 
} 
.btn-kelola-uji { 
    transition: all 0.3s; 
} 
.btn-kelola-uji:hover { 
    transform: scale(1.02); 
    box-shadow: 0 4px 15px rgba(78, 115, 223, 0.3); 
}

/* =========================================
   6. TOAST NOTIFICATION SYSTEM
   ========================================= */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-custom {
    width: 350px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    overflow: hidden;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-custom.show {
    transform: translateX(0%);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    padding: 15px;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 35px;
    width: 35px;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    margin-right: 15px;
    flex-shrink: 0;
}

.toast-message {
    flex-grow: 1;
}
.toast-message strong {
    font-size: 14px;
    color: #333;
    display: block;
    margin-bottom: 2px;
    font-family: 'Poppins', sans-serif;
}
.toast-message p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.toast-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #aaa;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.2s;
}
.toast-close:hover { color: #333; }

.toast-progress {
    height: 3px;
    width: 100%;
    position: relative;
    bottom: 0;
    left: 0;
}

.toast-custom.show .toast-progress::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    height: 100%;
    width: 100%;
    animation: progress 5s linear forwards;
}

/* Warna Toast */
.toast-custom.success .toast-icon { background: linear-gradient(to right, #11998e, #38ef7d); }
.toast-custom.success .toast-progress::before { background: #38ef7d; }

.toast-custom.error .toast-icon { background: linear-gradient(to right, #cb2d3e, #ef473a); }
.toast-custom.error .toast-progress::before { background: #ef473a; }

.toast-custom.warning .toast-icon { background: linear-gradient(to right, #f7971e, #ffd200); }
.toast-custom.warning .toast-progress::before { background: #ffd200; }

.toast-custom.info .toast-icon { background: linear-gradient(to right, #4facfe, #00f2fe); }
.toast-custom.info .toast-progress::before { background: #00f2fe; }

@keyframes progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Responsif Toast */
@media (max-width: 480px) {
    #toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }
    .toast-custom {
        width: 100%;
    }
}

/* Jawaban Terpilih */
.option-item.selected {
    border-color: #4e73df;
    background-color: #e3f2fd;
}

/* Hover effect */
.option-item:hover {
    background-color: #f8f9fc;
    border-color: #4e73df;
}

/* =========================================
   7. HALAMAN KERJAKAN UJIAN (FIXED)
   ========================================= */

/* Background Body Khusus Ujian */
body#page-top {
    background-color: #f0f2f5;
}

/* Timer */
.timer-box {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--success-color) 0%, #27ae60 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    z-index: 1050;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.timer-box.warning {
    background: linear-gradient(135deg, var(--danger-color) 0%, #c0392b 100%);
}

/* Layout Konten Ujian */
.quiz-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 80px;
    padding-bottom: 100px;
}

/* Kartu Soal - PENTING: Jangan ada display:none di sini */
.question-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    /* Default display diatur via PHP/Inline style, bukan di sini agar tidak bentrok */
}

/* Navigasi Soal (Bottom Bar) */
.nav-soal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1040;
    display: flex;
    flex-direction: column;
}

.nav-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 10px;
    max-height: 100px;
    overflow-y: auto;
}

.nav-numbers .btn {
    width: 40px;
    height: 40px;
    padding: 0;
    font-weight: bold;
}

.btn-nav {
    background-color: #e9ecef;
    color: var(--secondary-color);
    border-color: #dee2e6;
}

.btn-nav.answered {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* Opsi Jawaban Pilihan Ganda */
.option-item {
    display: block;
    margin-bottom: 10px;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.option-item:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
}

.option-item.selected {
    background-color: #e8f4ff;
    border-color: var(--primary-color);
    font-weight: bold;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

/* =========================================
   8. KOMPONEN SOAL DERET / ANGKA (MODERN)
   ========================================= */

/* Container Utama Deret - Diubah ke GRID agar Responsif */
.sequence-container {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    border: 1px solid #e0e0e0;
    border-radius: 15px;
    padding: 30px;
    margin: 25px 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    
    /* PERUBAHAN: Gunakan Grid agar item tidak keluar dari layar */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 15px; /* Jarak antar item */
    justify-items: center; /* Pusatkan item horizontal */
}

/* Satu Kotak Item */
.sequence-item {
    width: 70px;
    height: 70px;
    display: flex !important; /* Paksa tampil */
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sequence-item:hover {
    transform: translateY(-3px);
}

/* Kotak Jawaban (Kotak Kosong) */
.sequence-item.answer-box {
    border: 2px dashed #4e73df;
    background-color: #f8f9ff;
    color: #4e73df;
}

/* State Terisi */
.sequence-item.filled {
    border-style: solid;
    background-color: #e8f4ff;
    color: #333;
}

/* State Benar (Hijau) */
.sequence-item.correct {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

/* State Salah (Merah) */
.sequence-item.wrong {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

/* Tombol Pilihan Deret */
.pilihan-deret-btn {
    min-width: 60px;
    padding: 10px 20px;
    margin: 5px;
    font-weight: bold;
    font-size: 1.1rem;
    border-radius: 50px;
    transition: all 0.2s;
}
.pilihan-deret-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(78, 115, 223, 0.3);
}

/* Animasi */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   9. FIX: DROPDOWN MENU (TOMBOL 3 TITIK)
   ========================================= */

/* Pastikan container kartu tidak memotong menu */
.card {
    overflow: visible !important;
}

/* Styling Tombol 3 Titik */
.btn-icon {
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn-icon:hover {
    background-color: #e9ecef; /* Abu-abu saat hover */
}

/* Styling Menu Dropdown (Pop-up) */
.dropdown-menu {
    position: absolute !important; /* Posisi mutlak */
    z-index: 9999 !important;      /* Paling atas */
    background-color: #ffffff;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 0.55rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.175);
    padding: 0.5rem 0;
    min-width: 10rem;
    display: none; /* Default tersembunyi, Bootstrap JS yang akan mengatur display:block */
    right: 0; /* Muncul di kanan */
    left: auto;
}

/* Styling Item di dalam Dropdown */
.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    clear: both;
    font-weight: 400;
    color: #212529;
    text-align: inherit;
    text-decoration: none;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}

.dropdown-item:hover, .dropdown-item:focus {
    color: #1e2125;
    background-color: #e9ecef;
}

.dropdown-item.active, .dropdown-item:active {
    color: #fff;
    text-decoration: none;
    background-color: #4e73df; /* Warna primary */
}

.dropdown-item.disabled, .dropdown-item:disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
}

/* Pembatas dalam dropdown */
.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #e3e6f0;
}

/* Style khusus teks Hapus Merah */
.dropdown-item.text-danger {
    color: #e74a3b !important;
}
.dropdown-item.text-danger:hover {
    background-color: #fbebec;
    color: #d52a1a !important;
}

/* Responsif Mobile */
@media (max-width: 768px) {
    .nav-soal { padding: 10px; }
    .nav-numbers { max-height: 80px; }
    .nav-numbers .btn { width: 35px; height: 35px; font-size: 0.8rem; }
    
    /* Penyesuaian ukuran item deret di mobile */
    .sequence-item { width: 50px; height: 50px; font-size: 1.2rem; }
    .sequence-container { 
        padding: 15px; 
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr)); /* Lebih kecil di mobile */
        gap: 10px; 
    }
}