/* misc.css — Seite "Sonstiges" */

.device-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: clamp(10px, 1.6vh, 18px);
}
@media (max-width: 1100px) { .device-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .device-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .device-grid { grid-template-columns: 1fr; } }

.device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  padding: clamp(10px, 1.4vh, 16px);
  /* Runde 20: antippbar/klickbar — öffnet das Verbrauchs-Verlauf-Popup, siehe
     misc.js#openDeviceHistory(). */
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.device-card:hover { box-shadow: 0 3px 10px rgba(30,41,59,0.12); }
.device-card:active { transform: scale(0.98); }

/* Geräte-Verbrauchs-Popup (Runde 20) — Zeitraum-Umschalter wie bei der
   Kosten-Seite (.segmented), Chart-Bereich mit Mindesthöhe. */
.device-history-modal .modal-body { min-height: 220px; }
.device-history-chart { width: 100%; display: block; }
/* Runde 29: Summe des Verbrauchs im gewählten Zeitraum (siehe misc.js#
   loadDeviceHistory()) — rechtsbündig in derselben Zeile wie die
   Legende ("Verbrauch (kWh)"), damit sie nicht wie ein zweiter
   Legenden-Eintrag wirkt, sondern klar als eigenständige Kennzahl. */
.device-history-modal .period-sum-value {
  margin-left: auto;
  font-weight: 700;
  color: var(--text);
}
.device-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--surface-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex: 0 0 auto;
}
/* Geräte-Bild (Runde 15, siehe misc.js#deviceIconHtml()) — CSS-Maske statt
   <img>, damit das Symbol automatisch in --accent eingefärbt wird und bei
   Hell-/Dunkel-Wechsel mitzieht, unabhängig von der Farbe der SVG-Datei
   selbst (frontend/assets/devices/*.svg sind bewusst einfarbige Symbole). */
.device-icon-glyph {
  display: block;
  width: 26px; height: 26px;
  background: var(--accent);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.device-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
/* Runde 34: Name + Status-Badge in EINER Zeile (statt Badge oben rechts in
   der Kachel-Ecke, siehe .device-badge-Kommentar unten) — macht die Zeile
   eindeutig zu "diesem einen Gerät" gehörend. */
.device-name-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.device-name { font-size: 12.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-power { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.device-sub { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.device-badge { flex: 0 0 auto; }
/* Runde 30/34: Ein-/Ausschalter — per Default unsichtbar (nur eingeblendet
   für Geräte mit 'writable' => true bei ihrem 'on'-Feld, siehe misc.js#
   update() ".visible"-Klasse). Bis Runde 33 "position:absolute" unten
   rechts in der Kachel-Ecke (wie die Badge oben rechts) — wirkte dadurch
   vom eigentlichen Geräte-Inhalt losgelöst ("Ecken-Kachel" statt sichtbar
   zum Gerät gehörend, von Nico so gemeldet). Jetzt normales, letztes
   Flex-Element der Kachel-Zeile (siehe misc.js#deviceCard()) — dadurch
   automatisch vertikal zentriert neben Icon/Name/Status, kein eigenes
   Positionierungs-System mehr nötig. */
.toggle-switch {
  display: none;
  position: relative;
  width: 40px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--surface-alt);
  cursor: pointer;
  transition: background 0.2s, opacity 0.15s;
}
.toggle-switch.visible { display: inline-block; }
.toggle-switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.toggle-switch.on { background: var(--green); }
.toggle-switch.on::before { transform: translateX(16px); }
.toggle-switch.pending { opacity: 0.55; cursor: wait; }
/* Kurzer roter Blitz bei fehlgeschlagenem Schreibvorgang (siehe misc.js#
   handleDeviceToggle()) — Zustand selbst bleibt unverändert (kein
   optimistisches Umschalten), nur diese Farbe markiert kurz den Fehler. */
.toggle-switch.error { background: var(--red); }
.toggle-switch:disabled { cursor: not-allowed; }

.tesla-card { padding: clamp(14px, 1.8vh, 22px); }
.tesla-top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.tesla-visual { position: relative; width: 110px; height: 110px; flex: 0 0 auto; }
.tesla-soc-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.unit-sm { font-size: 0.55em; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.tesla-info { flex: 1; min-width: 220px; }
.tesla-name { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.tesla-kv { margin-top: 16px; }

.tesla-location {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12.5px;
  font-weight: 700;
  width: fit-content;
}
.tesla-location.away { background: var(--orange-soft); color: var(--orange); }
.tesla-location-icon { font-size: 1em; }

/* Fahrzeugvisualisierung (Runde 13): Draufsicht mit Türen/Frunk/Kofferraum,
   Rädern (drehen sich während der Fahrt) und Reifendruck-Beschriftung. */
.tesla-grid { grid-template-columns: 1.3fr 1fr; align-items: stretch; }
@media (max-width: 900px) { .tesla-grid { grid-template-columns: 1fr; } }

.tesla-visual-card { display: flex; flex-direction: column; padding: clamp(14px, 1.8vh, 22px); }
.tesla-car-svg { width: 100%; max-width: 220px; margin: 4px auto; display: block; }

.tesla-body { stroke: var(--border); stroke-width: 2; transition: fill 0.4s; }
.tesla-panel {
  fill: var(--surface-alt);
  stroke: var(--border);
  stroke-width: 1.5;
  transform-origin: center;
  transition: fill 0.3s, transform 0.3s;
}
.tesla-panel.open { fill: var(--red-soft); stroke: var(--red); }
#frunkRect.open { transform: translateY(-8px); }
#trunkRect.open { transform: translateY(8px); }

.tesla-door {
  fill: var(--surface-alt);
  stroke: var(--border);
  stroke-width: 1.5;
  transition: fill 0.3s, transform 0.3s;
}
.tesla-door.open { fill: var(--red-soft); stroke: var(--red); }
#doorFL.open, #doorRL.open { transform: translateX(-10px); }
#doorFR.open, #doorRR.open { transform: translateX(10px); }

.tesla-wheel-tire { fill: #22262a; }
.tesla-wheel-hub { fill: var(--surface); }
.tesla-wheel-spoke { fill: var(--text-faint); }
/* Runde 16: ohne transform-box: fill-box rotiert eine SVG-Form bei
   transform-origin: center um den Mittelpunkt des GESAMTEN SVG-Canvas
   statt um den eigenen Mittelpunkt — deshalb drehten sich die Tesla-Räder
   sichtbar "um das ganze Bild" statt um sich selbst. */
.tesla-wheel-spin.spinning { transform-box: fill-box; transform-origin: center; animation: teslaWheelSpin 0.5s linear infinite; }
@keyframes teslaWheelSpin { to { transform: rotate(360deg); } }

.tesla-tire-label { fill: var(--text-muted); font-size: 10px; font-weight: 700; font-family: inherit; }
.tesla-speed-txt { fill: var(--text); font-size: 20px; font-weight: 800; font-family: inherit; }

.tesla-visual-legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.tesla-visual-legend .legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
