/* ==========================================================
   FI Prüfungsvorbereitung - Stylesheet
   ========================================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --card-bg: #ffffff;
    --body-bg: var(--gray-50);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #1e3a5f;
    --success: #22c55e;
    --success-light: #14332a;
    --danger: #ef4444;
    --danger-light: #3b1515;
    --warning: #f59e0b;
    --warning-light: #3b2f0f;
    --gray-50: #111827;
    --gray-100: #1f2937;
    --gray-200: #374151;
    --gray-300: #4b5563;
    --gray-400: #9ca3af;
    --gray-500: #9ca3af;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
    --gray-900: #f9fafb;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.2);
    --card-bg: #1f2937;
    --body-bg: #0f172a;
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #1e3a5f, #111827);
}

[data-theme="dark"] .alert-success { background: #14332a; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-danger { background: #3b1515; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #3b2f0f; color: #fde68a; border-color: #92400e; }
[data-theme="dark"] .alert-info { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }

[data-theme="dark"] .invite-box {
    background: #1e3a5f;
    border-color: var(--primary);
}

[data-theme="dark"] .explanation-box {
    background: #1e3a5f;
    color: #d1d5db;
}

[data-theme="dark"] .timer {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .result-detail-card.correct-bg { background: #14332a; color: #22c55e; }
[data-theme="dark"] .result-detail-card.wrong-bg { background: #3b1515; color: #ef4444; }

/* --- Theme Toggle --- */
.theme-toggle {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 0.3rem 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.theme-toggle:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
}

/* --- Auth / Standalone Page Background --- */
.auth-bg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #dbeafe, #f9fafb);
}

[data-theme="dark"] .auth-bg {
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Navbar --- */
.navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0 2rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.navbar .logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar .logo span { font-size: 1.5rem; }

.navbar nav { display: flex; gap: 0.25rem; }

.navbar nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

/* --- Container & Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container-sm {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Page Header --- */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--gray-500);
    font-size: 0.95rem;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-body { padding: 1.5rem; }

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--gray-50);
}

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

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.25s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.category-card .icon {
    font-size: 2.5rem;
    line-height: 1;
}

.category-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.category-card p {
    font-size: 0.85rem;
    color: var(--gray-500);
    flex-grow: 1;
}

.category-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--gray-400);
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

/* --- Stats Row --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    text-align: center;
}

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

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* --- Quiz --- */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-progress {
    background: var(--gray-200);
    height: 6px;
    border-radius: 3px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.quiz-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.quiz-options { display: flex; flex-direction: column; gap: 0.75rem; }

.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card-bg);
}

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

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

.quiz-option .option-marker {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-500);
    transition: all 0.2s;
    margin-top: 1px;
}

.quiz-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.quiz-option.selected .option-marker {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

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

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

.quiz-option.wrong .option-marker {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.quiz-option .option-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

.explanation-box {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
    color: var(--gray-700);
    display: none;
}

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

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

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.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-outline {
    background: var(--card-bg);
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

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

/* --- Result --- */
.result-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

.result-circle.pass { background: linear-gradient(135deg, var(--success), #22c55e); }
.result-circle.fail { background: linear-gradient(135deg, var(--danger), #ef4444); }
.result-circle .sub { font-size: 0.875rem; font-weight: 400; opacity: 0.9; }

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

.result-detail-card {
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.result-detail-card.correct-bg { background: var(--success-light); color: var(--success); }
.result-detail-card.wrong-bg { background: var(--danger-light); color: var(--danger); }

.result-detail-card .big { font-size: 1.5rem; font-weight: 700; }
.result-detail-card .label { font-size: 0.8rem; margin-top: 0.25rem; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }

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

table th,
table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

table tbody tr:hover { background: var(--gray-50); }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--gray-800);
    background: var(--card-bg);
    transition: border-color 0.2s;
}

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

select.form-control { cursor: pointer; }

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* --- Alert --- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* --- Difficulty Selector --- */
.difficulty-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 0.5rem 1.25rem;
    border: 2px solid var(--gray-200);
    border-radius: 50px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    transition: all 0.2s;
    text-decoration: none;
}

.difficulty-btn:hover,
.difficulty-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
    font-size: 0.8rem;
    margin-top: 2rem;
}

/* --- Logout Button --- */
.btn-logout {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-logout:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
}

/* --- Count Selector --- */
.count-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.count-btn {
    padding: 0.4rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 50px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.2s;
    text-decoration: none;
}

.count-btn:hover,
.count-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* --- Gauge / Progress Bars --- */
.gauge-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.progress-ring {
    width: 100%;
    height: 100%;
}

.progress-bar-horizontal {
    background: var(--gray-200);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
}

/* --- Trainer Cards --- */
.trainee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.trainee-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.5rem;
    transition: all 0.2s;
}

.trainee-card:hover {
    box-shadow: var(--shadow-md);
}

/* --- Invite Code Box --- */
.invite-box {
    background: var(--primary-light);
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.invite-code {
    font-family: 'Courier New', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.15em;
    user-select: all;
}

/* --- Role Badge --- */
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.55rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
}

.role-azubi { background: #dbeafe; color: #1d4ed8; }
.role-ausbilder { background: #fef3c7; color: #b45309; }
.role-admin { background: #fee2e2; color: #b91c1c; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .container, .container-sm { padding: 1rem; }
    .navbar { padding: 0 1rem; }
    .navbar nav { display: none; }
    .category-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .result-details { grid-template-columns: 1fr; }
    .quiz-actions { flex-direction: column; }
    .quiz-actions .btn { width: 100%; }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--card-bg));
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--gray-200);
}

.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.hero p {
    color: var(--gray-500);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

/* Timer */
.timer {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
}
