/* ============================================
   Waffensachkunde PWA - Dark Theme Design
   ============================================ */

:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1c1c1c;
    --bg-card-hover: #242424;
    --bg-input: #1a1a1a;
    --accent: #c8102e;
    --accent-hover: #e0122f;
    --accent-light: rgba(200, 16, 46, 0.15);
    --text-primary: #f0f0f0;
    --text-secondary: #888;
    --text-muted: #555;
    --success: #2ecc71;
    --success-light: rgba(46, 204, 113, 0.15);
    --error: #e74c3c;
    --error-light: rgba(231, 76, 60, 0.15);
    --warning: #f39c12;
    --border: #2a2a2a;
    --border-light: #333;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', monospace;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f3f5;
    --bg-input: #f8f9fa;
    --accent: #c8102e;
    --accent-hover: #a00d25;
    --accent-light: rgba(200, 16, 46, 0.1);
    --text-primary: #1a1a2e;
    --text-secondary: #495057;
    --text-muted: #868e96;
    --success: #2b8a3e;
    --success-light: rgba(43, 138, 62, 0.1);
    --error: #c8102e;
    --error-light: rgba(200, 16, 46, 0.1);
    --warning: #e67700;
    --border: #dee2e6;
    --border-light: #e9ecef;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* Theme transition */
* {
    transition: background-color var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

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

html {
    scroll-behavior: smooth;
}

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

/* ---- Layout ---- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    padding: 40px 0;
}

/* ---- Header / Navbar ---- */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.navbar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
}

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

.navbar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: var(--transition);
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

.navbar-nav .btn-nav {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.navbar-nav .btn-nav:hover {
    background: var(--accent-hover);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
    margin-right: 8px;
}

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

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.theme-toggle .theme-icon-sun,
.theme-toggle .theme-icon-moon {
    font-size: 1.1rem;
    line-height: 1;
    transition: opacity var(--transition), transform var(--transition);
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

/* ---- Hero Section ---- */
.hero {
    text-align: center;
    padding: 80px 20px 60px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.2;
}

.hero h1 .accent {
    color: var(--accent);
}

.hero .subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    font-family: var(--font);
    line-height: 1;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(200, 16, 46, 0.3);
}

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

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

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

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

.btn-lg {
    padding: 16px 32px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.card .card-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}

/* ---- Auth Pages ---- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-primary);
}

.auth-box {
    width: 100%;
    max-width: 420px;
}

.auth-box .auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-box .auth-header .brand-icon {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: white;
    margin: 0 auto 16px;
}

.auth-box .auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-box .auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-box .card {
    padding: 32px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.auth-footer a:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.alert-error {
    background: var(--error-light);
    color: var(--error);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

/* ---- Quiz App ---- */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 24px;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.question-meta .badge {
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 24px;
}

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

.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    line-height: 1.5;
}

.answer-option:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.answer-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.answer-option.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.answer-option.incorrect {
    border-color: var(--error);
    background: var(--error-light);
}

.answer-option .answer-letter {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.answer-option.selected .answer-letter {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

.answer-option.incorrect .answer-letter {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.answer-option input[type="checkbox"],
.answer-option input[type="radio"] {
    display: none;
}

.explanation {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: none;
}

.explanation.visible {
    display: block;
}

.explanation strong {
    color: var(--text-primary);
}

.quiz-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-progress {
    margin-bottom: 12px;
}

.category-progress .category-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.category-progress .category-name {
    color: var(--text-primary);
    font-weight: 500;
}

.category-progress .category-pct {
    color: var(--text-secondary);
}

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

.category-progress .progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ---- Mode Selection ---- */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

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

.mode-card .mode-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.mode-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.mode-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ---- Prüfungssimulation: große Kachel ---- */
.exam-tile {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 28px 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.exam-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(200, 16, 46, 0.4);
}

.exam-tile-icon {
    font-size: 3rem;
    flex-shrink: 0;
}

.exam-tile-content {
    flex: 1;
}

.exam-tile-content h3 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.exam-tile-content p {
    font-size: 0.9rem;
    opacity: 0.92;
}

.exam-tile-btn {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ---- Musterantwort (Blur) ---- */
.muster-antwort {
    position: relative;
    background: var(--bg-card);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    user-select: none;
}

.muster-antwort:hover {
    border-color: var(--accent);
}

.muster-blur {
    filter: blur(8px);
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.7;
    pointer-events: none;
}

.muster-antwort.revealed .muster-blur {
    filter: none;
}

.muster-antwort.revealed {
    border-style: solid;
    border-color: var(--success);
    background: var(--bg-card);
}

.muster-hint {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.muster-antwort.revealed .muster-hint {
    display: none;
}

/* ---- Nachschlage-Infos (ID, Kapitel, Katalog-Link) ---- */
.lookup-box {
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.lookup-box a {
    color: var(--accent);
    text-decoration: none;
}

.lookup-box a:hover {
    text-decoration: underline;
}

.lookup-label {
    font-weight: 700;
    color: var(--text-muted);
}

/* ---- Exam Mode ---- */
.exam-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.exam-timer.warning {
    color: var(--warning);
    border-color: var(--warning);
}

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

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

/* ---- Category Filter ---- */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.category-chip {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.category-chip:hover,
.category-chip.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---- Guest Banner ---- */
.guest-banner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.guest-banner a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

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

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

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

.footer .footer-links {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 8px;
}

/* ---- Features Section ---- */
.features {
    padding: 60px 0;
}

.features h2 {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: 40px;
}

/* ---- Disclaimer ---- */
.disclaimer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 40px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.disclaimer strong {
    color: var(--text-secondary);
}

/* ---- Result Screen ---- */
.result-screen {
    text-align: center;
    padding: 40px 20px;
}

.result-screen .result-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.result-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.result-screen .result-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
    margin: 16px 0;
}

.result-screen .result-pass {
    color: var(--success);
}

.result-screen .result-fail {
    color: var(--error);
}

.result-details {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 24px 0;
    flex-wrap: wrap;
}

.result-detail {
    text-align: center;
}

.result-detail .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.result-detail .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Number Input for Question Count ---- */
.number-input {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.number-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-input button:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.number-input .number-display {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 60px;
    text-align: center;
}

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

    .hero .subtitle {
        font-size: 1rem;
    }

    .navbar-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 12px;
    }

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

    .menu-toggle {
        display: block;
    }

    .question-card {
        padding: 20px;
    }

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

    .result-details {
        flex-direction: column;
        gap: 12px;
    }

    .guest-banner {
        flex-direction: column;
        text-align: center;
    }

    .exam-tile {
        flex-direction: column;
        text-align: center;
        padding: 24px 20px;
        gap: 10px;
    }

    .exam-tile-btn {
        margin-top: 6px;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 50px 16px 40px;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .card-grid,
    .mode-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
