/**
 * ============================================================
 * style.css – Custom Styles für Staatsexamen Lernprogramm
 * ============================================================
 * Ergänzt Bootstrap 5 mit eigenen Styles.
 * 
 * CSS-Lernpunkte:
 * - CSS Custom Properties (Variablen) mit var(--name)
 * - Pseudo-Klassen (:hover, :focus, :active)
 * - Flexbox und Grid-Ergänzungen
 * - Transitions für Animationen
 */

/* ============================================================
   CSS-Variablen (Custom Properties)
   Definiert in :root = gelten überall im Dokument
   ============================================================ */
:root {

    /* ============================================================
       HAUPTFARBEN
       Ändern dieser Werte ändert ALLE Bootstrap-Komponenten
       die diese Farben verwenden (Buttons, Badges, Alerts, etc.)
       ============================================================ */
    
    /* Primary: Navbar, Haupt-Buttons, Links, aktive Pagination */
    /*--bs-primary:         #1e3a5f;
    --bs-primary-rgb:     30, 58, 95;     /* Gleiche Farbe als RGB (für rgba()) */

    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-purple: #7c3aed;
    --color-bg-light: #f8fafc;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

/* ============================================================
   Basis-Styles
   ============================================================ */
body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg-light);
}

/* ============================================================
   Frage-Vorschau in der Liste (quiz.php)
   ============================================================ */
.question-preview {
    font-size: 0.9rem;
    line-height: 1.5;
    /* Text nach 2 Zeilen abschneiden (mehrzeilig) */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Hover-Effekt für Listeneinträge */
.list-group-item-action {
    transition: background-color 0.15s ease, transform 0.1s ease;
    border-left: 3px solid transparent;
}

.list-group-item-action:hover {
    border-left-color: var(--color-primary);
    transform: translateX(2px);
}

/* Beantwortete Fragen leicht abgedimmt */
.list-group-item-light {
    opacity: 0.75;
}

.list-group-item-light:hover {
    opacity: 1;
}

/* ============================================================
   Antwort-Buttons (question.php)
   ============================================================ */
.answer-btn {
    transition: all 0.2s ease;
    border-radius: var(--radius);
    font-size: 0.95rem;
}

.answer-btn:hover {
    /* Leichter Schatten + Verschiebung = "hebt sich ab" */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.answer-btn:active {
    transform: translateY(0);
}

/* Gewählte Antwort (nach Klick, vor AJAX-Response) */
.answer-btn.selected {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Antwort-Buttons deaktiviert (nach Beantwortung) */
.answer-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================
   Statistik-Balken (nach Beantwortung)
   ============================================================ */
.answer-stat {
    transition: all 0.3s ease;
    background-color: white;
}

.answer-stat:hover {
    background-color: #f1f5f9;
}

.progress {
    border-radius: 999px;
    background-color: #e2e8f0;
}

.progress-bar {
    /* Animation: Balken "wächst" von links */
    transition: width 0.8s ease-out;
    border-radius: 999px;
}

/* ============================================================
   Fragetext
   ============================================================ */
.question-text {
    font-size: 1.05rem;
    line-height: 1.7;
    white-space: pre-line;
}

/* ============================================================
   Bild-Platzhalter
   ============================================================ */
.image-placeholder {
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
    border: 2px dashed #94a3b8;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
}

.image-placeholder i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* ============================================================
   Gesperrte Folgefragen
   ============================================================ */
.locked-question {
    opacity: 0.6;
    border-left: 4px solid #94a3b8 !important;
    background-color: #f1f5f9;
}

.locked-question .card-body {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(148, 163, 184, 0.05) 10px,
        rgba(148, 163, 184, 0.05) 20px
    );
}

/* ============================================================
   Badges & Tags
   ============================================================ */
/* Lila Badge für Duplikat-Zähler */
.bg-purple {
    background-color: var(--color-purple) !important;
    color: white;
}

.badge {
    font-weight: 500;
}

/* ============================================================
   Kommentare
   ============================================================ */
.comment-item {
    padding: 0.75rem 0;
}

.comment-item:last-child {
    border-bottom: none !important;
}

/* ============================================================
   Karten (Cards)
   ============================================================ */
.card {
    border: none;
    border-radius: var(--radius);
}

.card-header {
    border-bottom: 1px solid #e2e8f0;
    background-color: white;
    font-weight: 600;
}

/* ============================================================
   Responsive Anpassungen
   ============================================================ */

/* Auf kleinen Bildschirmen: Filter-Sidebar wird zum Accordion */
@media (max-width: 991.98px) {
    .question-preview {
        -webkit-line-clamp: 1;
    }
}

/* Druckansicht */
@media print {
    .navbar, .btn, form, .progress {
        display: none !important;
    }
    
    .answer-stat {
        break-inside: avoid;
    }
}

/* ============================================================
   Loading-Spinner (für AJAX-Requests)
   ============================================================ */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Pulsierender Punkt während des Ladens */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================================
   Folgefragen-Darstellung
   ============================================================ */
.follow-up-question {
    border-left: 4px solid var(--color-primary) !important;
    background-color: #fafbfc;
    margin-left: 1rem;
}

.follow-up-question .card-header {
    border-top-left-radius: 0;
}

/* Highlight-Flash: Kurzes Aufblitzen bei Anker-Navigation */
@keyframes highlightFlash {
    0% { background-color: #fef3c7; box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.4); }
    100% { background-color: transparent; box-shadow: none; }
}

.highlight-flash {
    animation: highlightFlash 2s ease-out;
}

/* ============================================================
   Long-Menu: Wortwolke
   ============================================================ */
.wordcloud-container {
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    min-height: 100px;
}

.wordcloud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.5rem;
    line-height: 1.4;
}

.wordcloud-item {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: white;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    color: var(--color-primary);
    font-weight: 500;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: default;
}

.wordcloud-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.wordcloud-count {
    font-size: 0.7em;
    color: var(--color-text-muted);
    margin-left: 0.25em;
}

/* ============================================================
   K-prim: Checkbox-Style
   ============================================================ */
.kprim-option {
    transition: background-color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

.kprim-option:hover {
    background-color: #f1f5f9;
    border-color: var(--color-primary) !important;
}

/* Ganze Zeile klickbar machen */
.kprim-option label {
    cursor: pointer;
    margin-bottom: 0;
    width: 100%;
}

.kprim-checkbox {
    width: 1.5em;
    height: 1.5em;
    cursor: pointer;
}

/* ============================================================
   Bild-Zoom beim Klick
   ============================================================ */
img.zoomed {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 95vw !important;
    max-height: 95vh !important;
    z-index: 9999;
    cursor: zoom-out;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* Overlay unter dem Zoomed-Bild */
img.zoomed::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: -1;
}

/* ============================================================
   Kommentar-Replies
   ============================================================ */
.comment-item .reply-form {
    margin-top: 0.5rem;
}

.comment-item[data-comment-id] {
    padding-bottom: 0.5rem;
}

/* Reply-Indentation farblich */
.comment-item.ms-4 {
    border-left-color: var(--color-primary) !important;
    margin-top: 0.5rem;
}

/* ============================================================
   Amboss-Link Badge
   ============================================================ */
a.bg-info:hover {
    background-color: #0ea5e9 !important;
    text-decoration: underline !important;
}

/* ============================================================
   Online-Zähler: Pulsier-Animation bei Aktualisierung
   ============================================================ */
@keyframes onlinePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.online-pulse {
    animation: onlinePulse 0.6s ease;
}

/* Grüner Punkt: pulsiert langsam als "alive"-Indikator */
.badge .bi-circle-fill {
    animation: pulse 2s ease-in-out infinite;
    color: #bbf7d0;
}

/* ============================================================
   Feedback-Widget: Schwebender Button + Panel
   ============================================================ */

/* Floating Action Button: Schwebt rechts unten */
.feedback-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: white;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    z-index: 1050;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.feedback-fab-active {
    background-color: #64748b;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.4);
}

/* Feedback-Panel: Karte die über dem Button erscheint */
.feedback-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 340px;
    max-width: calc(100vw - 48px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 1049;
    overflow: hidden;
    animation: feedbackSlideUp 0.2s ease;
}

@keyframes feedbackSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.feedback-panel-header {
    background: var(--color-primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feedback-panel-body {
    padding: 16px;
}

/* Sterne-Bewertung */
.star-rating {
    display: flex;
    align-items: center;
    gap: 2px;
}

.star-rating .star {
    cursor: pointer;
    font-size: 1.5rem;
    color: #cbd5e1;
    transition: color 0.15s ease, transform 0.15s ease;
    line-height: 1;
}

.star-rating .star:hover {
    transform: scale(1.2);
}

/* Aktive Sterne (per JS gesetzt) */
.star-rating .star-active {
    color: #f59e0b;
}

/* 
   HOVER-TRICK: Reihenfolge der Sterne im CSS umkehren!
   
   flex-direction: row-reverse dreht die VISUELLE Anordnung um,
   sodass Stern 5 links und Stern 1 rechts steht (im CSS-Fluss).
   Dann funktioniert der ~-Selektor korrekt nach "links" (= visuell rechts).
   
   Aber wir wollen die Sterne trotzdem 1-2-3-4-5 von links nach rechts
   ANZEIGEN. Trick: Die HTML-Reihenfolge im Widget umkehren (5,4,3,2,1)
   und CSS dreht es zurück.
   
   EINFACHERE LÖSUNG: Hover komplett per JavaScript steuern.
   Das ist robuster und vermeidet CSS-Hacks.
*/
.star-rating .star-hover {
    color: #fbbf24;
}

/* Mobile: Panel breiter machen */
@media (max-width: 400px) {
    .feedback-panel {
        right: 12px;
        left: 12px;
        width: auto;
    }
    .feedback-fab {
        right: 16px;
        bottom: 16px;
    }
}