/* ==========================================================================
   Home Dashboard – TV-Ansicht
   Referenzauflösung 1920x1080, skaliert responsiv über rem/vw ohne Scrollbars
   ========================================================================== */

:root {
  --bg: #02080d;
  --card-bg: #06121a;
  --card-bg-2: #081824;
  --border: #183441;
  --text: #f2f5f7;
  --text-muted: #7f9aa6;
  --green: #7ee52f;
  --blue: #48aaff;
  --yellow: #ffc400;
  --orange: #ff8a00;
  --red: #ff4040;

  --radius: 16px;
  --gap: 14px;
  --glow-green: 0 0 14px rgba(126, 229, 47, 0.35);
  --glow-orange: 0 0 14px rgba(255, 138, 0, 0.4);
  --glow-red: 0 0 16px rgba(255, 64, 64, 0.45);
  --glow-blue: 0 0 12px rgba(72, 170, 255, 0.3);

  --fs-base: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(72, 170, 255, 0.06), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(126, 229, 47, 0.04), transparent 40%),
    var(--bg);
}

.tv-frame {
  width: 100vw;
  height: 100vh;
  padding: 1.1vh 1.2vw;
  display: flex;
  flex-direction: column;
  gap: 1vh;
  transition: transform 3s linear, filter 1.5s ease;
}

body.night-mode .tv-frame {
  filter: brightness(0.55);
}

.card {
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--card-bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1vh 1.3vw;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1vh 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
}

.card h2 [data-lucide] {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--blue);
}

.muted-small { color: var(--text-muted); font-size: 0.82rem; }

/* --------------------------------------------------------------------
   Header
   -------------------------------------------------------------------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 1.4vh 1.5vw;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-left [data-lucide] {
  width: 2rem;
  height: 2rem;
  color: var(--blue);
  filter: drop-shadow(var(--glow-blue));
}

.header h1 {
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.8rem;
}

.header-date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}

#header-date { font-size: 1.05rem; color: var(--text-muted); }
.header-time { font-size: 2rem; font-weight: 700; }

.header-weather {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-weather [data-lucide] {
  width: 2.1rem;
  height: 2.1rem;
  color: var(--yellow);
}

.header-weather-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

#header-temp { font-size: 1.4rem; font-weight: 700; }

/* --------------------------------------------------------------------
   Status-Punkte
   -------------------------------------------------------------------- */

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  display: inline-block;
  background: var(--green);
  box-shadow: var(--glow-green);
}

.status-ok { background: var(--green); box-shadow: var(--glow-green); }
.status-warning { background: var(--yellow); box-shadow: 0 0 12px rgba(255, 196, 0, 0.4); }
.status-orange { background: var(--orange); box-shadow: var(--glow-orange); }
.status-critical { background: var(--red); box-shadow: var(--glow-red); animation: pulse-red 1.6s infinite; }

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.text-ok { color: var(--green); }
.text-warning { color: var(--yellow); }
.text-orange { color: var(--orange); }
.text-critical { color: var(--red); }

/* --------------------------------------------------------------------
   Hauptraster
   -------------------------------------------------------------------- */

.grid-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
}

.row-top, .row-mid, .row-bottom {
  display: grid;
  gap: var(--gap);
  flex: 1 1 0;
  min-height: 0;
}

.row-top { grid-template-columns: 1fr 1fr 1.15fr; }
.row-mid { grid-template-columns: 1.25fr 0.85fr 1fr; }
.row-bottom { grid-template-columns: 0.7fr 0.7fr 1.7fr; }

.row-top .card, .row-mid .card, .row-bottom .card {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------
   PV / Energiefluss
   -------------------------------------------------------------------- */

.energy-flow {
  flex: 1;
  display: grid;
  grid-template-rows: auto auto auto auto;
  justify-items: center;
  align-content: space-between;
  gap: 0.3vh;
}

.flow-pv, .flow-house, .flow-battery, .flow-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.flow-icon {
  width: 2.3rem;
  height: 2.3rem;
  padding: 0.5rem;
  border-radius: 50%;
  background: rgba(126, 229, 47, 0.08);
}

.icon-pv, .icon-house { color: var(--green); }
.icon-battery { color: var(--green); }
.icon-grid { color: var(--green); }

.icon-battery.discharging { color: var(--orange); }
.icon-grid.import { color: var(--orange); }
.icon-grid.export { color: var(--green); }

.flow-value { font-size: 1.35rem; font-weight: 800; }
.flow-label { font-size: 0.78rem; color: var(--text-muted); }
.flow-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }

.flow-arrow {
  width: 3px;
  height: 1.6vh;
  background: linear-gradient(180deg, var(--green), transparent);
  position: relative;
}

.flow-arrow.grid-import { background: linear-gradient(180deg, var(--orange), transparent); }

.flow-split {
  display: flex;
  justify-content: center;
  gap: 4rem;
  width: 100%;
}

.flow-arrow-left, .flow-arrow-right {
  width: 40%;
  height: 2px;
  background: var(--green);
  align-self: center;
  opacity: 0.85;
}

.flow-bottom {
  display: flex;
  justify-content: space-around;
  width: 100%;
}

.stale-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.3rem;
  min-height: 1em;
}

/* --------------------------------------------------------------------
   Wetter
   -------------------------------------------------------------------- */

.weather-main {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8vh;
}

.weather-icon { width: 3.4rem; height: 3.4rem; color: var(--blue); }
.weather-temp { font-size: 2.3rem; font-weight: 800; }

.weather-meta { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; margin-left: auto; }
.weather-row { display: flex; align-items: center; gap: 0.4rem; color: var(--text); }
.weather-row [data-lucide] { width: 1.05rem; height: 1.05rem; color: var(--blue); }

.warnings-box {
  display: flex;
  flex-direction: column;
  gap: 0.5vh;
  flex: 1;
  justify-content: flex-end;
}

.warning-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
}

.warning-badge {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(126, 229, 47, 0.12);
}

.warning-badge [data-lucide] { width: 1.1rem; height: 1.1rem; color: var(--green); }
.warning-badge.status-warning { background: rgba(255, 196, 0, 0.12); }
.warning-badge.status-warning [data-lucide] { color: var(--yellow); }
.warning-badge.status-orange { background: rgba(255, 138, 0, 0.14); }
.warning-badge.status-orange [data-lucide] { color: var(--orange); }
.warning-badge.status-critical { background: rgba(255, 64, 64, 0.16); }
.warning-badge.status-critical [data-lucide] { color: var(--red); }

.warning-text { display: flex; flex-direction: column; font-size: 0.85rem; line-height: 1.3; }
.warning-text strong { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

/* --------------------------------------------------------------------
   Verkehr
   -------------------------------------------------------------------- */

.traffic-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.traffic-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4vh 0;
  border-bottom: 1px solid var(--border);
}

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

.traffic-item [data-lucide] { width: 1.5rem; height: 1.5rem; color: var(--text-muted); }

.traffic-name { font-weight: 700; font-size: 1rem; flex: 1; }
.traffic-duration { font-size: 1.1rem; font-weight: 700; margin-right: 0.6rem; }
.traffic-delay { font-size: 0.85rem; font-weight: 700; }

/* --------------------------------------------------------------------
   Pakete
   -------------------------------------------------------------------- */

.package-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 0.4vh;
}

.package-item {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4vh 0;
  border-bottom: 1px solid var(--border);
}

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

.carrier-badge {
  width: 2.6rem;
  height: 1.6rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #0b0f12;
}

.carrier-dhl { background: #ffcc00; }
.carrier-ups { background: #6b4423; color: #ffcc00; }
.carrier-hermes { background: #004b93; color: #fff; }
.carrier-dpd { background: #dc0032; color: #fff; }
.carrier-gls { background: #2a3a8f; color: #fff; }
.carrier-amazon { background: #232f3e; color: #ff9900; }
.carrier-unknown, .carrier-post { background: var(--border); color: var(--text); }

.package-name { font-weight: 700; font-size: 0.95rem; }
.package-eta { font-size: 0.82rem; color: var(--text-muted); }

.package-status-col { text-align: right; }
.package-eta-label { font-weight: 700; font-size: 0.85rem; }
.package-status-text { font-size: 0.78rem; }

.empty-hint { color: var(--text-muted); font-size: 0.9rem; margin: auto; }

/* --------------------------------------------------------------------
   Müll
   -------------------------------------------------------------------- */

.waste-next {
  display: flex;
  flex-direction: column;
  gap: 0.4vh;
  margin-bottom: 1vh;
}

.waste-when {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.waste-type {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.5rem;
  font-weight: 800;
}

.waste-type [data-lucide] { width: 1.7rem; height: 1.7rem; }

.waste-upcoming {
  border-top: 1px solid var(--border);
  padding-top: 0.7vh;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.waste-upcoming-item { display: flex; align-items: center; gap: 0.4rem; }
.waste-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block; }

/* --------------------------------------------------------------------
   Zappi
   -------------------------------------------------------------------- */

.zappi-mode {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 0.8vh;
}

.zappi-visual {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex: 1;
}

.zappi-ring {
  width: 6.2rem;
  height: 6.2rem;
  border-radius: 50%;
  border: 3px solid var(--green);
  box-shadow: var(--glow-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.zappi-inner {
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 50%;
  background: var(--card-bg-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.zappi-inner [data-lucide] { width: 1.3rem; height: 1.3rem; color: var(--green); }

.zappi-info { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.95rem; }
#zappi-status { font-weight: 700; }

/* --------------------------------------------------------------------
   Netzwerk / Technik
   -------------------------------------------------------------------- */

.status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55vh 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.status-row:last-child { border-bottom: none; }
.status-row [data-lucide]:first-child { width: 1.2rem; height: 1.2rem; color: var(--text-muted); }
.status-row span:nth-child(2) { flex: 1; }

.ups-list { display: flex; flex-direction: column; }

.ups-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55vh 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.ups-row:last-child { border-bottom: none; }
.ups-name { flex: 1; }
.ups-value { font-weight: 700; }
.ups-row.on-battery {
  background: rgba(255, 64, 64, 0.08);
  border-radius: 8px;
  padding-left: 0.4rem;
}
.ups-row.on-battery .ups-value { color: var(--red); }
.ups-battery-label {
  font-weight: 800;
  color: var(--red);
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

/* --------------------------------------------------------------------
   Radar
   -------------------------------------------------------------------- */

.card-radar h2 { justify-content: space-between; }
.radar-future { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin-left: auto; }

#radar-map {
  flex: 1;
  border-radius: 10px;
  overflow: hidden;
  filter: saturate(1.1) brightness(0.95);
  border: 1px solid var(--border);
}

.leaflet-container { background: #04101a !important; }
.leaflet-control-attribution { font-size: 0.55rem !important; background: rgba(2,8,13,0.6) !important; color: var(--text-muted) !important; }
.leaflet-control-zoom { display: none !important; }

/* --------------------------------------------------------------------
   Status-Ticker
   -------------------------------------------------------------------- */

.ticker {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9vh 1.3vw;
  overflow: hidden;
}

.ticker [data-lucide] { width: 1.2rem; height: 1.2rem; color: var(--yellow); flex-shrink: 0; }

.ticker-track {
  white-space: nowrap;
  font-size: 0.95rem;
  color: var(--yellow);
  font-weight: 600;
}

.ticker-item { color: var(--yellow); }
.ticker-sep { color: var(--text-muted); margin: 0 1.4rem; }

/* --------------------------------------------------------------------
   Responsive Skalierung für andere Auflösungen
   -------------------------------------------------------------------- */

@media (max-width: 1500px) {
  :root { --fs-base: 13px; }
}

@media (min-width: 2500px) {
  :root { --fs-base: 22px; }
}

@media (min-width: 3600px) {
  :root { --fs-base: 30px; }
}
