/* Predicted Questions - Modern Reader UI */

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

:root {
    --bg: #faf9f7;
    --surface: #fff;
    --text: #1a1a1a;
    --text-secondary: #6b6b6b;
    --accent: #d4764e;
    --accent-light: #fdf0eb;
    --accent-hover: #c4603a;
    --border: #e8e6e3;
    --sidebar-bg: #1c1917;
    --sidebar-text: #a8a29e;
    --sidebar-active: #fff;
    --tag-pdf: #5b7aa5;
    --tag-exam: #6b8f71;
    --code-bg: #1c1917;
    --code-text: #a8a29e;
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header h3 {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--sidebar-active);
}

.sidebar-header p {
    font-size: 0.75em;
    color: var(--sidebar-text);
    margin-top: 4px;
    opacity: 0.7;
}

.sidebar-menu {
    list-style: none;
    padding: 12px 0;
}

.menu-label {
    padding: 16px 20px 6px;
    font-size: 0.65em;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
}

.sidebar-menu a {
    display: block;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85em;
    transition: all 0.2s;
    border-left: 2px solid transparent;
}

.sidebar-menu a:hover {
    color: var(--sidebar-active);
    background: rgba(255,255,255,0.04);
}

.sidebar-menu a.active {
    color: var(--sidebar-active);
    border-left-color: var(--accent);
    background: rgba(255,255,255,0.06);
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 16px 20px;
    background: rgba(0,0,0,0.2);
}

.back-link {
    display: block;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85em;
    text-align: center;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    transition: all 0.2s;
}

.back-link:hover {
    color: var(--sidebar-active);
    border-color: rgba(255,255,255,0.2);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 101;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 52px;
    background: rgba(250,249,247,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 90;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-bar-title {
    font-size: 0.85em;
    font-weight: 500;
    color: var(--text-secondary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.visitor-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    color: var(--text-secondary);
    padding: 5px 10px;
    background: var(--accent-light);
    border-radius: 20px;
}

.visitor-badge strong {
    color: var(--accent);
}

.cache-status {
    font-size: 0.72em;
    color: var(--text-secondary);
    opacity: 0.6;
}

.cache-status.online {
    color: var(--tag-exam);
    opacity: 1;
}

.nav-btn-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    transition: opacity 0.2s;
}

.nav-btn-header:hover {
    opacity: 0.9;
}

/* Main Content */
.content {
    margin-left: 260px;
    padding: 76px 40px 40px;
    max-width: 820px;
    min-height: 100vh;
}

/* View Toggle Header */
.view-toggle-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.view-toggle-header span {
    font-weight: 500;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.view-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 500;
    transition: all 0.2s;
}

.view-btn.active {
    background: var(--sidebar-bg);
    color: #fff;
    border-color: var(--sidebar-bg);
}

.view-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* Header */
header {
    margin-bottom: 30px;
}

header h1 {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 4px;
}

header .subtitle {
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--accent-light);
    border-radius: 4px;
    display: inline-block;
    font-size: 0.82em;
    color: var(--accent);
    font-weight: 500;
}

/* Predict Hero */
.predict-hero {
    margin-bottom: 20px;
}

.predict-hero-btn {
    display: block;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
    transition: opacity 0.2s;
}

.predict-hero-btn:hover {
    opacity: 0.9;
}

/* Set Divider */
.set-divider {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9em;
    margin: 28px 0 16px;
}

/* Pattern Card */
.pattern-card {
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.pattern-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.pattern-icon {
    font-size: 1.5em;
}

.pattern-header h2 {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text);
}

/* Question Cards */
.question-card {
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.question-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.q-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
}

.q-num {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.82em;
    min-width: 36px;
    text-align: center;
}

.q-text {
    flex: 1;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.marks {
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 500;
    white-space: nowrap;
}

/* Source Tag */
.source-tag {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: 0.8em;
    color: var(--text-secondary);
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.source-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-btn {
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
    transition: opacity 0.2s;
    font-weight: 500;
}

.pdf-btn {
    background: var(--tag-pdf);
    color: #fff;
}

.exam-btn {
    background: var(--tag-exam);
    color: #fff;
}

.preview-btn:hover {
    opacity: 0.85;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 4px;
}

.vt-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82em;
    font-weight: 500;
    transition: all 0.2s;
}

.vt-btn.active {
    background: var(--sidebar-bg);
    color: #fff;
    border-color: var(--sidebar-bg);
}

.vt-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* Answer */
.answer {
    padding: 18px 20px;
}

.answer.hidden {
    display: none;
}

.answer h4 {
    color: var(--accent);
    margin: 12px 0 8px;
    font-size: 0.9em;
    font-weight: 600;
}

.answer p {
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.88em;
    line-height: 1.7;
}

.answer ul, .answer ol {
    margin: 8px 0 8px 20px;
    color: var(--text-secondary);
}

.answer li {
    margin-bottom: 6px;
    font-size: 0.88em;
    line-height: 1.6;
}

.answer-note {
    background: #ecfdf5;
    border-left: 3px solid var(--tag-exam);
    padding: 10px 14px;
    margin-top: 14px;
    border-radius: 0 4px 4px 0;
    font-size: 0.85em;
    color: #065f46;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.86em;
}

th, td {
    padding: 9px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--sidebar-bg);
    color: #fff;
    font-weight: 500;
    font-size: 0.92em;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--accent-light);
}

/* Code Box */
.code-box {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.code-box pre {
    color: #86efac;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.84em;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Formula Box */
.formula-box {
    background: var(--accent);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.92em;
    text-align: center;
    margin: 12px 0;
    font-weight: 500;
}

/* Calculator Box */
.calculator-box {
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 16px;
    margin: 14px 0;
}

.calculator-box h4 {
    color: var(--accent);
    margin-bottom: 12px;
    font-size: 0.88em;
}

.calculator-box label {
    font-weight: 500;
    color: var(--text);
    font-size: 0.86em;
}

.calculator-box input[type="number"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9em;
    width: 90px;
    margin: 0 8px;
    background: var(--surface);
}

.calculator-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.calculator-box button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.86em;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.calculator-box button:hover {
    opacity: 0.9;
}

#seriesResult {
    margin-top: 12px;
    padding: 14px;
    background: var(--surface);
    border-radius: 4px;
    border-left: 3px solid var(--tag-exam);
    display: none;
}

#seriesResult.show {
    display: block;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 10px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.6em;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    line-height: 1;
}

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

.modal-header {
    padding: 14px 50px 14px 20px;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.modal-header.exam-header {
    color: var(--accent);
}

.modal-body {
    padding: 16px;
    text-align: center;
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    background: var(--bg);
}

.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.modal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.modal-nav .nav-btn {
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
}

.modal-nav .nav-btn:hover {
    opacity: 0.85;
}

.modal-nav .nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.exam-nav-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
}

.exam-nav-btn:hover {
    opacity: 0.85;
}

#pdfPageInfo {
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Footer */
footer {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin-top: 20px;
    border: 1px solid var(--border);
    font-size: 0.85em;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    display: inline-block;
    margin-top: 8px;
    font-weight: 500;
}

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

/* Mobile */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

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

    .menu-toggle {
        display: block;
    }

    .top-bar {
        left: 0;
        padding: 0 16px 0 52px;
    }

    .content {
        margin-left: 0;
        padding: 64px 16px 24px;
    }

    .q-header {
        flex-wrap: wrap;
    }

    .source-tag {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .source-left {
        flex-wrap: wrap;
    }

    .predict-hero-btn {
        font-size: 0.95em;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d0cd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0afac;
}

/* Print */
@media print {
    .sidebar, .menu-toggle, .modal-overlay, .preview-btn, .top-bar {
        display: none !important;
    }

    .content {
        margin-left: 0;
        padding: 0;
    }

    .answer.hidden {
        display: block !important;
    }

    .calculator-box {
        display: none;
    }
}
