/*
 * Styles für die "Meine Statistik"-Seite (stats.html).
 * Karten (.quiz-card*), Toolbar (.hub-toolbar) und Header kommen aus
 * home.css/quizhub.css/auth.css - hier nur Seitenlayout, Aside-Panels und
 * das um eine Spalte reduzierte Grid für das rechte "Meine Quizze"-Grid.
 */
/* css/stats.css */

body.stats-page {
    align-items: stretch; /* Override base.css centering */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.stats-main {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    /* Platz für den fixierten Auth-Header oben rechts + eventuelle Top-Banner */
    padding: calc(90px + var(--top-banner-height, 0px)) 24px 60px;
    flex: 1;
}

/* ─── Kopfbereich ────────────────────────────────────────────────── */
.stats-head {
    text-align: center;
    margin-bottom: 28px;
}

.stats-head h1 {
    font-size: 2.6rem;
    font-weight: 800;
    margin: 0 0 10px;
    color: var(--text-main);
}

.stats-intro {
    color: var(--text-muted);
    max-width: 640px;
    margin: 0 auto;
}

/* ─── Zwei-Spalten-Layout ────────────────────────────────────────── */
.stats-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}

/* ─── Linke Spalte: Kurzstatistik + einklappbare Listen ─────────── */
.stats-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: calc(90px + var(--top-banner-height, 0px));
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
}

.stats-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}

.stats-summary-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
}

.stats-summary-label {
    font-size: 0.78em;
    color: var(--text-muted);
}

/* Panels sind native <details>/<summary> - kein eigener JS-Toggle nötig. */
.stats-panel {
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 4px 16px;
}

.stats-panel summary {
    padding: 12px 0;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-panel summary::-webkit-details-marker {
    display: none;
}

.stats-panel summary::after {
    content: '';
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.stats-panel[open] summary::after {
    transform: rotate(45deg);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
    max-height: 360px;
    overflow-y: auto;
}

.stats-list-loading,
.stats-list-empty {
    color: var(--text-muted);
    font-size: 0.88em;
    padding: 6px 0 10px;
}

.stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-hover);
    border-radius: 10px;
}

.stats-row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.stats-row-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-row-meta {
    font-size: 0.78em;
    color: var(--text-muted);
}

.stats-row-resume {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-row-resume:hover {
    background: var(--accent-hover);
}

.stats-row-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.stats-row-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--text-muted);
    opacity: 0.4;
}

.stats-row-badge.active {
    color: var(--accent-color);
    opacity: 1;
}

.stats-row-badge .icon {
    width: 15px;
    height: 15px;
}

/* Follower/"Ich folge"-Listen (gleiches .stats-row-Muster wie oben, s.
   loadFollows() in js/stats-main.js). Die "Ich folge"-Zeile packt Avatar+Name
   UND Benachrichtigen-Checkbox+Entfolgen-Button in eine Reihe - in der
   schmalen Sidebar (.stats-side) reicht die Breite dafuer oft nicht. Ohne
   flex-wrap wuerde .stats-follow-main (erbt min-width:0 von .stats-row-main)
   komplett auf 0 zusammengedrueckt, weil .stats-follow-actions bewusst nicht
   schrumpft (flex-shrink:0) - der Name war dann unsichtbar. flex-wrap laesst
   die Aktionen bei Platzmangel in eine zweite Zeile umbrechen statt den Namen
   zu verdraengen. */
.stats-follow-row {
    flex-wrap: wrap;
}

.stats-follow-main {
    flex: 1 1 100px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.stats-follow-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.stats-follow-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: #fff;
    font-weight: 700;
    font-size: 0.9em;
}

/* "Ich folge": Name verlinkt auf quizhub.html?author=<id> (alle Quizze
   dieses Autors) - optisch weiter wie .stats-row-title, nur mit Hover. */
a.stats-follow-name {
    text-decoration: none;
    cursor: pointer;
}

a.stats-follow-name:hover {
    text-decoration: underline;
}

.stats-follow-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.stats-follow-notify {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78em;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.stats-follow-notify input {
    cursor: pointer;
}

.stats-follow-unfollow {
    flex-shrink: 0;
    padding: 6px 14px;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.stats-follow-unfollow:hover {
    background: var(--bg-hover);
}

/* ─── Erhaltene Ergebnisse (Spieler-Shares an mich als Autor) ────── */
.stats-received-quiz {
    font-weight: 600;
    font-size: 0.85em;
    margin: 10px 0 4px;
    color: var(--text-main);
}

.stats-received-quiz span {
    font-weight: 400;
    color: var(--text-muted);
}

.stats-row-message {
    display: block;
    font-size: 0.82em;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.stats-row-message.pending {
    font-style: italic;
}

.stats-row-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-muted);
    cursor: pointer;
}

.stats-row-delete:hover {
    color: var(--error-text);
}

.stats-row-delete .icon {
    width: 16px;
    height: 16px;
}

/* ─── Rechte Spalte: eigene Quizze / Favoriten ───────────────────── */
.stats-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.stats-tab {
    padding: 8px 4px 12px;
    margin-right: 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 1.15rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.18s, border-color 0.18s;
}

.stats-tab:hover {
    color: var(--text-main);
}

.stats-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--accent-color);
}

/* home.css setzt auf .quiz-cards-grid ein seitliches Padding von 24px, um die
   Karten mittig auf der Startseite auszurichten - hier soll das Grid aber
   bündig mit der Toolbar darüber sein (die kein eigenes Padding hat). */
.stats-quiz-grid {
    padding-left: 0;
    padding-right: 0;
}

/* Startseiten-Grid-Muster, aber eine Spalte weniger (max. 3 statt 4). */
@media (min-width: 768px) {
    #stats-my-quizzes .quiz-cards-grid { grid-template-columns: repeat(2, minmax(270px, 1fr)); }
}

@media (min-width: 992px) {
    #stats-my-quizzes .quiz-cards-grid { grid-template-columns: repeat(3, minmax(270px, 1fr)); }
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .stats-layout {
        grid-template-columns: 1fr;
    }
    .stats-side {
        position: static;
    }
}

@media (max-width: 640px) {
    .stats-main {
        padding-left: 14px;
        padding-right: 14px;
    }
}
