/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    /* Colors */
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;
    
    --success: #10b981;
    --success-light: #34d399;
    --success-bg: #ecfdf5;
    
    --danger: #ef4444;
    --danger-light: #f87171;
    --danger-bg: #fef2f2;
    
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --warning-bg: #fffbeb;
    
    --info: #06b6d4;
    --purple: #8b5cf6;
    
    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --white: #ffffff;
    --black: #000000;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* =========================================
   2. LAYOUT & CONTAINERS
   ========================================= */
.container, 
.registration-container, 
.token-container {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden; /* Penting untuk gradient top */
}

/* Container Umum */
.container {
    max-width: 900px;
    margin: 40px auto;
    padding: 40px;
    border: 1px solid var(--gray-200);
}

/* Container Login/Register */
.registration-container {
    max-width: 600px;
    margin: 50px auto;
    padding: 40px;
}

/* Container Token */
.token-container {
    max-width: 480px;
    width: 100%;
    margin: 50px auto;
    padding: 50px 40px;
    text-align: center;
}

/* Top Gradient Line Shared */
.container::before, 
.registration-container::before, 
.token-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--purple));
}

/* Headings */
h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 30px 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.section-title {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin: 30px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--gray-200);
}

/* =========================================
   3. FORMS & INPUTS
   ========================================= */
.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 15px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: 16px;
    transition: var(--transition);
    background: var(--white);
    font-family: inherit;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.readonly-field {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    cursor: not-allowed !important;
}

/* Custom Select Dropdown */
.select-wrapper {
    position: relative;
}

.custom-select {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    background-color: white;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
    transition: var(--transition);
}

.custom-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Password Toggle */
.password-field {
    position: relative;
    width: 100%;
}

.password-field input {
    padding-right: 50px !important;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 18px;
    z-index: 5;
}

.toggle-password:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Tabs for Login/Register */
.tabs {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--gray-200);
}

.tab {
    padding: 15px 25px;
    cursor: pointer;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    color: var(--gray-600);
    flex: 1;
    text-align: center;
}

.tab.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

/* =========================================
   4. BUTTONS & ALERTS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 16px 30px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Button Variants */
.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-light); }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { background: var(--warning-light); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }

.btn-info { background: var(--info); }
.btn-info:hover { background: #0891b2; }

.btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Alerts */
.alert {
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
    border-left: 4px solid;
    font-weight: 500;
}

.alert-error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: #991b1b;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success);
    color: #065f46;
}

.alert-info {
    background: #eff6ff;
    border-color: var(--info);
    color: #1e3a8a;
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    padding: 25px;
    border-radius: var(--radius-lg);
    margin: 25px 0;
    border-left: 4px solid var(--primary);
}

/* =========================================
   5. QUIZ INTERFACE & QUESTIONS
   ========================================= */
/* Content Fade In */
#quiz-content {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}
#quiz-content[style*="display: block"] { opacity: 1; }

.question {
    background: var(--white);
    padding: 30px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin: 25px 0;
    transition: var(--transition);
    position: relative;
}

.question:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.question-number {
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--primary);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

.question-text {
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

/* Choices */
.choice {
    display: flex;
    align-items: flex-start;
    padding: 18px 20px;
    margin: 12px 0;
    background: var(--gray-50);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.choice:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.choice.selected {
    background: #dbeafe;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.choice input[type="radio"] {
    margin-right: 12px;
    margin-top: 4px;
    transform: scale(1.2);
}

.choice-text {
    flex: 1;
    line-height: 1.5;
}

/* Image Handling in Quiz */
.question-text img,
.choice-text img,
.answer-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: block;
}

.choice-text img {
    max-width: 200px;
}

/* Timer */
.timer {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.timer.warning { background: var(--warning); animation: pulse 1s infinite; color: #000; }
.timer.danger { background: var(--danger); animation: pulse 0.5s infinite; }

/* Camera */
.camera-indicator {
    position: fixed;
    top: 70px; /* Below timer */
    right: 20px;
    background: var(--danger);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    z-index: 90;
    animation: pulse 2s infinite;
}

#camera-preview {
    width: 100%;
    max-width: 400px;
    height: 300px;
    background: #000;
    margin: 20px auto;
    border-radius: 10px;
    overflow: hidden;
}

#camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =========================================
   6. RESULTS & HISTORY
   ========================================= */
.score-display {
    font-size: 48px;
    font-weight: 900;
    color: var(--primary);
    text-align: center;
    margin: 30px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* Stats Grid */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    border-left: 4px solid var(--primary);
    transition: transform 0.3s ease;
}

.stat-card:hover { transform: translateY(-5px); }

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    color: var(--gray-600);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Tables */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.history-table th, 
.history-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.history-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

/* Detailed Result Answers */
.detailed-results .question-text,
.detailed-results .answer-text {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.detailed-results .question-text {
    background: #f8f9fa;
    border-left: 4px solid var(--primary);
}

.detailed-results .answer-text {
    background: var(--white);
    border: 2px solid var(--gray-200);
}

.detailed-results .correct .answer-text { border-color: var(--success); background: var(--success-bg); }
.detailed-results .incorrect .answer-text { border-color: var(--danger); background: var(--danger-bg); }

/* Score Colors */
.score-excellent { color: var(--success); }
.score-good { color: var(--primary); }
.score-average { color: var(--warning); }
.score-poor { color: var(--danger); }

/* =========================================
   7. SECURITY & OVERLAYS
   ========================================= */
/* Common Overlay Base */
.security-overlay, 
.fullscreen-required {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

/* Fullscreen Force Overlay */
.fullscreen-required {
    background: rgba(0, 0, 0, 0.95);
    z-index: 4000; /* Paling tinggi */
    backdrop-filter: blur(5px);
}

/* Violation Overlay */
.security-overlay {
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
}

/* Toast Notification (Pojok Kanan Atas) */
.security-warning {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--danger);
    color: white;
    padding: 15px;
    border-radius: 8px;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

/* Counter (Pojok Kiri Atas) */
.warning-counter {
    position: fixed;
    top: 10px;
    left: 10px;
    background: var(--warning);
    color: #000;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    z-index: 2000;
    font-size: 14px;
    box-shadow: var(--shadow-md);
}

/* Violations Summary Box */
.violations-summary {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 20px;
}

.violation-item {
    padding: 10px;
    margin: 5px 0;
    background: white;
    border-radius: 5px;
    border-left: 4px solid var(--danger);
    font-size: 0.9rem;
}

/* Blur Effect Class */
.blur-effect {
    opacity: 0.2;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* =========================================
   8. UTILITY & RESPONSIVE
   ========================================= */
.text-center { text-align: center; }
.hidden { display: none; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* OTP Sections */
#otp-request-section, 
#otp-verify-section {
    padding: 20px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
#otp-request-section { background: var(--gray-50); }
#otp-verify-section { background: #f0f9ff; border-left: 4px solid var(--primary); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* Media Queries */
@media (max-width: 768px) {
    .container { margin: 20px 10px; padding: 25px; }
    h1 { font-size: 26px; }
    
    .timer {
        position: static;
        display: block;
        margin-bottom: 20px;
        text-align: center;
        width: 100%;
    }
    
    .camera-indicator {
        position: static;
        display: inline-block;
        margin-bottom: 10px;
    }

    .btn-group { flex-direction: column; }
    .btn { width: 100%; }
    
    .setting-item { flex-direction: column; align-items: flex-start; gap: 5px; }
    
    .history-table { display: block; overflow-x: auto; }
}

@media (max-width: 480px) {
    .container, .registration-container, .token-container { padding: 20px; }
    .score-display { font-size: 36px; }
    .stat-number { font-size: 1.8rem; }
    .toggle-password { right: 5px; }
}
/* === PERBAIKAN CONTAINER LOGIN (Agar Stabil) === */
.registration-container {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
    
    /* SETTING LEBAR YANG STABIL */
    width: 100%;          /* Di HP: Mengisi layar */
    max-width: 400px;     /* Di PC: KUNCI lebar maksimal 400px (jangan 600px) */
    margin: 50px auto;    /* Posisi tengah */
}

/* === PERBAIKAN TOMBOL (Agar Teks Pas di Tengah) === */
.btn {
    display: flex;              /* Ganti inline-flex jadi flex */
    justify-content: center;    /* KUNCI: Menengahkan isi tombol secara horizontal */
    align-items: center;        /* Menengahkan isi tombol secara vertikal */
    gap: 10px;
    
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 16px 30px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--shadow);
    
    width: 100%; /* Agar tombol memenuhi lebar form */
    text-align: center;
}

/* Pastikan style hover tetap ada */
.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
