:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --danger: #EF4444;
    --dark: #1F2937;
    --light: #F3F4F6;
    --text-main: #111827;
    --text-muted: #6B7280;
    --bg-main: #EEF2F6;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
}

/* Background specifically for login */
.login-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 40px 30px;
    text-align: center;
    transition: transform 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-5px);
}

.glass-panel h2 {
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--dark);
}

.glass-panel p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 12px 24px;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 8px;
    transition: all 0.3s;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    color: #fff;
    background-color: var(--secondary);
    border-color: var(--secondary);
}
.btn-danger {
    color: #fff;
    background-color: var(--danger);
}

.btn-block {
    display: block;
    width: 100%;
}

.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #F87171;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #34D399;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: #fff;
    border-right: 1px solid #E5E7EB;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0 20px 20px;
    border-bottom: 1px solid #E5E7EB;
    color: var(--primary);
    margin-bottom: 20px;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-link:hover, .nav-link.active {
    background: var(--bg-main);
    color: var(--primary);
    border-left: 4px solid var(--primary);
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
}

/* Navbar */
.top-navbar {
    background: #fff;
    padding: 15px 30px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px;
    margin-bottom: 30px;
}

/* Card */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

table th {
    background-color: var(--light);
    font-weight: 600;
    color: var(--text-muted);
}

table tbody tr:hover {
    background-color: #F9FAFB;
}

/* Siswa Exam UI */
.exam-header {
    background: #fff;
    padding: 15px 30px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--danger);
    background: #FEE2E2;
    padding: 5px 15px;
    border-radius: 8px;
}

.exam-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.question-box {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    font-size: 1.1rem;
}

.options-container {
    margin-top: 20px;
}

.option-label {
    display: block;
    padding: 15px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-label:hover {
    background: var(--bg-main);
}

.option-label input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.2);
}

.option-label.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.navigation-box {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: fit-content;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.nav-btn {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn.answered {
    background: var(--secondary);
    color: #fff;
    border-color: var(--secondary);
}

.nav-btn.active {
    border: 2px solid var(--primary);
    transform: scale(1.1);
}

.nav-btn.unanswered {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
}

/* Exam Protection */
.noselect {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ===== Rich Content (hasil rich text editor: rumus & gambar) ===== */
.rich-content img,
.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 6px 0;
}

.rich-content p,
.ql-editor p {
    margin: 0 0 6px;
}

.rich-content .katex,
.ql-editor .katex {
    font-size: 1.05em;
}

.rich-editor-box {
    background: #fff;
    border-radius: 0 0 8px 8px;
    min-height: 90px;
}

.rich-editor-box .ql-editor {
    min-height: 90px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
}

.rich-editor-field .ql-toolbar {
    border-radius: 8px 8px 0 0;
    background: #F9FAFB;
}

.rich-editor-field {
    margin-bottom: 4px;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    isolation: isolate;
    position: relative;
}

.rich-editor-field .ql-toolbar.ql-snow,
.rich-editor-field .ql-container.ql-snow {
    border: none;
}

.opsi-editor-wrap {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
}

.opsi-editor-wrap .opsi-label {
    flex: 0 0 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    background: var(--light);
    border-radius: 8px;
    margin-top: 2px;
}

.opsi-editor-wrap .rich-editor-field {
    flex: 1;
    min-width: 0;
}

/* ===== Jam Langsung (WIB) di Header Ujian ===== */
.exam-live-clock {
    text-align: center;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.exam-live-clock .clock-time {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dark, #1F2937);
    letter-spacing: 0.5px;
}
.exam-live-clock .clock-date {
    font-size: 0.75rem;
    margin-top: 2px;
}

/* ===== Modal generik (pengganti alert()/confirm() browser bawaan) ===== */
.cbt-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}
.cbt-modal-overlay.show {
    display: flex;
}
.cbt-modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    animation: cbtModalPop 0.15s ease-out;
}
@keyframes cbtModalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.cbt-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.5rem;
}
.cbt-modal-icon.warning { background: #FEF3C7; color: #D97706; }
.cbt-modal-icon.danger { background: #FEE2E2; color: #DC2626; }
.cbt-modal-icon.info { background: #DBEAFE; color: #2563EB; }
.cbt-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--dark, #1F2937);
}
.cbt-modal-message {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 22px;
}
.cbt-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.cbt-modal-actions .btn {
    flex: 1;
    max-width: 160px;
}

/* =========================================================================
   RESPONSIVE / MOBILE & TABLET
   ========================================================================= */

/* Tabel: aman di-scroll horizontal di layar sempit, tanpa perlu ubah tiap halaman */
@media (max-width: 700px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Sidebar dashboard (admin/guru): dari kolom fixed di kiri -> jadi bar atas yang bisa
   di-scroll horizontal di layar sempit, supaya konten utama tidak kehilangan ruang */
@media (max-width: 900px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: 0;
        display: flex;
        align-items: center;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 1px solid #E5E7EB;
    }
    .sidebar-brand {
        display: none;
    }
    .sidebar .nav-link {
        padding: 10px 14px;
        white-space: nowrap;
        border-left: none !important;
        border-radius: 8px;
    }
    .sidebar .nav-link:hover, .sidebar .nav-link.active {
        border-left: none;
        background: var(--bg-main);
    }
    .sidebar .text-danger {
        margin-top: 0 !important;
        margin-left: auto;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .top-navbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 15px;
    }
    .card {
        padding: 16px;
    }
    body .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    body .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    body .stat-grid {
        grid-template-columns: 1fr !important;
    }
    .card-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Halaman ujian siswa: header & area soal menyesuaikan layar sempit (HP/tablet) */
@media (max-width: 800px) {
    .exam-header {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        gap: 10px;
        padding: 14px 16px;
    }
    .exam-live-clock {
        order: 2;
    }
    .exam-header > div:last-child {
        order: 3;
        justify-self: center !important;
        flex-wrap: wrap;
        justify-content: center;
    }
    .exam-body {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 15px;
    }
    .navigation-box {
        order: -1;
    }
    .nav-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .question-box {
        padding: 18px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .font-size-control span {
        display: none;
    }
    .timer {
        font-size: 1.2rem;
        padding: 5px 10px;
    }
    .exam-live-clock .clock-time {
        font-size: 1.1rem;
    }
    .nav-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    .opsi-editor-wrap {
        gap: 6px;
    }
    .opsi-editor-wrap .opsi-label {
        flex-basis: 26px;
        font-size: 0.85rem;
    }
    .cbt-modal-box {
        padding: 20px;
    }
}
