/* ══════════════════════════════════════
   PMP Quiz - Main Stylesheet
   ══════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

/* ── Navbar ── */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.navbar-brand {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
}

.navbar-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.navbar-nav a:hover, .navbar-nav a.active {
    background: rgba(255,255,255,0.2);
    color: white;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Main Content ── */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

select.form-control {
    appearance: auto;
}

/* ── Quiz Question ── */
.question-text {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 20px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary);
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.question-meta .badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.option-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.option-item:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.option-item.selected {
    border-color: var(--primary);
    background: #dbeafe;
}

.option-item.correct {
    border-color: var(--success);
    background: #dcfce7;
}

.option-item.wrong {
    border-color: var(--danger);
    background: #fef2f2;
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.option-item.selected .option-letter {
    background: var(--primary);
    color: white;
}

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

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

.option-text {
    flex: 1;
    padding-top: 4px;
}

/* ── Translation Toggle ── */
.translation-wrapper {
    display: flex;
    gap: 16px;
}

.translation-wrapper .original {
    flex: 1;
}

.translation-wrapper .translation {
    flex: 1;
    background: #fefce8;
    border-radius: var(--radius-sm);
    padding: 12px;
    display: none;
    border: 1px solid #fde047;
}

.translation-wrapper .translation.show {
    display: block;
}

.translation-toggle {
    background: #fbbf24;
    color: #78350f;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.translation-toggle:hover {
    background: #f59e0b;
}

.translation-toggle.active {
    background: #78350f;
    color: #fef3c7;
}

/* ── Explanation ── */
.explanation-box {
    margin-top: 16px;
    padding: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    display: none;
}

.explanation-box.show {
    display: block;
}

.explanation-box h4 {
    color: var(--success);
    margin-bottom: 8px;
}

/* ── Progress Bar ── */
.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ── Question Navigation ── */
.question-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0;
}

.question-nav .q-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
}

.question-nav .q-btn.answered {
    background: #dbeafe;
    border-color: var(--primary);
    color: var(--primary);
}

.question-nav .q-btn.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Result Table ── */
.result-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: var(--radius);
    text-align: center;
}

.result-summary.pass { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.result-summary.fail { background: linear-gradient(135deg, #fef2f2, #fecaca); }

.result-score {
    font-size: 3rem;
    font-weight: 800;
}

.result-detail {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-info { background: #cffafe; color: var(--info); }

/* ── Table ── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

th {
    background: #f1f5f9;
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover { background: #f8fafc; }

/* ── Flash Messages ── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ── Login Page ── */
.login-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 0 16px;
}

.login-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 20px 16px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 40px;
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab:hover { color: var(--text); }

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

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Answer Count Indicator ── */
.answer-count-hint {
    display: inline-block;
    padding: 4px 12px;
    background: #e0f2fe;
    color: var(--info);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 12px;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    .hamburger { display: block; }

    .navbar-nav {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
        flex-direction: column;
        padding: 8px;
        gap: 2px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }

    .navbar-nav.open { display: flex; }

    .navbar-nav a {
        padding: 12px 16px;
        width: 100%;
    }

    .main-content { padding: 12px 10px; }

    .card { padding: 16px; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-value { font-size: 1.5rem; }

    .translation-wrapper {
        flex-direction: column;
    }

    .result-summary {
        flex-direction: column;
        gap: 10px;
    }

    .result-score { font-size: 2rem; }

    .question-nav .q-btn {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .option-item { padding: 10px 12px; }
    .option-letter { width: 28px; height: 28px; font-size: 0.8rem; }

    table { font-size: 0.8rem; }
    th, td { padding: 8px 10px; }

    .btn { padding: 8px 16px; font-size: 0.9rem; }

    .pc-only {
        display: none !important;
    }

    .pc-only-notice {
        display: block;
        text-align: center;
        padding: 12px;
        background: #fef3c7;
        color: #92400e;
        border-radius: var(--radius-sm);
        font-size: 0.85rem;
    }
}

@media (min-width: 769px) {
    .pc-only-notice { display: none; }
    .mobile-only { display: none !important; }
}

/* ── Chart Container ── */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
}

/* ── Loading Spinner ── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Admin Table ── */
.admin-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ══════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════ */

body.dark {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 15px rgba(0,0,0,0.4);
}

body.dark .navbar {
    background: linear-gradient(135deg, #1e40af 0%, #5b21b6 100%);
}

body.dark .card { border: 1px solid var(--border); }
body.dark .btn-outline { border-color: var(--border); color: var(--text); }
body.dark .btn-outline:hover { background: var(--border); }
body.dark input, body.dark select, body.dark textarea {
    background: #0f172a;
    color: var(--text);
    border-color: var(--border);
}
body.dark .option-item { border-color: var(--border); background: var(--card-bg); }
body.dark .option-item:hover { background: #2d3f55; }
body.dark .option-item.selected { background: #1e3a5f; border-color: var(--primary); }
body.dark .option-item.correct { background: #14532d; border-color: var(--success); }
body.dark .option-item.wrong   { background: #450a0a; border-color: var(--danger); }
body.dark .flash { filter: brightness(0.8); }
body.dark table { color: var(--text); }
body.dark th { background: #1e293b !important; color: var(--text-muted) !important; }
body.dark td { border-color: var(--border) !important; }
body.dark tr:hover td { background: #1e293b !important; }
body.dark .badge-info    { background: #0c4a6e; }
body.dark .badge-success { background: #14532d; }
body.dark .badge-warning { background: #451a03; color: #fbbf24; }
body.dark .slicer-chip { background: #1e293b; color: var(--text); border-color: var(--border); }
body.dark .slicer-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
body.dark .answer-count-hint { background: #1e3a5f; }
body.dark .footer { background: #0f172a; border-top-color: var(--border); color: var(--text-muted); }
body.dark .question-nav .q-btn { background: #1e293b; color: var(--text); border-color: var(--border); }
body.dark .question-nav .q-btn.answered { background: #1e3a5f; }
body.dark .question-nav .q-btn.current  { background: var(--primary); color: #fff; }

/* ── Dark Mode Toggle Button ── */
.dark-toggle {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    white-space: nowrap;
}
.dark-toggle:hover { background: rgba(255,255,255,0.25); }

/* ══════════════════════════════════════
   BOOKMARK & REPORT BUTTONS
   ══════════════════════════════════════ */

.question-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-bookmark {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}
.btn-bookmark:hover { border-color: #f59e0b; color: #f59e0b; }
.btn-bookmark.active { border-color: #f59e0b; color: #f59e0b; background: rgba(245,158,11,0.1); }
.btn-bookmark.active .fa-bookmark { font-weight: 900; }

.btn-report {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}
.btn-report:hover { border-color: var(--danger); color: var(--danger); }

/* ── Report Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: 16px; font-size: 1.1rem; }
.modal-box label { display: block; margin-bottom: 8px; cursor: pointer; }
.modal-box label input[type=radio] { margin-right: 8px; }
.modal-box textarea {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 70px;
    background: var(--bg);
    color: var(--text);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Bookmarks Page ── */
.bookmark-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card-bg);
}
.bookmark-item .q-no { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 6px; }
.bookmark-item .q-text { font-size: 0.95rem; line-height: 1.5; }
.bookmark-item .answer-badge {
    display: inline-block;
    background: var(--success);
    color: white;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8rem;
    margin-top: 8px;
}
