/* CSS-Variablen mit Gruppierung */
:root {
    /* Grundfarben */
    --background-color: #fff;
    --text-color: #333;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Navbar & Statusbar */
    --navbar-bg: #3498db;
    --navbar-text: #fff;
    --status-bg: #3498db;
    --status-text: #fff;
    --nav-link-hover: #ddd;
    
    /* Buttons */
    --button-bg: #3498db;
    --button-text: #fff;
    --button-hover-bg: #2980b9;
    --button-disabled-bg: #bdc3c7;
    --check-button-bg: #007bff;
    --check-button-hover-bg: #0056b3;
    
    /* Rahmen */
    --border-color: #ccc;
    --border-light: #ddd;
    --border-feedback: #e0e0e0;
    
    /* Quiz-Elemente */
    --quiz-header: #2c3e50;
    --question-bg: #fafafa;
    --question-text: #2c3e50;
    --options-bg: #f9f9f9;
    --options-hover: #e0f7e0;
    --label-hover: #c9ecef;
    
    /* Fortschritt & Timer */
    --progress-bg: #e0e0e0;
    --progress-fill: #6f42c1;
    --progress-timer: #b3c3c5;
    
    /* Feedback */
    --correct-bg: #d4edda;
    --correct-text: #155724;
    --correct-border: #c3e6cb;
    --incorrect-bg: #f8d7da;
    --incorrect-text: #721c24;
    --incorrect-border: #f5c6cb;
    
    /* Ergebnisse */
    --results-bg: #ecf0f1;
    --results-error: #e74c3c;
    --correct-answer: #27ae60;
    --explanation-bg: #f9f9f9;
    --explanation-text: #7f8c8d;
    
    /* Interaktion */
    --icon-hover: #1976d2;
}

/* Dark Theme */
.dark-theme {
    --background-color: #1a1a1a;
    --text-color: #fff;
    --shadow-color: rgba(0, 0, 0, 0.5);
    
    --navbar-bg: #2c3e50;
    --status-bg: #2c3e50;
    --nav-link-hover: #e2e8f0;
    
    --button-bg: #2c3e50;
    --button-hover-bg: #2b6cb0;
    --button-disabled-bg: #718096;
    --check-button-bg: #3182ce;
    --check-button-hover-bg: #2c5282;
    
    --border-color: #4a5568;
    --border-light: #718096;
    --border-feedback: #4a5568;
    
    --quiz-header: #e2e8f0;
    --question-bg: #2d3748;
    --question-text: #fff;
    --options-bg: #2d3748;
    --options-hover: #4a5568;
    --label-hover: #4a5568;
    
    --progress-bg: #4a5568;
    --progress-fill: #9b59b6;
    --progress-timer: #a0aec0;
    
    --correct-bg: #38a169;
    --correct-text: #e6fffa;
    --correct-border: #2f855a;
    --incorrect-bg: #e53e3e;
    --incorrect-text: #fff;
    --incorrect-border: #c53030;
    
    --results-bg: #2d3748;
    --results-error: #feb2b2;
    --correct-answer: #68d391;
    --explanation-bg: #2d3748;
    --explanation-text: #a0aec0;
    
    --icon-hover: #63b3ed;
}

/* Basis-Styles */
html {
    font-size: 16px;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: 'Arial', sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 5px 0 60px;
    line-height: 1.1;
    width: 100%;
    touch-action: none;
    overflow: hidden;
}

/* Container */
#quiz-container, #question-container {
    width: 90%;
    max-width: 900px;
    margin: 1rem auto;
    padding: 1.5rem;
    padding-top: 3rem;
    background: var(--background-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
}

#question-container {
    overflow-y: auto;
    height: calc(100vh - 110px);
    touch-action: pan-y pinch-zoom;
    transform-origin: 0 0;
    margin-top: 50px;
    margin-bottom: 50px;
    transform-origin: center center;
}

/* Typografie */
h2 { color: var(--quiz-header); font-size: 2rem; text-align: center; margin-bottom: 1rem; }
#question-container p { font-size: 1.25rem; color: var(--question-text); margin-bottom: 0.75rem; }

#progress { flex-grow: 1; font-size: 1rem; font-weight: bold; color: var(--progress-timer); text-align: center; margin: 0rem 0; }
#timer { font-size: 1rem; color: var(--progress-timer); text-align: center; margin: 0rem 0; }
#page-info { font-size: 1rem; color: var(--progress-timer); text-align: center; margin: 0rem 0; }

/* Formularelemente */
#quiz-select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.5rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    background: var(--background-color);
    color: var(--text-color);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

#quiz-select:focus {
    outline: none;
    border-color: var(--button-bg);
}

button {
    padding: 0.75rem 1.25rem;
    font-size: 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin: 0.5rem 0;
    min-height: 44px;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

button:not(:disabled) { background: var(--button-bg); color: var(--button-text); }
button:not(:disabled):hover { background: var(--button-hover-bg); transform: translateY(-2px); }
button:disabled { background: var(--button-disabled-bg); cursor: not-allowed; }

/* Fragen & Optionen */
.question {
    display: block;
    margin-bottom: 1.5rem;
    padding: 0.2rem;
    background: var(--question-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
}

.question:hover { box-shadow: 0 2px 10px var(--shadow-color); }

.question-number {
    margin: 0;
}

.options label {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin: 0.25rem 0;
    font-size: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--options-bg);
    cursor: pointer;
    transition: background-color 0.2s;
}

.options label:hover { background: var(--label-hover); }
.options label.correct-option { background: var(--correct-bg); border-color: var(--correct-border); }
.options label.incorrect-option { background: var(--incorrect-bg); border-color: var(--incorrect-border); }

input[type="radio"], input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 1.5rem;
    height: 1.5rem;
    accent-color: var(--button-bg);
}

/* Fortschrittsbalken */
.progress-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
    padding: 0 1rem;
}

.progress-text { font-size: 0.8rem; font-weight: bold; color: var(--text-color); }
.progress-bar { flex-grow: 0.9; height: 5px; background: var(--progress-bg); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--progress-fill); border-radius: 5px; transition: width 0.3s ease; }

/* Pagination */
.pagination {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.pagination-buttons { display: flex; justify-content: space-between; width: 100%; }
.pagination-buttons button { padding: 0.5rem 1rem; font-size: 1rem; width: auto; }

/* Feedback */
.check-answer { margin-top: 0.75rem; }
.feedback {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-feedback);
    border-radius: 5px;
    background: var(--options-bg);
}

.feedback.correct { background: var(--correct-bg); color: var(--correct-text); border-color: var(--correct-border); }
.feedback.incorrect { background: var(--incorrect-bg); color: var(--incorrect-text); border-color: var(--incorrect-border); }

/* Ergebnisse */
#results {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--results-bg);
    border-radius: 8px;
    overflow-y: auto;
    height: calc(100vh - 110px);
    touch-action: pan-x pan-y pinch-zoom;
}

#results h2 { font-size: 1.5rem; }
#results h3 { color: var(--results-error); font-size: 1.25rem; margin-top: 1rem; }
#results p { font-size: 1rem; margin: 0.5rem 0; }
#results p.correct-answer { color: var(--correct-answer); font-weight: bold; }
#results p.explanation { font-style: italic; color: var(--explanation-text); font-size: 0.875rem; background: var(--explanation-bg); padding: 0.5rem; border-radius: 4px; }

.question-image { margin: 0.75rem 0; border: 1px solid var(--border-color); border-radius: 5px; max-width: 100%; height: auto; }

/* Navbar & Hamburger */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    padding: 0 1rem;
    background: var(--navbar-bg);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    touch-action: none;
}

.hamburger { display: none; cursor: pointer; }
.bar { display: block; width: 25px; height: 3px; margin: 5px auto; background: var(--navbar-text); transition: all 0.3s ease-in-out; }

.nav-menu {
    position: fixed;
    left: -100%;
    top: 50px;
    flex-direction: column;
    background: var(--navbar-bg);
    width: 100%;
    text-align: center;
    transition: 0.3s;
    list-style: none;
    padding: 0;
    margin: 0;
    touch-action: none;
}

.nav-item { margin: 1.5rem 0; }
.nav-link { color: var(--navbar-text); text-decoration: none; }
.nav-link:hover { color: var(--nav-link-hover); }

/* Statusbar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: var(--status-bg);
    color: var(--status-text);
    display: block;
/*    display: flex; */
/*    flex-direction: column; */
    justify-content: center; 
    font-size: 10px;
    line-height: 15px;
    padding: 0 0.5rem;
    z-index: 1000;
    touch-action: none;
}

.status-table {
    width: 100%;
    border-collapse: collapse; /* Zellen ohne Lücken */
    table-layout: fixed; /* Erzwingt stabiles Tabellenlayout */
}

.status-table td {
    padding: 1px;
}

/* Icon-Buttons */
.icon-btn, .icon-btn-check, .icon-btn-theme {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 30px;
    height: 30px;
    transition: transform 0.1s ease; /* Nur für sanfte Bewegung */    
}

/* Spezifische Positionierung für icon-btn-check */
.icon-btn-check {
    position: absolute;
    left: 50%; 
    /* Fixiere die Position */
    margin: 0; /* Entfernt mögliche Margin-Interferenzen */
}

/* Theme-Button bleibt rechts */
.icon-btn-theme {
    margin-left: auto; /* Schiebt es ganz nach rechts */
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    stroke: var(--navbar-text);
    fill: none;
    transition: stroke 0.3s ease;
}

.icon-btn:hover svg, .icon-btn-check:hover svg, .icon-btn-theme:hover svg {
    stroke: var(--icon-hover);
}

/* Verhindere Hintergrund und Springen beim Klick */
.icon-btn:active, .icon-btn-check:active, .icon-btn-theme:active,
.icon-btn:focus, .icon-btn-check:focus, .icon-btn-theme:focus {
    background: transparent;
    outline: none; /* Entfernt Fokus-Rahmen */
}

#theme-icon .sun { opacity: 1; }
#theme-icon .moon { opacity: 0.5; }

/* Dark Theme spezifische Anpassungen */
.dark-theme .icon-btn,
.dark-theme .icon-btn-check,
.dark-theme .icon-btn-theme {
    background: transparent; /* Explizit transparent im Dark-Theme */
}

.dark-theme .icon-btn svg,
.dark-theme .icon-btn-check svg,
.dark-theme .icon-btn-theme svg {
    stroke: var(--navbar-text);
}

.dark-theme .icon-btn:hover svg,
.dark-theme .icon-btn-check:hover svg,
.dark-theme .icon-btn-theme:hover svg {
    stroke: var(--nav-link-hover);
}

.dark-theme .icon-btn:active,
.dark-theme .icon-btn-check:active,
.dark-theme .icon-btn-theme:active {
    background: transparent;
}

.dark-theme #theme-icon .sun { opacity: 0.5; }
.dark-theme #theme-icon .moon { opacity: 1; }

.deep-explanation-toggle {
    display: inline-block;
    cursor: pointer;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.deep-explanation-toggle svg {
    stroke: #3498db;
}

.deep-explanation-toggle:hover svg {
    stroke: #1d6fa5;
}

.deep-explanation {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f0f0f0;
    border-radius: 4px;
    display: none; /* Standardmäßig versteckt */
}

/* Responsive Design */
@media (max-width: 768px) {
    html { font-size: 15px; }
    #quiz-container { width: 95%; margin: 0.5rem auto; padding: 1rem; padding-top: 3rem; }
    #question-container { width: 95%; margin: 0.5rem auto; padding: 0rem; }
    h2 { font-size: 1.75rem; }
    #quiz-select, button { font-size: 1.25rem; padding: 0.5rem 1rem; }
    #question-container p, .options label { font-size: 1.1rem; padding: 0.5rem; }
    input[type="radio"], input[type="checkbox"] { width: 1.25rem; height: 1.25rem; }
    #progress, #timer { font-size: 0.9rem; }
    #results h2 { font-size: 1.25rem; }
    #results h3 { font-size: 1.1rem; }
    #results p { font-size: 0.9rem; }
    #results p.explanation { font-size: 0.8rem; padding: 0.4rem; }
    
    .hamburger { display: block; } 

    .nav-menu.active { left: 0; }
    .hamburger.active .bar:nth-child(2) { opacity: 0; }
    .hamburger.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .hamburger.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
    .icon-btn-theme { margin-right: 1rem; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    #quiz-container { width: 98%; margin: 0.25rem auto; padding: 0.75rem; padding-top: 3.5rem; }
    #question-container { width: 98%; margin: 0.25rem auto; padding: 0rem; }
    h2 { font-size: 1.5rem; }
    #quiz-select, button { font-size: 1rem; padding: 0.5rem 0.75rem; }
    #question-container p, .options label { font-size: 1rem; }
    #progress, #timer { font-size: 0.875rem; }
    #results h2 { font-size: 1.1rem; }
    #results h3 { font-size: 1rem; }
    #results p { font-size: 0.875rem; }
    #results p.explanation { font-size: 0.75rem; padding: 0.3rem; }
}

@media (hover: none) {
    button:not(:disabled):hover { background: var(--button-bg); transform: none; }
    .question:hover { box-shadow: none; }
    .options label:hover { background: var(--options-bg); }
}