/* ===========================================================================
   style.css - Dark-Navy-Theme fuer das PV-Monitoring-Dashboard
   Design orientiert an solar_dashboard.png
   =========================================================================== */

/* --------------------------- CSS-Variablen ------------------------------- */
:root {
    --bg:            #0d1117;   /* Seitenhintergrund */
    --card:          #161b22;   /* Karten / Panels */
    --card-2:        #1c2230;   /* leicht abgehobene Flaechen */
    --border:        #21262d;   /* Rahmenfarbe */
    --text:          #e6edf3;   /* Haupttext */
    --text-dim:      #8b949e;   /* gedaempfter Text */
    --yellow:        #f59e0b;   /* Batterie */
    --green:         #22c55e;   /* SOC / aktiv */
    --blue:          #38bdf8;   /* Verbrauch */
    --orange:        #fb923c;   /* Solar */
    --accent-blue:   #3b82f6;   /* Buttons */
    --accent-purple: #6366f1;   /* Verlauf Sprachsteuerung */
    --radius:        14px;
    --shadow:        0 4px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.dashboard {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ------------------------------- Header ---------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
    font-size: 30px;
    color: var(--yellow);
    background: rgba(245, 158, 11, 0.12);
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}

.brand h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

.datetime { text-align: center; }
.dt-date { color: var(--yellow); font-weight: 600; font-size: 15px; }
.dt-time { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

.live-badge {
    display: flex; align-items: center; gap: 8px;
    color: var(--green); font-weight: 600; font-size: 13px;
    letter-spacing: 0.5px;
}
.live-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
    70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* -------------------------------- Karten --------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

/* ------------------------------ KPI-Grid --------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}
.kpi-card { transition: transform 0.15s ease, border-color 0.15s ease; }
.kpi-card:hover { transform: translateY(-3px); border-color: #30363d; }

.kpi-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.kpi-label { color: var(--text-dim); font-size: 11px; letter-spacing: 1px; font-weight: 600; }
.kpi-icon { font-size: 18px; opacity: 0.85; }

.kpi-value { font-size: 34px; font-weight: 700; line-height: 1; }
.kpi-value .unit { font-size: 15px; color: var(--text-dim); font-weight: 500; }

.kpi-trend { font-size: 12px; margin: 10px 0 12px; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--blue); }

.kpi-foot { color: var(--text-dim); font-size: 11px; margin-top: 10px; }

/* ---------------------------- Fortschrittsbalken ------------------------- */
.progress {
    width: 100%; height: 6px;
    background: var(--card-2);
    border-radius: 6px;
    overflow: hidden;
}
.progress-bar { height: 100%; border-radius: 6px; transition: width 0.5s ease; }
.bar-yellow { background: var(--yellow); }
.bar-green  { background: var(--green); }
.bar-orange { background: var(--orange); }
.bar-blue   { background: var(--blue); }

/* ---------------------------- Haupt-Grid --------------------------------- */
.main-grid {
    display: grid;
    grid-template-columns: 2.6fr 1fr;
    gap: 18px;
    align-items: start;
}

/* ------------------------------- Chart ----------------------------------- */
.chart-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.chart-head h2 { font-size: 17px; font-weight: 600; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.lg-yellow { color: var(--yellow); }
.lg-green  { color: var(--green); }
.lg-blue   { color: var(--blue); }

.chart-wrap { position: relative; height: 360px; width: 100%; }

/* ---------------------------- Zeitraum-Buttons --------------------------- */
.timeframe {
    display: flex; align-items: center; gap: 8px;
    margin-top: 16px; flex-wrap: wrap;
}
.tf-label { color: var(--text-dim); font-size: 12px; margin-right: 4px; }
.tf-btn {
    background: var(--card-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
}
.tf-btn:hover { color: var(--text); border-color: #30363d; }
.tf-btn.active {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--yellow);
    color: var(--yellow);
    font-weight: 600;
}

/* --------------------------- Rechte Spalte ------------------------------- */
.side-col { display: flex; flex-direction: column; gap: 18px; }
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* ---------------------------- Geraetezeile ------------------------------- */
.device-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.device-row:last-of-type { border-bottom: none; }
.device-icon { font-size: 20px; width: 26px; text-align: center; }
.device-info { flex: 1; }
.device-name { font-weight: 600; font-size: 14px; }
.device-meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.device-state { color: var(--text-dim); font-size: 12px; font-weight: 600; }

/* ---------------------------- Toggle-Switch ------------------------------ */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #30363d;
    border-radius: 24px;
    transition: 0.25s;
}
.slider:before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* --------------------------- Sprachsteuerung ----------------------------- */
.voice-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    transition: opacity 0.15s ease;
}
.voice-btn:hover { opacity: 0.9; }

/* --------------------------- Automatisierung ----------------------------- */
.auto-card {
    background: var(--card-2);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border-left: 3px solid var(--green);
}
.auto-card:last-child { margin-bottom: 0; }
.auto-green { border-left-color: var(--green); }
.auto-blue  { border-left-color: var(--blue); }

.auto-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.auto-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-blue  { background: var(--blue); }
.auto-text { color: var(--text-dim); font-size: 12px; line-height: 1.5; }

/* ------------------------------ Text-Akzente ----------------------------- */
.orange-text { color: var(--orange); }
.blue-text   { color: var(--blue); }
.green-text  { color: var(--green); }

/* ------------------------------ Responsive ------------------------------- */
@media (max-width: 980px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; gap: 14px; align-items: flex-start; }
    .datetime { text-align: left; }
}
