/* =============================================
   QUIZ PAGES — SHARED STYLES
   Matches the Japura Online dark teal theme
   ============================================= */

:root {
    --bg-base: #041c1d;
    --bg-surface: #08383a;
    --bg-elevated: #0a4a4d;
    --bg-highlight: #0d5e62;
    --text-primary: #ffffff;
    --text-secondary: #b0c9ca;
    --accent: #1ef0e8;
    --accent-dark: #12b8b2;
    --danger: #ff4d4f;
    --success: #52c41a;
    --warning: #faad14;
    --font-family: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', 'Courier New', Courier, monospace;
}

code {
    font-family: var(--font-code);
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 0.9em;
}
pre code {
    display: block;
    background: rgba(0,0,0,0.4);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    margin: 12px 0;
    overflow-x: auto;
    white-space: pre;
    color: #e0e0e0;
    line-height: 1.5;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Auth Pages (register / login) ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at 60% 20%, rgba(30,240,232,0.08) 0%, transparent 60%),
                linear-gradient(135deg, var(--bg-base) 0%, #021215 100%);
}

.auth-card {
    background: rgba(8,56,58,0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(30,240,232,0.15);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    animation: slideUp 0.4s ease;
}

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

.auth-logo {
    text-align: center;
    margin-bottom: 20px;
}
.auth-logo a {
    display: block;
    width: 200px;
    height: 120px;
    margin: -10px auto 0px;
    background-image: url('assets/logo.png');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}
.auth-logo a img {
    display: none;
}

.auth-title {
    font-size: 26px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

/* Form elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 13px 16px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(30,240,232,0.05);
}
.form-group input::placeholder { color: rgba(255,255,255,0.3); }
.form-group select option { background: var(--bg-surface); }

.phone-row {
    display: flex;
    gap: 8px;
}
.phone-prefix {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 13px 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}
.phone-row input { flex: 1; }

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #021215;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    margin-top: 8px;
    box-shadow: 0 4px 20px rgba(30,240,232,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 28px rgba(30,240,232,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: transparent;
    border: 1px solid rgba(30,240,232,0.4);
    color: var(--accent);
    border-radius: 50px;
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(30,240,232,0.08); }

.btn-ghost {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-primary);
    border-radius: 50px;
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.14); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

.auth-link {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 20px;
}
.auth-link a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-link a:hover { text-decoration: underline; }

/* Error / success messages */
.msg-error {
    background: rgba(255,77,79,0.12);
    border: 1px solid rgba(255,77,79,0.3);
    color: #ff7875;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}
.msg-success {
    background: rgba(82,196,26,0.12);
    border: 1px solid rgba(82,196,26,0.3);
    color: #95de64;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}
.msg-error.show, .msg-success.show { display: block; }

/* Credentials card (after registration) */
.creds-card {
    background: rgba(30,240,232,0.07);
    border: 1px solid rgba(30,240,232,0.25);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}
.creds-card .cred-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.creds-card .cred-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 3px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 16px;
}
.creds-card .cred-username {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* ── Dashboard Layout ── */
.quiz-layout {
    display: block; /* Use block + margin-left for desktop instead of grid to avoid conflicts */
    min-height: 100vh;
}

.quiz-sidebar {
    background: #000;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    position: fixed; /* Fixed position for sidebar */
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}
.quiz-sidebar .logo-container { padding: 0 12px 24px; text-align: center; }
.quiz-sidebar img.brand-logo { height: 64px; }

.sidebar-user {
    padding: 12px;
    margin-bottom: 8px;
}
.sidebar-user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-user-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.sidebar-nav-list { list-style: none; }
.sidebar-nav-list li a,
.sidebar-nav-list li span {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.sidebar-nav-list li a:hover,
.sidebar-nav-list li span:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.sidebar-nav-list li a.active { color: var(--text-primary); }
.sidebar-nav-list li ion-icon { font-size: 20px; }

.sidebar-divider { height: 1px; background: #282828; margin: 12px; }

.sidebar-logout {
    margin-top: auto;
    padding: 12px;
}

/* Main content area */
.quiz-main {
    background: linear-gradient(to bottom, var(--bg-surface) 0%, var(--bg-base) 300px);
    padding: 40px 48px;
    height: 100vh;
    overflow-y: auto;
}

.page-header { margin-bottom: 36px; }
.page-header h1 { font-size: 32px; font-weight: 800; }
.page-header p { color: var(--text-secondary); margin-top: 6px; font-size: 15px; }

/* Quiz Cards */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.quiz-card {
    background: rgba(8,56,58,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}
.quiz-card:hover {
    transform: translateY(-4px);
    border-color: rgba(30,240,232,0.3);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

.quiz-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 50px;
    margin-bottom: 16px;
}
.badge-active { background: rgba(82,196,26,0.15); color: #95de64; border: 1px solid rgba(82,196,26,0.3); }
.badge-upcoming { background: rgba(250,173,20,0.15); color: #ffc53d; border: 1px solid rgba(250,173,20,0.3); }
.badge-ended { background: rgba(255,255,255,0.08); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.1); }
.badge-completed { background: rgba(30,240,232,0.1); color: var(--accent); border: 1px solid rgba(30,240,232,0.2); }

.quiz-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.quiz-card .quiz-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.quiz-card .quiz-meta span { display: flex; align-items: center; gap: 6px; }
.quiz-card .quiz-meta ion-icon { font-size: 14px; }

.quiz-card-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.quiz-score-preview {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
}

/* Section header */
.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.section-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state ion-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.4; display: block; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-primary); }

/* ── Quiz Player ── */
.quiz-player-layout {
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(ellipse at 30% 0%, rgba(30,240,232,0.06) 0%, transparent 50%),
                var(--bg-base);
    display: flex;
    flex-direction: column;
}

.quiz-top-bar {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.quiz-top-bar-left { display: flex; align-items: center; gap: 16px; }
.quiz-top-bar h2 { font-size: 16px; font-weight: 700; }
.quiz-top-bar .quiz-subject { font-size: 13px; color: var(--text-secondary); }

/* Timer */
.quiz-timer {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50px;
    padding: 8px 20px;
    font-variant-numeric: tabular-nums;
}
.quiz-timer ion-icon { font-size: 18px; }
.quiz-timer-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-primary);
    transition: color 0.3s;
}
.quiz-timer.warning .quiz-timer-value { color: var(--warning); }
.quiz-timer.danger .quiz-timer-value { color: var(--danger); animation: pulse 1s infinite; }

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

/* Progress bar */
.quiz-progress-bar {
    height: 3px;
    background: rgba(255,255,255,0.1);
    position: relative;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #12b8b2);
    transition: width 0.5s ease;
}

/* Questions */
.quiz-body { flex: 1; padding: 40px 32px; max-width: 800px; margin: 0 auto; width: 100%; overflow-y: auto; }

.quiz-counter {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.question-card {
    background: rgba(8,56,58,0.5);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}
.question-card.answered { border-color: rgba(30,240,232,0.25); }

.question-text {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 20px;
}

.question-text code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: rgba(0, 0, 0, 0.4);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(30, 240, 232, 0.2);
    font-size: 0.95em;
    font-weight: 500;
}

.options-list { display: flex; flex-direction: column; gap: 10px; }

.option-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    word-break: break-word;
}
.option-label span:last-child {
    flex: 1;
    min-width: 0;
    line-height: 1.5;
}
.option-label:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.2); }
.option-label input[type="radio"] { display: none; }
.option-label.selected {
    background: rgba(30,240,232,0.1);
    border-color: var(--accent);
    color: var(--accent);
}
.option-label.correct { background: rgba(82,196,26,0.15); border-color: var(--success); color: #95de64; }
.option-label.wrong { background: rgba(255,77,79,0.12); border-color: var(--danger); color: #ff7875; }

.option-key {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    transition: background 0.15s;
}
.selected .option-key { background: var(--accent); color: #021215; }
.correct .option-key { background: var(--success); color: #021215; }
.wrong .option-key { background: var(--danger); color: #fff; }

/* Submit bar */
.quiz-submit-bar {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    bottom: 0;
}
.quiz-answered-count { font-size: 14px; color: var(--text-secondary); }
.quiz-answered-count strong { color: var(--text-primary); }

/* Results page */
.results-header {
    background: linear-gradient(135deg, rgba(30,240,232,0.12), rgba(8,56,58,0.9));
    border: 1px solid rgba(30,240,232,0.2);
    border-radius: 24px;
    padding: 48px 32px;
    text-align: center;
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.results-score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) var(--pct), rgba(255,255,255,0.08) 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    position: relative;
    box-shadow: 0 0 30px rgba(30,240,232,0.15);
}
.results-score-circle::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: #061a1d; /* Matches the dark theme */
    z-index: 0;
}
.results-score-text {
    position: relative;
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    z-index: 1;
}
.results-score-label { 
    font-size: 15px; 
    color: var(--text-secondary); 
    font-weight: 500;
}

/* History Table */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.history-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.history-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-secondary);
}
.history-table tr:hover td { background: rgba(255,255,255,0.03); }
.history-table td:first-child { color: var(--text-primary); font-weight: 500; }

/* Admin panel */
.admin-section {
    background: rgba(8,56,58,0.4);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}
.admin-section h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: rgba(30,240,232,0.06);
    border: 1px solid rgba(30,240,232,0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
.stat-card .stat-number { font-size: 36px; font-weight: 800; color: var(--accent); }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid rgba(30,240,232,0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlay loading */
.page-loading {
    position: fixed; inset: 0;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    gap: 16px;
    font-size: 15px;
    color: var(--text-secondary);
}
.page-loading .spinner { width: 40px; height: 40px; border-width: 3px; }

/* Confirmation modal */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
    display: none;
}
.confirm-overlay.show { display: flex; }
.confirm-box {
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 36px;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.confirm-box h3 { font-size: 20px; margin-bottom: 10px; }
.confirm-box p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }
.confirm-box .btn-row { display: flex; gap: 12px; justify-content: center; }

/* Responsive */
@media (min-width: 1025px) {
    .quiz-sidebar { transform: translateX(0) !important; display: flex !important; width: 280px !important; }
    .quiz-main { margin-left: 280px !important; }
    .mobile-menu-toggle { display: none !important; }
}

@media (max-width: 1024px) {
    .quiz-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
        display: flex;
    }
    .quiz-sidebar.open, .quiz-sidebar.active {
        transform: translateX(0);
    }
    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        z-index: 150;
        display: none;
    }
    .mobile-sidebar-overlay.active {
        display: block;
    }
    .quiz-main { margin-left: 0 !important; padding: 80px 20px 24px; }
    .mobile-menu-toggle { display: flex !important; }
    .quiz-body { padding: 24px 20px; }
    .quiz-top-bar { padding: 12px 16px; }
    .quiz-submit-bar { padding: 12px 16px; flex-direction: column; gap: 12px; }
    .auth-card { padding: 32px 24px; }
    .quiz-timer-value { font-size: 18px; }
    .results-header { padding: 28px 20px; }
}

@media (max-width: 480px) {
    .quiz-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
