/* =====================================================================
   VeCon-CI Basis-Stylesheet — Dark Theme, Agri-PV Budrio
   CI-Farben aus dem VeCon-Logo; Layout-Patterns analog Lachwaldhof.
   ===================================================================== */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  /* VeCon CI-Farben */
  --vecon-hellblau: #99C6D8;
  --vecon-mittelblau: #7B9AC0;
  --vecon-strong: #367BA2;
  --vecon-grau: #47545A;

  /* Dark Theme (VeCon-getoente Blaugrau-Stufen) */
  --bg: #0c1317;
  --bg-2: #0e171d;
  --panel: #13202a;
  --card: #17252f;
  --card-hover: #1b2c38;
  --border: #263a47;
  --text: #e8eef2;
  --muted: #9db4c0;

  /* Statusfarben */
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

/* ------------------------------ Header ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand .logo { height: 34px; width: auto; display: block; }

.site-title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.site-name { font-weight: 600; font-size: 17px; white-space: nowrap; }
.site-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }

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

/* --------------------------- Status-Pill ---------------------------- */
.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  white-space: nowrap;
}
.status-online        { background: #16351c; color: #9cf2b0; border-color: #2f7f49; }
.status-standby       { background: #182632; color: var(--vecon-hellblau); border-color: var(--vecon-strong); }
.status-degraded      { background: #38240d; color: #ffd399; border-color: #8a5a1a; }
.status-offline       { background: #3a1418; color: #ffb3ba; border-color: #a03040; }
.status-initializing  { background: var(--card); color: var(--muted); }

/* ------------------------- Sprach-Toggle ---------------------------- */
.lang-toggle-group { display: flex; gap: 4px; }
.lang-btn {
  padding: 5px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.lang-btn:hover { background: var(--card-hover); }
.lang-btn.active {
  background: var(--vecon-strong);
  border-color: var(--vecon-strong);
  color: #fff;
}

/* ------------------------------ Inhalt ------------------------------ */
.content {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 20px;
}

/* Kachel-Grid (responsive) */
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.card h2 { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; }
.card h3 { margin: 0 0 6px 0; font-size: 13px; font-weight: 500; color: var(--muted); }
.card .val { font-size: 28px; font-weight: 600; }
.card .unit { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* Rekonstruierte Werte (ComBoard-Resilienz): gestrichelter Rand + Hinweis */
.card.reconstructed { border-style: dashed; border-color: var(--vecon-mittelblau); }
.source-hint { font-size: 11px; color: var(--vecon-hellblau); }

.placeholder p { color: var(--muted); }

/* --------------------- Nachtmodus (Kundensicht) --------------------- */
.night-banner {
  background: rgba(153, 198, 216, 0.08);
  border: 1px solid var(--vecon-strong);
  color: var(--vecon-hellblau);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.tile.night-dim { opacity: 0.55; }   /* Leistungs-Kacheln nachts gedimmt;
                                        Energie-Kacheln bleiben normal */

/* ------------------------------ Kacheln ----------------------------- */
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile#tile-ts .val { font-size: 24px; }
.dimmed { opacity: 0.55; }
.source-hint { cursor: help; color: var(--vecon-hellblau); }
.pill-info { margin-left: 6px; cursor: help; }

/* --------------------- Buttons (Zeitbereiche/Tabs) ------------------ */
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  padding: 5px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.btn:hover { background: var(--card-hover); }
.btn.active {
  background: var(--vecon-strong);
  border-color: var(--vecon-strong);
  color: #fff;
}

/* ------------------------------ Charts ------------------------------ */
.chart-card { margin-top: 14px; }
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.chart-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.chart-wrap { position: relative; height: 320px; }
.hist-meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.hist-meta b { color: var(--text); }

/* --------------------------- Servicesicht --------------------------- */
.svc-status-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.val.small { font-size: 18px; font-weight: 600; }
.night-note { color: var(--vecon-hellblau); }

.devices .dev-card { min-width: 0; }
.dev-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dev-head h2 { margin: 0; font-size: 16px; }
.dev-info { margin: 4px 0 10px; word-break: break-word; }
.dev-card h4 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); font-weight: 500; }

.health-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
}
.hb-ok          { background: #16351c; color: #9cf2b0; border-color: #2f7f49; }
.hb-degraded    { background: #38240d; color: #ffd399; border-color: #8a5a1a; }
.hb-unreachable { background: #3a1418; color: #ffb3ba; border-color: #a03040; }

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: 13px;
  margin: 6px 0;
}
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }

.recon-note { color: var(--vecon-hellblau); margin: 4px 0; }

.errors { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.err-chip {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  border: 1px solid var(--border);
}
.sev-error { background: #3a1418; color: #ffb3ba; border-color: #a03040; }
.sev-warn  { background: #38240d; color: #ffd399; border-color: #8a5a1a; }
.sev-info  { background: var(--panel); color: var(--muted); }

/* Sensorik-Sektion (SPS) */
.s7-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 8px;
}
.s7-grid h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 500; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th, .mini-table td {
  padding: 3px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table th { color: var(--muted); font-weight: 500; }
.diag-table td, .diag-table th { white-space: nowrap; }
.diag-table .diag-err { white-space: normal; max-width: 340px; font-size: 11px; }

/* ------------------------------ Footer ------------------------------ */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.footer-right { display: flex; align-items: center; gap: 8px; }
.footer-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--border);
}
.footer-link:hover { color: var(--text); }

/* horizontale Scroll-Huelle fuer breite Tabellen (Servicesicht, mobil) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ------------------------------ Mobil ------------------------------- */
@media (max-width: 700px) {
  .site-header { flex-wrap: wrap; }
  .site-name { font-size: 15px; }
  .brand .logo { height: 28px; }
  .content { padding: 14px 12px; }
  .card .val { font-size: 24px; }
  .tile#tile-ts .val { font-size: 20px; }
  .chart-wrap { height: 240px; }
  /* Touch-Ziele (Tabs, Zeitbereiche, Sprachumschalter) >= 44px */
  .btn, .lang-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 13px;
  }
}
