@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --accent: #8B5CF6;
    --accent-dark: #6D28D9;
    --accent-gradient: linear-gradient(135deg, #8B5CF6, #6D28D9);
    --surface: #ffffff;
    --surface-2: #f4f4f8;
    --border: rgba(0, 0, 0, 0.08);
    --text: #1a1a2e;
    --text-dim: #64748b;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --page-bg: #f8f7fc;
    --inline-code: #c02d76;
    --pre-bg: #1e1e2e;
    --pre-text: #cdd6f4;
}

html[data-theme="dark"] {
    --surface: #1e1e2e;
    --surface-2: #2a2a3e;
    --border: rgba(255, 255, 255, 0.1);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --page-bg: #141422;
    --inline-code: #f472b6;
}

html, body {
    font-family: 'Outfit', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--page-bg);
}

h1:focus {
    outline: none;
}

.content {
    padding: 1.5rem 2rem 3rem;
    max-width: 1100px;
}

.muted {
    color: var(--text-dim);
}

.page-subtitle {
    margin-top: -0.75rem;
    margin-bottom: 2rem;
}

/* Header filter bar */
.app-header {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: center;
}

.filter-bar-spacer {
    flex: 1;
    min-width: 0.5rem;
}

.theme-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease;
}

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

.level-selector,
.type-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-right: 0.25rem;
}

.filter-pill {
    background: var(--surface-2);
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 0.45rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    border-color: var(--border);
    color: var(--text);
}

.filter-pill.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
}

/* Topic grid */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.topic-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topic-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
    text-decoration: none;
    color: inherit;
}

.topic-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.topic-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: 0.5rem 0 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.topic-badges {
    margin-bottom: 1rem;
}

.mastery-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    text-transform: capitalize;
}

.badge.beginner { background: #dcfce7; color: #166534; }
.badge.intermediate { background: #dbeafe; color: #1e40af; }
.badge.expert { background: #fce7f3; color: #9d174d; }
.badge.scenario { background: #fef3c7; color: #92400e; }

html[data-theme="dark"] .badge.beginner { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .badge.intermediate { background: #1e3a8a; color: #bfdbfe; }
html[data-theme="dark"] .badge.expert { background: #831843; color: #fbcfe8; }
html[data-theme="dark"] .badge.scenario { background: #78350f; color: #fde68a; }
.badge.count { background: var(--surface-2); color: var(--text-dim); }
.badge.muted { background: var(--surface-2); color: var(--text-dim); }

/* Topic detail */
.topic-header {
    margin-bottom: 1.5rem;
}

.back-link {
    font-size: 0.9rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

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

.topic-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.btn-secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.question-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
}

.question-block.is-mastered {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.04), transparent);
}

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

.mastered-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.mastered-btn.is-mastered {
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    color: #fff;
    border-color: transparent;
}

.q-toggle {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    line-height: 1.45;
}

.toggle-icon {
    color: var(--accent);
    margin-right: 0.35rem;
}

.answer-body {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.65;
}

.answer-body pre {
    background: var(--pre-bg);
    color: var(--pre-text);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.answer-body code {
    color: var(--inline-code);
}

.answer-body pre code {
    color: inherit;
}

.followup {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: 8px;
}

.followup-question {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

a.question-ref {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

a.question-ref:hover {
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}

/* Blazor / bootstrap overrides */
a, .btn-link {
    color: var(--accent);
}

#blazor-error-ui {
    background: lightyellow;
    color: #1a1a2e;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3c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IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

html[data-theme="dark"] #blazor-error-ui {
    background: #422006;
    color: #fef3c7;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 640px) {
    .content {
        padding: 1rem;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Prep Guide form */
.prep-form {
    max-width: 560px;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.field-label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-top: 1rem;
}

.field-input {
    width: 5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}

.range-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.pool-info {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.warning-text {
    color: #b45309;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    padding: 0.85rem 1.75rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
    transition: transform 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
}

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

.inline-link {
    display: inline-block;
    text-decoration: none;
    margin-top: 1rem;
}

/* Review flashcards */
.review-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.review-card-area {
    margin-top: 1.5rem;
    outline: none;
}

.flashcard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    min-height: 220px;
}

.flashcard-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.flashcard .question-text {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.45;
}

.reveal-btn {
    margin-top: 1.25rem;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    padding: 0.85rem 1.75rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
}

.reveal-btn:hover {
    transform: translateY(-2px);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.action-btn {
    font-family: inherit;
    font-weight: 700;
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.action-btn.got-it {
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    color: #fff;
}

.action-btn.keep-practicing {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.done-state {
    text-align: center;
    padding: 2rem 1rem;
}

.done-icon {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.done-state .action-row {
    justify-content: center;
}

.kbd-hint {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 1.25rem;
}

.kbd-hint kbd {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}

/* Search */
.search-box {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    max-width: 560px;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.search-filter-toggle {
    margin-top: 0.75rem;
}

.search-meta {
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.search-results {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-result-link {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.search-result-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.12);
    color: inherit;
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-topic {
    font-size: 0.85rem;
}

.search-question {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 0.35rem;
}

.search-snippet {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Review setup */
.review-setup {
    max-width: 560px;
}

.field-select {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

.field-select option {
    background: var(--surface);
    color: var(--text);
}

.setup-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.review-toolbar {
    margin-bottom: 1rem;
}
