/* =====================================================================
   Voozalis Spielekeller 3.0 — Core-Design
   Sauber, responsive, kein abgeschnittener Text, einheitliches Gold-Theme
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. THEME-VARIABLEN (zentral — alle Farben kommen von hier)
   --------------------------------------------------------------------- */
:root {
    /* Hintergrund-Schichten (dunkel → hell) */
    --bg-main:        #0f1115;   /* Body / App-Hintergrund */
    --bg-card:        #1a1d24;   /* Standard-Card */
    --bg-elevated:    #21252e;   /* Card auf Card (z.B. Quests-Items) */
    --bg-sidebar:     #13161c;   /* Linke/Rechte Sidebar */
    --bg-input:       #0a0c10;   /* Input-Felder */
    --bg-overlay:     rgba(8, 10, 14, 0.85);

    /* Brand-Akzent (Brushed Gold) */
    --accent:         #d4af37;
    --accent-hover:   #e6c14d;
    --accent-dim:     rgba(212, 175, 55, 0.12);
    --accent-border:  rgba(212, 175, 55, 0.35);

    /* Status-Farben */
    --success:        #10b981;
    --success-dim:    rgba(16, 185, 129, 0.12);
    --danger:         #ef4444;
    --danger-dim:     rgba(239, 68, 68, 0.12);
    --info:           #3b82f6;

    /* Text-Schichten */
    --text-main:      #e2e8f0;
    --text-bright:    #f8fafc;
    --text-muted:     #94a3b8;   /* Aufgehellt für bessere Lesbarkeit */
    --text-dim:       #64748b;

    /* Borders / Schatten */
    --border:         #262b35;
    --border-strong:  #3a4150;
    --shadow-sm:      0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-md:      0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-gold:    0 4px 16px rgba(212, 175, 55, 0.18);

    /* Spacing (8px-Grid) */
    --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px;
    --sp-4: 16px; --sp-5: 24px;  --sp-6: 32px;
    --sp-7: 48px; --sp-8: 64px;

    /* Radius */
    --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-xl: 20px;

    /* Schriften */
    --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ---------------------------------------------------------------------
   2. RESET & BASE
   --------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;            /* App regelt eigenes Scrolling pro Spalte */
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar (für innere scrollende Container) */
*::-webkit-scrollbar         { width: 8px; height: 8px; }
*::-webkit-scrollbar-track   { background: transparent; }
*::-webkit-scrollbar-thumb   { background: var(--border-strong); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Mono für Währungen */
.currency-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------
   3. APP-LAYOUT (3-Spalten, responsive)
   --------------------------------------------------------------------- */
.keller-app-container {
    display: grid;
    grid-template-columns: 240px 1fr 340px;   /* Menü | Center | Sidebar */
    grid-template-rows: 100vh;
    height: 100vh;
    width: 100vw;
    background: var(--bg-main);
}

/* Linke Spalte — Navigation */
.keller-sidebar-left {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;                 /* WICHTIG: damit Kinder scrollen können */
    padding: var(--sp-5);
    gap: var(--sp-4);
}

.keller-logo {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-shrink: 0;
}

.keller-logo .logo-icon { font-size: 28px; }

.keller-logo h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--accent);
    line-height: 1.1;
}

.keller-logo small {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1.5px;
    display: block;
    margin-top: 2px;
}

/* Navigation-Container (scrollt) */
.keller-nav {
    flex: 1 1 auto;
    min-height: 0;                 /* Flexbox-Scroll-Fix */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding-right: var(--sp-1);    /* Platz für Scrollbar */
}

.nav-separator {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: 700;
    margin: var(--sp-4) var(--sp-1) var(--sp-2);
    padding-left: var(--sp-3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    padding: var(--sp-3) var(--sp-3);
    border-radius: var(--r-md);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-bright);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent-border);
    font-weight: 600;
}

.nav-item .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Theme-Switcher (unten fixiert) */
.theme-switcher-box {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    font-size: 12px;
    color: var(--text-muted);
}

.keller-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    width: 100%;
}

.keller-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------------------------------------------------------------------
   4. MITTLERE SPALTE — Spielplatz
   --------------------------------------------------------------------- */
.keller-spielplatz {
    padding: var(--sp-6) var(--sp-7);
    overflow-y: auto;
    min-height: 0;
    min-width: 0;                  /* WICHTIG: damit Flex/Grid-Kinder schrumpfen */
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.dashboard-welcome {
    max-width: 720px;
    margin: 0 auto var(--sp-6);
    text-align: center;
    width: 100%;
}

.dashboard-welcome h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: var(--sp-2);
}

.dashboard-welcome p {
    color: var(--text-muted);
    font-size: 14px;
}

.dashboard-stats-strip {
    margin-top: var(--sp-6);
    display: flex;
    justify-content: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.quick-stat {
    min-width: 220px;
    text-align: center;
    padding: var(--sp-5) var(--sp-6);
}

.quick-stat small {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    display: block;
    margin-bottom: var(--sp-2);
}

.quick-stat .currency-amount {
    font-size: 28px;
    color: var(--accent);
}

/* Feature-Bar (zwei Features nebeneinander) */
.feature-bar {
    display: flex;
    gap: var(--sp-4);
    justify-content: center;
    margin-top: var(--sp-5);
    flex-wrap: wrap;
}

.feature-bar > div { min-width: 0; flex: 1 1 280px; max-width: 400px; }

/* Feature-Slots (volle Breite) */
[id^="feature-"] {
    margin-top: var(--sp-4);
}

/* ---------------------------------------------------------------------
   5. RECHTE SPALTE — Leaderboard & Chat
   --------------------------------------------------------------------- */
.keller-sidebar-right {
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding: var(--sp-5);
    min-height: 0;
    min-width: 0;
    overflow: hidden;               /* Verhindert dass Inhalt die Spalte sprengt */
}

.keller-card {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    min-width: 0;                  /* WICHTIG: für Flex/Grid-Inhalt */
}

.rangliste-box { flex: 0 0 auto; max-height: 35%; display: flex; flex-direction: column; min-height: 0; }
.chat-box     { flex: 1 1 auto;  min-height: 0; display: flex; flex-direction: column; }

.keller-sidebar-right h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: var(--sp-3);
    color: var(--text-bright);
    flex-shrink: 0;
}

/* Leaderboard */
.rangliste-header {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-2);
    flex-shrink: 0;
}

.rangliste-list {
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.rangliste-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-2);
    font-size: 12px;
    padding: var(--sp-2) 0;
    border-bottom: 1px solid rgba(38, 43, 53, 0.4);
    min-width: 0;
}

.rangliste-item:last-child { border-bottom: none; }

.rangliste-item .rang-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.rangliste-item .rang-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    flex-shrink: 0;
    font-size: 12px;
}

.rangliste-item.loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: var(--sp-5);
}

/* Chat */
.chat-sound-banner {
    background: rgba(212, 175, 55, 0.05);
    border: 1px dashed var(--accent-border);
    border-radius: var(--r-md);
    text-align: center;
    padding: var(--sp-2);
    margin-bottom: var(--sp-3);
    flex-shrink: 0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-sans);
    padding: var(--sp-1) var(--sp-2);
}

.btn-text:hover { color: var(--accent); }

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    font-size: 13px;
    margin-bottom: var(--sp-3);
    word-wrap: break-word;          /* Lange Wörter umbrechen */
    overflow-wrap: break-word;
}

.chat-system-msg {
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
    text-align: center;
    padding: var(--sp-2);
}

.chat-input-area {
    display: flex;
    gap: var(--sp-2);
    flex-shrink: 0;
    min-width: 0;
}

#chat-input {
    flex: 1 1 auto;
    min-width: 0;                  /* Damit flex-shrink funktioniert */
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 13px;
}

#chat-input::placeholder {
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

#chat-send-btn {
    background: var(--accent);
    color: #0a0c10;
    border: none;
    border-radius: var(--r-md);
    padding: 0 var(--sp-4);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
    white-space: nowrap;
}

#chat-send-btn:hover { background: var(--accent-hover); }

/* ---------------------------------------------------------------------
   6. AUTH / LOGIN OVERLAY
   --------------------------------------------------------------------- */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: var(--sp-4);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: var(--sp-7);
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md), var(--shadow-gold);
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: var(--sp-5);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    text-align: left;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.form-group label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-weight: 600;
}

.form-group input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}

.btn-primary-action {
    background: var(--accent);
    color: #0a0c10;
    border: none;
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: background 0.15s;
}

.btn-primary-action:hover { background: var(--accent-hover); }

.btn-secondary-action {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    border-radius: var(--r-md);
    padding: var(--sp-3) var(--sp-4);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all 0.15s;
}

.btn-secondary-action:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--accent);
    color: var(--accent);
}

.auth-error {
    background: var(--danger-dim);
    border: 1px solid var(--danger);
    color: #fca5a5;
    font-size: 13px;
    padding: var(--sp-3);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-4);
    text-align: center;
}

/* ---------------------------------------------------------------------
   7. RESPONSIVE — Mobile / Tablet
   --------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .keller-app-container {
        grid-template-columns: 200px 1fr 300px;
    }
    .keller-spielplatz { padding: var(--sp-5); }
}

@media (max-width: 900px) {
    .keller-app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    .keller-sidebar-left  { max-height: 50vh; border-right: none; border-bottom: 1px solid var(--border); }
    .keller-sidebar-right { max-height: 40vh; border-left: none; border-top: 1px solid var(--border); }
}
