/* =========================================
   1. VARIABLES & THEME DEFINITIONS
   ========================================= */
:root {
    /* Standard (Himmel / Sky) */
    --bg-gradient-1: #e0c3fc;
    --bg-gradient-2: #8ec5fc;
    --bg-gradient-3: #ffffff;
    
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --backdrop-blur: blur(25px);
    
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    
    --accent-color: #007aff;
    --danger-color: #ff3b30;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --header-height: 70px;
    
    --font-family: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Animation Speed für Hintergrundwechsel */
    --theme-transition: 2s ease;
}

/* Dark Mode Defaults */
body.dark-mode {
    --bg-gradient-1: #0f2027; 
    --bg-gradient-2: #203a43; 
    --bg-gradient-3: #2c5364;
    
    --glass-bg: rgba(30, 30, 40, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --accent-color: #0a84ff;
}

/* --- DYNAMISCHE THEMES (Überschreiben die Farben global) --- */

/* THEME: ERDE (Grünlich, entspannt) */
body.theme-earth {
    --bg-gradient-1: #d1fae5; /* Mint */
    --bg-gradient-2: #34d399; /* Emerald */
    --bg-gradient-3: #f0fdf4; /* Weiß-Grün */
    --accent-color: #10b981;
}
body.dark-mode.theme-earth {
    --bg-gradient-1: #064e3b; --bg-gradient-2: #065f46; --bg-gradient-3: #111827;
    --accent-color: #34d399;
}

/* THEME: SPACE (Dunkel, Lila, Tief) */
body.theme-space {
    --bg-gradient-1: #312e81; /* Indigo */
    --bg-gradient-2: #4c1d95; /* Violet */
    --bg-gradient-3: #1e1b4b; /* Deep Blue */
    --accent-color: #c084fc;
    --text-primary: #e9d5ff; /* Immer hell im Space */
    --text-secondary: #a5b4fc;
    --glass-bg: rgba(20, 20, 40, 0.65);
}

/* =========================================
   2. BASIS LAYOUT & BACKGROUND
   ========================================= */
body {
    font-family: var(--font-family);
    margin: 0; padding: 0;
    height: 100vh; overflow: hidden; /* Fixiert für App-Feeling */
    color: var(--text-primary);
    background-color: var(--bg-gradient-3);
    
    /* WICHTIG: Smooth Transition für alles */
    transition: background-color var(--theme-transition), color 0.5s ease;
}

/* Background Blobs */
.ambient-background {
    position: fixed; inset: 0; z-index: -1; overflow: hidden;
}
/* Rauschen Textur */
.noise-overlay {
    position: absolute; inset: 0; opacity: 0.03; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.blob {
    position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.6;
    transition: background var(--theme-transition); /* Farbe wechselt langsam */
    animation: float-blob 20s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}
.blob-1 { top: -10%; left: -10%; width: 60vw; height: 60vw; background: var(--bg-gradient-1); animation-delay: 0s; }
.blob-2 { bottom: -10%; right: -10%; width: 70vw; height: 70vw; background: var(--bg-gradient-2); animation-delay: -5s; }
.blob-3 { top: 40%; left: 30%; width: 40vw; height: 40vw; background: rgba(255,255,255,0.2); animation-delay: -10s; }

@keyframes float-blob {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    50% { transform: translate(30px, 40px) scale(1.1) rotate(10deg); }
    100% { transform: translate(-20px, -30px) scale(0.95) rotate(-5deg); }
}

/* =========================================
   3. APP STRUCTURE & HEADER
   ========================================= */
.app-layout {
    display: flex; flex-direction: column;
    height: 100vh; max-width: 1600px; margin: 0 auto; padding: 20px;
    box-sizing: border-box; gap: 20px;
    perspective: 1200px; /* 3D Bühne */
}

.glass-header {
    height: var(--header-height); flex-shrink: 0;
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur); -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 30px; box-shadow: var(--glass-shadow);
    z-index: 50;
    transition: background 0.5s ease;
}

.header-left h1 { font-size: 1.1rem; margin: 0; font-weight: 700; transition: opacity 0.3s; }
.header-center { position: absolute; left: 50%; transform: translateX(-50%); }
.score-pill { display: flex; align-items: baseline; gap: 4px; }
.score-pill span:first-child { font-size: 1.8rem; font-weight: 800; color: var(--accent-color); line-height: 1; transition: color 0.5s; }
.score-pill .unit { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; }

.header-right { display: flex; align-items: center; gap: 15px; }

/* Atomuhr */
.atomic-clock {
    font-family: var(--font-mono); font-size: 0.95rem; font-weight: 500;
    color: var(--text-secondary); background: rgba(0,0,0,0.05);
    padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.05);
    min-width: 80px; text-align: center;
}
body.dark-mode .atomic-clock, body.theme-space .atomic-clock { 
    background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.1); color: var(--text-primary); 
}

.icon-btn { background: none; border: none; font-size: 1.4rem; cursor: pointer; transition: 0.3s; opacity: 0.7; color: var(--text-primary); }
.icon-btn:hover { opacity: 1; transform: rotate(45deg); }

/* =========================================
   4. DASHBOARD & PANELS
   ========================================= */
.dashboard-grid { flex: 1; display: grid; grid-template-columns: 350px 1fr; gap: 20px; min-height: 0; }

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--backdrop-blur); -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    display: flex; flex-direction: column; overflow: hidden;
    transition: background 0.5s ease, border-color 0.5s ease;
}

.panel-header { padding: 20px 20px 10px 20px; flex-shrink: 0; }
.panel-header h2 { margin: 0; font-size: 0.9rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.scroll-content { flex: 1; overflow-y: auto; padding: 0 15px 15px 15px; }
.scroll-content::-webkit-scrollbar { width: 5px; }
.scroll-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; }

.sidebar-column { display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.panel-ranking { flex: 3; min-height: 0; }
.panel-weekly { flex: 2; min-height: 0; }

/* Graph Panel Specials */
.panel-graph { padding: 0; position: relative; z-index: 1; background-size: 200% 200%; }

/* Chart Animation Container */
.chart-container { 
    flex: 1; position: relative; width: 100%; height: 100%; 
    padding: 10px 20px 20px 20px; box-sizing: border-box; 
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.chart-fade-out { opacity: 0; transform: scale(0.98); }

/* =========================================
   5. LISTEN & ITEMS
   ========================================= */
.ranking-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; margin-bottom: 8px;
    background: rgba(255,255,255,0.2); border-radius: var(--radius-md);
    cursor: pointer; transition: 0.2s; border: 1px solid transparent;
}
.ranking-item:hover { background: rgba(255,255,255,0.4); transform: translateY(-1px); }
.ranking-item.active { background: var(--accent-color); color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.ranking-item.active .ranking-score { color: white; }
.ranking-name { font-weight: 500; }
.ranking-score { font-weight: 700; color: var(--accent-color); }

.weekly-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; margin-bottom: 8px;
    background: rgba(255,255,255,0.1); border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-color);
}
.week-total { font-weight: 600; background: rgba(255,255,255,0.3); padding: 2px 8px; border-radius: 6px; font-size: 0.9em; }

/* =========================================
   6. GRAPH THEMES (Specific styling)
   ========================================= */
/* ERDE */
.panel-graph.theme-earth {
    background: linear-gradient(135deg, rgba(209, 250, 229, 0.4), rgba(167, 243, 208, 0.2));
    border-color: rgba(52, 211, 153, 0.4);
}
.panel-graph.theme-earth h2 { color: #065f46; }

/* HIMMEL */
.panel-graph.theme-sky {
    background: linear-gradient(135deg, rgba(219, 234, 254, 0.4), rgba(191, 219, 254, 0.2));
    border-color: rgba(96, 165, 250, 0.4);
}
.panel-graph.theme-sky h2 { color: #1e40af; }

/* SPACE */
.panel-graph.theme-space {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.4), rgba(49, 46, 129, 0.4));
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 10px 40px rgba(76, 29, 149, 0.3);
}
.panel-graph.theme-space h2 { color: #e9d5ff; text-shadow: 0 0 10px rgba(233, 213, 255, 0.5); }
/* Sternenstaub */
.panel-graph.theme-space::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background-image: radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 3px), radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 2px);
    background-size: 550px 550px, 350px 350px; background-position: 0 0, 40px 60px;
    opacity: 0.6; animation: stars-twinkle 4s infinite alternate;
}
@keyframes stars-twinkle { 0% { opacity: 0.3; transform: scale(1); } 100% { opacity: 0.7; transform: scale(1.1); } }

/* =========================================
   7. 3D REVEAL ANIMATION (Einschweben)
   ========================================= */
.animate-entry {
    opacity: 0; transform-origin: center top; will-change: transform, opacity;
    animation: reveal-3d 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes reveal-3d {
    0% { opacity: 0; transform: translateY(60px) scale(0.94) rotateX(15deg); filter: blur(10px); }
    100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0deg); filter: blur(0); }
}
/* Initial verstecken */
.glass-header, .panel-ranking, .panel-weekly, .panel-graph, .fab-container { opacity: 0; }

/* =========================================
   8. MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    body { height: auto; overflow-y: auto; }
    .app-layout { height: auto; display: block; padding: 15px; }
    .glass-header { position: sticky; top: 10px; margin-bottom: 20px; padding: 0 15px; }
    .header-center { position: static; transform: none; }
    .header-right { gap: 10px; }
    .atomic-clock { font-size: 0.8rem; padding: 4px 8px; min-width: 60px; }
    .dashboard-grid { display: flex; flex-direction: column; gap: 15px; }
    .glass-panel { min-height: 350px; }
    .chart-container { height: 350px; }
    .settings-dropdown { top: 80px; right: 20px; }
}

/* =========================================
   9. UI CONTROLS (FAB, MODALS, SETTINGS)
   ========================================= */
.fab-container { position: fixed; bottom: 30px; right: 30px; z-index: 1000; }
.fab-main { width: 60px; height: 60px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--accent-color), #0055b3); color: white; cursor: pointer; display: flex; justify-content: center; align-items: center; box-shadow: 0 10px 25px rgba(0,0,0,0.3); transition: transform 0.3s; }
.fab-main:hover { transform: scale(1.05); }
.fab-menu { position: absolute; bottom: 75px; right: 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.fab-container.open .fab-menu { pointer-events: auto; }
.fab-menu-item { padding: 12px 24px; font-weight: 600; cursor: pointer; background: var(--glass-bg); backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 30px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); transform: translateX(20px); opacity: 0; transition: 0.3s; color: var(--text-primary); }
.fab-container.open .fab-menu-item { transform: translateX(0); opacity: 1; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); backdrop-filter: blur(8px); z-index: 2000; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-content { width: 90%; max-width: 380px; padding: 30px; background: rgba(255,255,255,0.9); box-shadow: 0 20px 40px rgba(0,0,0,0.2); border-radius: var(--radius-lg); }
body.dark-mode .modal-content, body.theme-space .modal-content { background: rgba(30,30,35,0.95); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); }
.form-group input, .form-group select { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.1); background: rgba(0,0,0,0.05); color: var(--text-primary); font-size: 1rem; outline: none; }
.form-group input:focus { border-color: var(--accent-color); background: rgba(0,0,0,0.02); }
.form-actions { display: flex; gap: 10px; }
.btn-primary { flex: 1; background: var(--accent-color); color: white; border: none; padding: 12px; border-radius: 12px; font-weight: 600; cursor: pointer; }
.btn-secondary { flex: 1; background: transparent; border: 1px solid rgba(0,0,0,0.1); color: var(--text-primary); padding: 12px; border-radius: 12px; font-weight: 600; cursor: pointer; }

.settings-dropdown { position: fixed; top: 90px; right: 30px; width: 220px; padding: 20px; z-index: 200; transition: 0.3s; display: block; }
.settings-dropdown.hidden { opacity: 0; transform: translateY(-10px); pointer-events: none; }
.setting-item { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 500; font-size: 0.9rem; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.1); border-radius: 34px; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 2px; bottom: 2px; background-color: white; border-radius: 50%; transition: .4s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(20px); }

/* CRAZY MODES */
body.crazy-mode { animation: rainbow-bg 4s infinite linear; }
@keyframes rainbow-bg { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
body.crazy-mode .glass-panel { animation: shake 0.4s infinite; border: 2px solid #ff00ff; }
@keyframes shake { 0% { transform: rotate(0); } 25% { transform: rotate(0.5deg); } 75% { transform: rotate(-0.5deg); } }
body.extreme-crazy-mode { background: #000 !important; overflow: hidden !important; cursor: crosshair; }
body.extreme-crazy-mode * { animation: chaos 0.2s infinite linear !important; color: #0f0 !important; background: #000 !important; border-radius: 0 !important; border: 1px dashed #0f0 !important; font-family: 'Courier New', monospace !important; transition: none !important; }
@keyframes chaos { 0% { transform: translate(2px, 2px) skew(2deg); } 50% { transform: translate(-2px, -2px) skew(-2deg); } 100% { transform: translate(1px, -1px); } }