/* =============================================
   Fiat 500E Dashboard – Styles
   ============================================= */

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

:root {
  --bg:        #0d0f14;
  --surface:   #161922;
  --surface2:  #1e2230;
  --accent:    #00c8ff;
  --accent2:   #3d6bff;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --blue:      #3b82f6;
  --text:      #e8ecf4;
  --muted:     #6b7280;
  --radius:    16px;
  --radius-sm: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding: 20px;
}

/* ---- Layout ---- */
.dashboard {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 4px;
}

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

.car-icon {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}

h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.accent { color: var(--accent); }

.subtitle {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.btn-refresh {
  background: var(--surface2);
  border: 1px solid #2a2f3e;
  color: var(--text);
  width: 42px; height: 42px;
  border-radius: 10px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-refresh:hover { background: var(--surface); }
.btn-refresh.spinning #refresh-icon { display: inline-block; animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Card base ---- */
.card {
  background: var(--surface);
  border: 1px solid #1e2435;
  border-radius: var(--radius);
  padding: 24px;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ---- Hero card ---- */
.card-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(135deg, #161922 60%, #0e1a2e);
  border-color: #1e3a5f44;
}

.car-photo {
  max-height: 150px;
  max-width: 46%;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
}

.soc-value {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.soc-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
  margin-bottom: 18px;
}

.range-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
}

.range-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

/* ---- Battery visual ---- */
.battery-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.battery-body {
  width: 110px;
  height: 52px;
  border: 3px solid #2a3650;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: #0d1120;
}

.battery-tip {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 22px;
  background: #2a3650;
  border-radius: 0 4px 4px 0;
}

.battery-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
}

.battery-fill.low  { background: linear-gradient(90deg, #b91c1c, var(--red)); }
.battery-fill.mid  { background: linear-gradient(90deg, #d97706, var(--yellow)); }
.battery-fill.high { background: linear-gradient(90deg, var(--accent2), var(--accent)); }

.charge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.charge-status.charging { background: #0c2a1e; color: var(--green); border: 1px solid #166534; }
.charge-status.full     { background: #0c1f3a; color: var(--accent); border: 1px solid #1d4ed8; }

/* ---- Info row ---- */
.card-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #1e2435;
  padding: 0;
  overflow: hidden;
}

.info-item {
  background: var(--surface);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.info-value {
  font-size: 1.05rem;
  font-weight: 600;
}

/* ---- Controls ---- */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.control-group { display: flex; flex-direction: column; gap: 10px; }

.control-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.control-buttons { display: flex; flex-direction: column; gap: 8px; }

.btn {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}
.btn:hover  { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }

.btn-green   { background: #166534; color: #bbf7d0; }
.btn-red     { background: #7f1d1d; color: #fecaca; }
.btn-blue    { background: #1e3a5f; color: #bfdbfe; }
.btn-yellow  { background: #78350f; color: #fde68a; }
.btn-outline { background: transparent; color: var(--muted); border: 1px solid #2a2f3e; }
.btn-outline:hover { color: var(--text); border-color: #3d4455; }

/* Aktueller Zustand hervorgehoben / inaktiver gedimmt */
.btn.state-active {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
  filter: brightness(1.12);
  font-weight: 700;
}
.btn.state-active::after { content: " ✓"; }
.btn.state-inactive { opacity: 0.4; filter: grayscale(0.4); }

/* Menü-Tabs (Vorklimatisierung / Ladeplan) */
.plan-tabs { display: flex; gap: 8px; margin: 18px 0 12px; }
.plan-tab {
  flex: 1; background: #21262d; color: var(--muted);
  border: 1px solid #30363d; border-radius: 8px; padding: 10px;
  cursor: pointer; font-size: 0.9em; font-weight: 600;
}
.plan-tab.active { background: #1e3a5f; color: #bfdbfe; border-color: #1f6feb; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid #2a2f3e;
  color: var(--text);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok  { border-color: #166534; color: var(--green); }
.toast.err { border-color: #7f1d1d; color: var(--red); }

/* ---- Error overlay ---- */
.error-banner {
  background: #2d0f0f;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: none;
}
.error-banner.visible { display: block; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .card-hero  { flex-direction: column; align-items: flex-start; }
  .card-info  { grid-template-columns: repeat(2, 1fr); }
  .controls-grid { grid-template-columns: 1fr; }
  .battery-visual { align-items: flex-start; }
  .car-photo { max-width: 80%; max-height: 130px; align-self: center; margin: 6px 0; }
}
