/* ============================================
   GLOBAL STYLES & ANIMATIONS
   ============================================ */

/* Indikator Real-time */
.realtime-dot {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* UI polish tokens */
:root {
    --ui-primary: #2563eb;
    --ui-primary-strong: #1d4ed8;
    --ui-danger: #dc2626;
    --ui-surface: #ffffff;
    --ui-border: #e2e8f0;
    --ui-ring: rgba(37, 99, 235, 0.35);
    --ui-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --ui-shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10);
    --ui-radius: 0.9rem;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* iOS/iPad fix: ensure inputs and buttons are tappable */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
    min-height: 44px;
}

/* Checkbox & radio keep native rendering, just fix touch + size */
input[type="checkbox"],
input[type="radio"] {
    touch-action: manipulation;
    cursor: pointer;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    accent-color: #0891B2;
}

select {
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

button {
    -webkit-appearance: none;
    cursor: pointer;
    touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--ui-ring);
    outline-offset: 3px;
}

button:disabled,
.btn:disabled,
[aria-disabled="true"] {
    cursor: not-allowed !important;
    opacity: 0.55 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Efek transisi umum untuk tombol */
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.85rem;
    padding: 0.75rem 1rem;
    font-weight: 800;
    line-height: 1;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
    box-shadow: var(--ui-shadow-sm);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.btn-primary {
    background: linear-gradient(135deg, var(--ui-primary), #4f46e5);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--ui-primary-strong), #4338ca);
}

.btn-secondary {
    background: #ffffff;
    color: #334155;
    border: 1px solid var(--ui-border);
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger {
    background: linear-gradient(135deg, var(--ui-danger), #b91c1c);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.premium-card,
.card {
    border-radius: var(--ui-radius);
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--ui-shadow-md);
}

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--ui-primary) !important;
    box-shadow: 0 0 0 4px var(--ui-ring) !important;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16) !important;
}

.form-input.success,
.form-select.success,
.form-textarea.success {
    border-color: #22c55e !important;
}

.dark .premium-card,
.dark .card {
    border-color: rgba(55, 65, 81, 0.9);
    background: rgba(31, 41, 55, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.dark .btn-secondary {
    background: #1f2937;
    color: #f3f4f6;
    border-color: #4b5563;
}

.dark .btn-secondary:hover:not(:disabled) {
    background: #374151;
}

.ui-empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
    padding: 2rem;
    text-align: center;
    color: #64748b;
}

.dark .ui-empty-state {
    border-color: #4b5563;
    background: rgba(17, 24, 39, 0.7);
    color: #9ca3af;
}

.ui-skeleton {
    position: relative;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: 0.75rem;
}

.ui-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: shimmer 1.35s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.dark .ui-skeleton {
    background: #374151;
}

/* ============================================
   NAVIGATION BUTTONS
   ============================================ */

.nav-btn {
    height: 44px !important;
    width: 44px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem !important;
    transition: all 150ms ease;
    border-radius: 10px;
    position: relative;
    font-family: 'Fira Sans', system-ui, sans-serif;
    background-color: #ffffff;
    color: #334155;
    border: 2px solid #E2E8F0;
    cursor: pointer;
}

.nav-btn:hover {
    background-color: #F0FDFA;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(8, 145, 178, 0.15);
    border-color: #22D3EE;
}

.nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.4);
}

.nav-btn.answered {
    background-color: #DCFCE7 !important;
    color: #15803D !important;
    border-color: #86EFAC !important;
}

.nav-btn.answered:hover {
    background-color: #BBF7D0 !important;
    border-color: #22C55E !important;
}

.nav-btn.marked {
    background-color: #FEF3C7 !important;
    color: #B45309 !important;
    border-color: #FCD34D !important;
}

.nav-btn.marked:hover {
    background-color: #FDE68A !important;
    border-color: #F59E0B !important;
}

.nav-btn.current {
    background: linear-gradient(135deg, #0891B2, #0E7490) !important;
    color: white !important;
    border-color: #0891B2 !important;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.3), 0 4px 12px rgba(8, 145, 178, 0.4) !important;
    transform: scale(1.05);
}

/* Badge untuk soal yang marked + answered */
.nav-btn.answered.marked {
    position: relative;
}

.nav-btn.answered.marked::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #F59E0B;
    border: 2px solid white;
    border-radius: 9999px;
}

/* ============================================
   DARK MODE - NAVIGATION BUTTONS
   ============================================ */

.dark .nav-btn:not(.answered):not(.current):not(.marked) {
    background-color: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.dark .nav-btn:hover {
    background-color: #4b5563;
}

.dark .nav-btn.answered {
    background-color: #064e3b !important;
    border-color: #059669 !important;
    color: #a7f3d0 !important;
}

.dark .nav-btn.marked {
    background-color: #92400e !important;
    border-color: #d97706 !important;
    color: #fde68a !important;
}

.dark .nav-btn.current {
    background-color: #1e40af !important;
    border-color: #1e3a8a !important;
}

/* ============================================
   ANIMATIONS
   ============================================ */

.question-fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

.question-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide Animations */
@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.exam-jump-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.exam-jump-chip {
    min-width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    color: #334155;
    transition: all 0.2s ease;
}

.exam-jump-chip:hover {
    transform: translateY(-1px);
}

.exam-jump-chip.empty {
    border-color: #fca5a5;
    color: #b91c1c;
    background: #fef2f2;
}

.exam-jump-chip.marked {
    border-color: #fcd34d;
    color: #92400e;
    background: #fffbeb;
}

.exam-mobile-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.12);
}

@media (max-width: 360px) {
    .exam-mobile-action-bar {
        padding: 0.6rem 0.6rem calc(0.6rem + env(safe-area-inset-bottom));
        gap: 0.4rem;
    }

    .exam-mobile-action-btn {
        min-height: 44px;
        font-size: 0.72rem;
    }
}

.exam-mobile-action-btn {
    min-height: 48px;
    border-radius: 0.8rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1f2937;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.exam-mobile-action-btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.exam-mobile-action-btn.danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.exam-mobile-action-btn.marked {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}

.exam-mobile-action-btn:disabled {
    opacity: 0.5;
}

.dark .exam-mobile-action-bar {
    background: rgba(17, 24, 39, 0.98);
    border-top-color: #374151;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}

.dark .exam-mobile-action-btn {
    background: #111827;
    border-color: #4b5563;
    color: #f3f4f6;
}

.dark .exam-mobile-action-btn.primary {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

.dark .exam-mobile-action-btn.danger {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #ffffff;
}

.dark .exam-mobile-action-btn.marked {
    background: #b45309;
    border-color: #b45309;
    color: #ffffff;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out forwards;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out forwards;
}

/* Loading Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 0.5rem;
}

/* Progress Animation */
@keyframes progress {
    0% {
        stroke-dasharray: 0 100;
    }
}

/* ============================================
   SEGMENTED CONTROL
   ============================================ */

.segmented-control {
    display: flex;
    background-color: #e5e7eb;
    padding: 4px;
    border-radius: 0.5rem;
}

.segmented-control button {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background-color: transparent;
    border-radius: 0.375rem;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.segmented-control button.active {
    background-color: white;
    color: #2563eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .segmented-control {
    background-color: #111827;
}

.dark .segmented-control button {
    color: #9ca3af;
}

.dark .segmented-control button.active {
    background-color: #374151;
    color: white;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

#toast-container > * {
    pointer-events: auto;
}

.toast {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 400px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-left: 4px solid transparent;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: #1f2937;
}

.toast-message {
    font-size: 0.875rem;
    color: #4b5563;
}

/* Toast Variants */
.toast.success {
    border-left-color: #10b981;
}

.toast.success .toast-icon {
    color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.error .toast-icon {
    color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast.warning .toast-icon {
    color: #f59e0b;
}

.toast.info {
    border-left-color: #3b82f6;
}

.toast.info .toast-icon {
    color: #3b82f6;
}

/* Dark Mode for Toasts */
.dark .toast {
    background-color: #1f2937;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dark .toast-title {
    color: #f3f4f6;
}

.dark .toast-message {
    color: #d1d5db;
}

/* ============================================
   CIRCULAR CHART
   ============================================ */

.circular-chart {
    display: block;
    margin: 10px auto;
    max-width: 80%;
    max-height: 250px;
}

.circle-bg {
    fill: none;
    stroke: #eee;
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}

.percentage {
    fill: #666;
    font-family: sans-serif;
    font-weight: bold;
    font-size: 0.5em;
    text-anchor: middle;
}

/* ============================================
   MOBILE SIDEBAR
   ============================================ */

.mobile-sidebar-overlay {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.mobile-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}

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

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar-animated {
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   WATERMARK BACKGROUND
   ============================================ */

.watermark-bg::before {
    content: "";
    position: absolute;
    top: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f3f4f6'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5zm0 9l2.5-1.25L12 8.5l-2.5 1.25L12 11zm0 2.5l-5-2.5-5 2.5L12 22l10-8.5-5-2.5-5 2.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.5;
    pointer-events: none;
    transform: rotate(15deg);
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */

.login-container {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #7f9eb2 0%, #8db5c9 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-bg-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

.login-card {
    background: linear-gradient(to bottom, #2c7da0 0%, #0d4d6d 100%);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    position: relative;
    color: white;
    text-align: center;
}

.user-icon-circle {
    width: 100px;
    height: 100px;
    background-color: #001f3f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -90px auto 30px auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-icon-svg {
    width: 50px;
    height: 50px;
    stroke: white;
    stroke-width: 1.5;
}

.input-group {
    position: relative;
    margin-bottom: 25px;
    text-align: left;
}

.input-icon {
    position: absolute;
    left: 0;
    top: 10px;
    color: rgba(255, 255, 255, 0.8);
}

.login-input {
    width: 100%;
    padding: 10px 10px 10px 30px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.3s;
}

.login-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
}

.login-input:focus {
    border-bottom-color: white;
}

.btn-login {
    background-color: #001f3f;
    color: white;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    margin-top: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.btn-login:hover {
    background-color: #003366;
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.footer-links {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.footer-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: white;
}

.footer-links a:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.error-msg {
    color: #ff8a80;
    font-size: 11px;
    margin-top: 4px;
    display: none;
}

/* ============================================
   DARK MODE - GLOBAL
   ============================================ */

.dark {
    color-scheme: dark;
}

.dark body {
    background-color: #111827;
}

.dark .card {
    background-color: #1f2937;
    border-color: #374151;
}

.dark h1,
.dark h2,
.dark h3,
.dark p,
.dark label,
.dark span,
.dark div {
    color: #d1d5db;
}

.dark .text-gray-800,
.dark .text-blue-800,
.dark .text-blue-600,
.dark .text-purple-700 {
    color: #93c5fd;
}

.dark .text-gray-700 {
    color: #9ca3af;
}

.dark .text-gray-600 {
    color: #9ca3af;
}

.dark .text-gray-500 {
    color: #6b7280;
}

.dark .text-gray-400 {
    color: #4b5563;
}

.dark .text-green-600 {
    color: #34d399;
}

.dark .text-red-600 {
    color: #f87171;
}

.dark .text-yellow-600 {
    color: #fbbf24;
}

/* ============================================
   DESIGN SYSTEM - ANBK CBT
   Primary: #0891B2 | Secondary: #22D3EE
   CTA: #22C55E | BG: #ECFEFF | Text: #164E63
   Typography: Fira Sans + Fira Code
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --ds-primary: #0891B2;
    --ds-primary-dark: #0e7490;
    --ds-secondary: #22D3EE;
    --ds-cta: #22C55E;
    --ds-cta-dark: #16a34a;
    --ds-bg: #ECFEFF;
    --ds-text: #164E63;
    --ds-transition-fast: 100ms ease;
    --ds-transition-base: 200ms ease;
    --ds-transition-slow: 300ms ease;
}

body {
    font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
}

code, .font-mono, .tracking-widest {
    font-family: 'Fira Code', 'Courier New', monospace;
}

/* Micro-interactions */
.micro-btn {
    transition: transform var(--ds-transition-fast), box-shadow var(--ds-transition-fast), background-color var(--ds-transition-base);
}

.micro-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.25);
}

.micro-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* Skeleton loaders */
.skeleton-line {
    height: 1rem;
    border-radius: 0.5rem;
    background: #e2e8f0;
    position: relative;
    overflow: hidden;
}

.skeleton-line::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: shimmer 1.35s infinite;
}

.skeleton-circle {
    border-radius: 9999px;
    background: #e2e8f0;
    position: relative;
    overflow: hidden;
}

.skeleton-circle::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: shimmer 1.35s infinite;
}

.dark .skeleton-line,
.dark .skeleton-circle {
    background: #374151;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(236, 254, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.dark .loading-overlay {
    background: rgba(17, 24, 39, 0.85);
}

/* Spinner */
.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(8, 145, 178, 0.2);
    border-top-color: var(--ds-primary);
    border-radius: 9999px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ensure empty containers don't block touch */
#modal-container:empty,
#toast-container:empty {
    pointer-events: none;
    position: fixed;
    z-index: -1;
}

#modal-container:not(:empty) {
    position: fixed;
    inset: 0;
    z-index: 9999;
}
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 22rem;
    width: calc(100vw - 2rem);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    font-family: 'Fira Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    animation: toastIn 0.25s ease forwards;
    border: 1px solid transparent;
}

.toast.toast-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.toast.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.toast.toast-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.toast.toast-info {
    background: #ecfeff;
    color: #164e63;
    border-color: #a5f3fc;
}

.dark .toast.toast-success { background: #052e16; color: #86efac; border-color: #166534; }
.dark .toast.toast-error { background: #450a0a; color: #fca5a5; border-color: #991b1b; }
.dark .toast.toast-warning { background: #451a03; color: #fde68a; border-color: #92400e; }
.dark .toast.toast-info { background: #083344; color: #a5f3fc; border-color: #0e7490; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(1rem); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(1rem); }
}

.toast.removing {
    animation: toastOut 0.2s ease forwards;
}

/* Page transition */
.page-transition-enter {
    animation: pageIn 0.22s ease forwards;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   ADVANCED ANIMATIONS - ANBK CBT
   ============================================ */

/* Page Transitions - smooth fade+slide */
.page-enter {
    animation: pageEnter 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.page-exit {
    animation: pageExit 200ms cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes pageExit {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* Button press - tactile feedback */
.btn-press {
    transition: transform 120ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 120ms cubic-bezier(0.4, 0, 0.2, 1),
                background-color 200ms ease;
}

.btn-press:active:not(:disabled) {
    transform: scale(0.96) translateY(1px);
}

.btn-lift {
    transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-lift:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -8px rgba(8, 145, 178, 0.4),
                0 4px 8px -2px rgba(8, 145, 178, 0.2);
}

/* Form validation animations */
.shake-error {
    animation: shake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

.success-pulse {
    animation: successPulse 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes successPulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Checkmark draw animation */
.checkmark-draw {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: drawCheck 500ms cubic-bezier(0.65, 0, 0.45, 1) 100ms forwards;
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.checkmark-circle {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawCircle 600ms cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}

/* Skeleton shimmer (enhanced) */
.skeleton-shimmer {
    background: linear-gradient(
        90deg,
        #e2e8f0 0%,
        #f1f5f9 50%,
        #e2e8f0 100%
    );
    background-size: 200% 100%;
    animation: shimmerWave 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

@keyframes shimmerWave {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dark .skeleton-shimmer {
    background: linear-gradient(
        90deg,
        #374151 0%,
        #4b5563 50%,
        #374151 100%
    );
    background-size: 200% 100%;
}

/* Modal bottom sheet slide (mobile) */
@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideDownSheet {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.modal-sheet-enter {
    animation: slideUpSheet 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-sheet-exit {
    animation: slideDownSheet 200ms cubic-bezier(0.4, 0, 1, 1) both;
}

/* Modal backdrop fade */
.modal-backdrop-enter {
    animation: backdropFade 240ms ease-out both;
}

@keyframes backdropFade {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(4px); }
}

/* Toast slide-in from right */
@keyframes toastSlideIn {
    from {
        transform: translateX(110%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateX(110%) scale(0.95);
        opacity: 0;
    }
}

.toast-enter {
    animation: toastSlideIn 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.toast-exit {
    animation: toastSlideOut 220ms cubic-bezier(0.4, 0, 1, 1) both;
}

/* Ripple effect on tap */
@keyframes rippleExpand {
    from {
        transform: scale(0);
        opacity: 0.6;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(8, 145, 178, 0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    border-radius: inherit;
}

.ripple-effect:active::before {
    animation: rippleExpand 600ms ease-out;
}

/* Number count-up effect (untuk score, stats) */
.count-up {
    animation: countUpBounce 600ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes countUpBounce {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Card hover lift */
.card-hover {
    transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 30px -10px rgba(8, 145, 178, 0.15),
                0 8px 12px -4px rgba(0, 0, 0, 0.05);
}

/* Pulse for live indicator */
.pulse-dot {
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: currentColor;
    opacity: 0.4;
    animation: pulseRing 1.5s ease-out infinite;
}

@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Floating action button bounce */
@keyframes fabBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.fab-bounce {
    animation: fabBounce 2s ease-in-out infinite;
}

/* Progress bar smooth */
.progress-smooth {
    transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger children animation */
.stagger-children > * {
    animation: fadeInUp 400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Number/Timer flip-down (untuk countdown) */
@keyframes flipDown {
    0% {
        transform: rotateX(0);
        opacity: 1;
    }
    50% {
        transform: rotateX(-90deg);
        opacity: 0;
    }
    51% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
        opacity: 1;
    }
}

.timer-flip {
    animation: flipDown 500ms cubic-bezier(0.65, 0, 0.45, 1);
    display: inline-block;
    transform-origin: center;
}

/* Heart-beat for important alerts */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14%, 42% { transform: scale(1.08); }
    28%, 70% { transform: scale(1); }
}

.heartbeat {
    animation: heartbeat 1.4s ease-in-out infinite;
}

/* Slide indicator (active tab/nav) */
.slide-indicator {
    position: relative;
}

.slide-indicator::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0891B2, #22D3EE);
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.slide-indicator.active::after {
    transform: scaleX(1);
}

/* ============================================
   MOBILE NATIVE APP FEEL
   ============================================ */

/* Disable text selection on UI elements (keep on content) */
button, a, [role="button"], .btn, .nav-btn, .mobile-nav-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Prevent pinch-zoom only on UI chrome */
header, nav, .modal-overlay, #toast-container {
    touch-action: pan-y;
}

/* Smooth scroll with momentum on iOS */
html, body, main, aside, .overflow-y-auto, .overflow-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Safe area for iPhone notch / home indicator */
body {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
}

/* Pull-to-refresh disabled on app pages */
.exam-page, .min-h-screen {
    overscroll-behavior-y: contain;
}

/* Active press feedback (tactile) */
button:active:not(:disabled),
a[onclick]:active,
.btn:active:not(:disabled),
[role="button"]:active {
    transform: scale(0.97);
    transition: transform 80ms ease;
}

/* Touch target minimum 44px (Apple HIG + WCAG) */
@media (hover: none) and (pointer: coarse) {
    button, a[onclick], input:not([type="checkbox"]):not([type="radio"]), select, textarea, [role="button"] {
        min-height: 44px;
    }

    button:focus, a:focus {
        outline: none;
    }

    /* Larger tap targets on mobile */
    .btn, .nav-btn {
        padding: 0.875rem 1.25rem;
    }

    /* Spacing between adjacent buttons */
    .btn + .btn,
    button + button:not(.close) {
        margin-left: 0.5rem;
    }

    /* Hide hover-only tooltips on touch */
    [title]:hover::after {
        display: none;
    }
}

/* iOS input zoom prevention (input font must be >= 16px) */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="date"],
textarea,
select {
    font-size: 16px;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    textarea,
    select {
        font-size: 0.875rem;
    }
}

/* Ripple effect for buttons (material feel) */
.mobile-tap-ripple {
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.mobile-tap-ripple::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(8, 145, 178, 0.3) 10%, transparent 50%);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.4s, transform 0.4s;
    pointer-events: none;
}

.mobile-tap-ripple:active::after {
    opacity: 1;
    transform: scale(1.5);
    transition: 0s;
}

/* Bottom sheet style modals on mobile */
@media (max-width: 640px) {
    .modal-content {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 1.25rem 1.25rem 0 0 !important;
        max-width: 100% !important;
        max-height: 90vh;
        animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* iOS-style segmented control feel for nav tabs */
.mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Prevent text size adjust on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Fast tap (remove 300ms delay) */
a, button, input, select, textarea, [role="button"] {
    touch-action: manipulation;
}

/* Disable double-tap zoom */
* {
    touch-action: manipulation;
}

body {
    touch-action: pan-x pan-y;
}

/* Login page focus states */
#login-form input:focus,
#login-form select:focus {
    outline: none !important;
    border-color: #0891B2 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.15) !important;
}

#login-form input:hover:not(:focus),
#login-form select:hover:not(:focus) {
    border-color: #CBD5E1 !important;
}

#startButton:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(8, 145, 178, 0.4) !important;
}

#startButton:active:not(:disabled) {
    transform: translateY(0);
}

.dark .anbk-header {
    background: linear-gradient(90deg, #1e3a8a 0%, #1c3d5a 100%);
}

.dark .anbk-input {
    background-color: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.dark .anbk-input::placeholder {
    color: #6b7280;
}

.dark .option-label:hover {
    background-color: #374151;
}

.dark .bg-blue-50 {
    background-color: #1e293b;
}

.dark .option-label.selected {
    background-color: #1e3a8a;
    border-color: #2563eb;
}

.dark .option-label input:checked + span {
    color: #93c5fd;
}

.dark .border-blue-100 {
    border-color: #1e40af;
}

.dark .text-blue-800 {
    color: #93c5fd;
}

.dark .bg-gray-50 {
    background-color: #1f2937;
    border-color: #374151;
}

.dark .border-blue-200 {
    border-color: #1e40af;
}

.dark .bg-red-100 {
    background-color: #3f2121;
}

.dark .text-red-700 {
    color: #fca5a5;
}

.dark .bg-gray-100 {
    background-color: #374151;
}

.dark .border-b {
    border-color: #374151;
}

.dark .border-t {
    border-color: #374151;
}

.dark .hover\:bg-gray-50:hover {
    background-color: #374151;
}

/* ============================================
   ACCESSIBILITY - FOCUS STATES
   ============================================ */

button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark button:focus,
.dark input:focus,
.dark select:focus,
.dark textarea:focus,
.dark a:focus {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
