/* ===== CSS Variables & Reset ===== */
/* Dark theme (default) */
:root {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-bg: rgba(59, 130, 246, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-secondary: #334155;
    --bg-hover: #2d3a4d;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

/* Light theme */
[data-theme="light"] {
    --primary: #1a56db;
    --primary-hover: #1e40af;
    --primary-bg: #eff6ff;
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header & Navigation ===== */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--primary);
}

/* ===== Main Content ===== */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
    flex: 1;
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    padding: 2rem 0 1.5rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ===== Mode Cards ===== */
.modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.mode-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.mode-icon {
    margin-bottom: 1rem;
    color: var(--primary);
}

.mode-icon svg {
    width: 48px;
    height: 48px;
}

.mode-card h2 {
    margin-bottom: 0.75rem;
}

.mode-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ===== Info Section ===== */
.info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-top: 1rem;
}

.info h3 {
    margin-bottom: 0.75rem;
}

.info ul {
    list-style: none;
}

.info li {
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-muted);
}

.info li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-secondary);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Exam Header ===== */
.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.exam-header h1 {
    font-size: 1.5rem;
}

.exam-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.timer {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.timer.warning {
    border-color: var(--warning);
    color: var(--warning);
    animation: pulse 1s infinite;
}

.timer.danger {
    border-color: var(--danger);
    color: var(--danger);
    animation: pulse 0.5s infinite;
}

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

.progress-info {
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Question Cards ===== */
.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.question-number {
    font-weight: 700;
    color: var(--primary);
}

.question-source {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.question-content {
    font-size: 1.05rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* ===== Image Warning ===== */
.image-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: 8px;
    color: var(--warning);
    font-size: 0.9rem;
    font-weight: 500;
}

.image-warning svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* ===== Question Image ===== */
.question-image {
    margin-bottom: 1rem;
    text-align: center;
}

.question-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* ===== Options ===== */
.options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 0.75rem;
}

.option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.option input[type="radio"] {
    display: none;
}

.option input[type="radio"]:checked + .option-letter {
    background: var(--primary);
    color: white;
}

.option-letter {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.option-text {
    padding-top: 0.25rem;
    line-height: 1.5;
}

/* Option states for results */
.option.correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.option.correct .option-letter {
    background: var(--success);
    color: white;
}

.option.wrong {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.option.wrong .option-letter {
    background: var(--danger);
    color: white;
}

/* ===== Exam Actions ===== */
.exam-actions {
    text-align: center;
    padding: 2rem 0;
}

/* ===== Results Overlay ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.overlay.hidden {
    display: none;
}

.results-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2.5rem;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.results-container h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

.results-score {
    margin: 1.5rem 0;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    border: 6px solid;
}

.score-circle.passed {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-bg);
}

.score-circle.failed {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-bg);
}

.results-stats {
    margin: 1.5rem 0;
    color: var(--text-muted);
}

.results-stats p {
    margin: 0.3rem 0;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ===== Practice Mode ===== */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.practice-header h1 {
    font-size: 1.5rem;
}

.test-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.test-selector label {
    font-weight: 500;
    color: var(--text-muted);
}

.test-selector select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}

.practice-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stats-text {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-correct,
.stat-wrong {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.stat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.stat-correct .stat-dot {
    background: var(--success);
}

.stat-wrong .stat-dot {
    background: var(--danger);
}

.practice-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

/* ===== Feedback ===== */
.feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
}

.feedback.correct {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success);
}

.feedback.wrong {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.feedback.hidden {
    display: none;
}

/* ===== Complete Card ===== */
.complete-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.complete-card h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.complete-card p {
    color: var(--text-muted);
    margin: 0.3rem 0;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* ===== Keyboard Hint ===== */
.keyboard-hint {
    text-align: center;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.keyboard-hint kbd {
    display: inline-block;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-family: inherit;
    font-size: 0.75rem;
    margin: 0 0.1rem;
    min-width: 1.4rem;
    text-align: center;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.footer-link:hover {
    text-decoration: underline;
}

/* ===== Cookie Banner ===== */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 300;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cookie-banner p {
    margin: 0;
    max-width: 600px;
}

.cookie-banner .btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Admin Panel ===== */
.admin-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.admin-header-bar h1 { margin: 0; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* Login form */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
}
.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.login-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: left;
}
.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}
.login-form input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}
.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.login-form .btn { width: 100%; }
.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.admin-section { margin-bottom: 2rem; }
.admin-section h2 { margin-bottom: 1rem; font-size: 1.3rem; }

.q-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.q-info { flex: 1; min-width: 0; }
.q-info .q-meta { font-size: 0.85rem; color: var(--primary); font-weight: 700; margin-bottom: 0.25rem; }
.q-info .q-text { font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.q-upload { flex-shrink: 0; display: flex; align-items: center; gap: 0.5rem; }
.q-upload input[type="file"] { width: 180px; font-size: 0.8rem; }
.q-upload .upload-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.q-thumb { flex-shrink: 0; width: 80px; height: 60px; object-fit: contain; border-radius: 4px; border: 1px solid var(--border); background: var(--bg-secondary); }

.q-status { font-size: 0.8rem; padding: 0.2rem 0.5rem; border-radius: 4px; font-weight: 600; }
.q-status.done { background: var(--success-bg); color: var(--success); }

.delete-btn { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }

.count-badge { background: var(--bg-secondary); padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.85rem; color: var(--text-muted); margin-left: 0.5rem; }

.details-summary { cursor: pointer; color: var(--text-muted); font-weight: 600; margin-top: 1rem; }

.msg { position: fixed; top: 4rem; right: 1rem; padding: 0.75rem 1.25rem; border-radius: 8px; font-weight: 600; z-index: 400; animation: adminFadeIn 0.3s; }
.msg.ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.msg.err { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
@keyframes adminFadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .hero h1 {
        font-size: 1.5rem;
    }

    .exam-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .practice-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
        text-align: center;
    }

    nav {
        padding: 0.75rem 1rem;
    }

    main {
        padding: 1rem;
    }
}

/* ===== FAQ Page ===== */
.faq-section {
    max-width: 800px;
    margin: 0 auto;
}

.faq-category {
    font-size: 1.25rem;
    color: var(--primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.faq-category:first-child {
    margin-top: 0;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.faq-item:hover {
    border-color: var(--primary);
}

.faq-item[open] {
    border-color: var(--primary);
}

.faq-item summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    user-select: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    content: '\2212';
    color: var(--primary);
}

.faq-answer {
    padding: 0 1.25rem 1.25rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.faq-answer p {
    margin-bottom: 0.75rem;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

.faq-answer ul {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.faq-answer li {
    margin-bottom: 0.4rem;
}

.faq-answer strong {
    color: var(--text);
}
