/* 🎨 Garagen-App Design-Tokens + Theme
   Eingebunden in allen Seiten via <link rel="stylesheet" href="/garagen-theme.css">
   DEPLOYED: 2026-06-24 */
   
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #fff;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: #334155;
  --ok: #22c55e;
  --warn: #eab308;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 1rem;
  --radius-sm: 0.75rem;
  --shadow: none;
  --body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 480px;
}

body.light {
  --bg: #f8fafc;
  --bg-card: #fff;
  --bg-hover: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  transition: background .2s, color .2s;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.app-wrap { max-width:var(--max-width); margin:0 auto; padding:1rem 1rem 6rem; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  transition: background .2s, border .2s, box-shadow .2s;
  box-shadow: var(--shadow);
}
body.light .card { border: 1px solid var(--border); }

/* ===== SLOTS ===== */
.slot {
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius-sm); padding: 0.75rem;
  background: var(--bg-card);
  transition: background .2s, border .2s;
}
body.light .slot { border: 1px solid var(--border); }
.slot-ok { border-left: 3px solid var(--ok); }
.slot-warn { border-left: 3px solid var(--warn); }
.slot-danger { border-left: 3px solid var(--danger); }
.slot-free { border-left: 3px solid var(--text-dim); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-ok { background:rgba(34,197,94,0.15); color:var(--ok); border:1px solid rgba(34,197,94,0.3); }
.badge-warn { background:rgba(234,179,8,0.15); color:var(--warn); border:1px solid rgba(234,179,8,0.3); }
.badge-danger { background:rgba(239,68,68,0.15); color:var(--danger); border:1px solid rgba(239,68,68,0.3); }
.badge-muted { background:rgba(100,116,139,0.15); color:var(--text-muted); border:1px solid rgba(100,116,139,0.3); }

/* ===== KPI ===== */
.kpi { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* KPI-Kacheln (m-kpi-strip auf Mieter-Seite u.a.) */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.kpi-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.kpi-sub.is-good { color: var(--ok); }
.kpi-sub.is-warn { color: var(--warn); }
.kpi-sub.is-bad  { color: var(--danger); }

/* Strip-Container: Kacheln nebeneinander */
#m-kpi-strip {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  border: none; transition: .15s;
  background: var(--bg-hover); color: var(--text);
}
.btn-ok { background:rgba(34,197,94,0.15); color:var(--ok); }
.btn-danger { background:rgba(239,68,68,0.15); color:var(--danger); }
.btn-info { background:rgba(59,130,246,0.15); color:var(--info); }

/* ===== FORM ===== */
.select-sm {
  font-size:0.8rem; padding:0.4rem 0.6rem; border-radius:0.5rem;
  background:var(--bg-hover); border:1px solid var(--border);
  color:var(--text); cursor:pointer;
}

/* ===== THEME TOGGLE ===== */
.theme-btn {
  width: 2rem; height: 2rem; border-radius: 50%;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  cursor: pointer; font-size: 0.85rem;
  background: var(--bg-hover); color: var(--text);
  transition: .2s;
}

/* ===== NAV ===== */
.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  padding: 0.5rem 0; font-size: 0.7rem;
  z-index: 100;
}
body.light .app-nav { border-top-color: var(--border); }
.nav-item {
  text-align: center; padding: 0.5rem 0;
  color: var(--text-dim); cursor: pointer;
  border-radius: 0.5rem; transition: .15s;
}
.nav-item.active { color: var(--info); font-weight: 600; }

/* ===== UTILITY ===== */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.25rem; }
.mt-2 { margin-top: 1rem; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== HEADER ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.app-header-left { line-height: 1.3; }
.app-header-sub { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.app-header-title { font-size: 1.25rem; font-weight: 700; }
.app-header-right { display: flex; align-items: center; gap: 0.75rem; }

/* ===== STATUS DOT ===== */
.status-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  box-shadow: 0 0 8px rgba(34,197,94,0.5);
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-dot.err { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ===== CHART BOX ===== */
.chart-box {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1.25rem;
  transition: background .2s, border .2s;
}
body.light .chart-box { border: 1px solid var(--border); }

/* ===== CHIP ACTIONS ===== */
.chip-action {
  flex-shrink: 0;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--info);
  white-space: nowrap;
}


body.dark input,
body.dark textarea,
body.dark select {
    color: #e2e8f0 !important;
    -webkit-text-fill-color: #e2e8f0 !important;
    caret-color: white !important;
    background: #1e293b !important;
    border-color: #475569 !important;
}
body.dark input::placeholder,
body.dark textarea::placeholder {
    color: #94a3b8 !important;
    -webkit-text-fill-color: #94a3b8 !important;
}

/* ===== RESPONSIVE: Tablet / Laptop / Desktop ==========================
   Mobile (< 768px): Bottom-Nav, app-wrap zentriert schmal.
   Tablet+ (>= 768px): Sidebar links (200px), Content rechts.
   Laptop  (>= 1024px): Sidebar 220px, Content breiter.
======================================================================== */
@media (min-width: 768px) {
  :root { --sidebar-w: 200px; }

  body {
    display: flex;
    min-height: 100vh;
  }

  /* Sidebar: Nav wandert von Bottom nach Links */
  .app-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0; right: auto;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 1.5rem 0.75rem;
    gap: 0.25rem;
    overflow-y: auto;
  }

  .nav-item {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .nav-item.active {
    background: var(--bg-hover);
  }

  /* Content-Bereich neben der Sidebar */
  .app-wrap {
    margin-left: var(--sidebar-w);
    max-width: none;
    width: calc(100% - var(--sidebar-w));
    padding: 1.5rem 1.5rem 2rem;
  }
}

@media (min-width: 1024px) {
  :root { --sidebar-w: 220px; }

  .app-wrap {
    padding: 2rem 2rem 2rem;
  }
}

/* Touch-Targets: Buttons und nav-Items sollten >= 44x44px sein (WCAG AA) */
.nav-item {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* ===== SIDEBAR COLLAPSE (nur Desktop) ===== */
.nav-collapse-btn {
  display: none; /* Mobile: versteckt */
}

@media (min-width: 768px) {
  .nav-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.5rem;
    border: none;
    background: none;
    color: var(--text-dim);
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background .15s, color .15s;
    flex-shrink: 0;
  }
  .nav-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
  }

  /* Eingeklappt: Sidebar schmäler, Text ausgeblendet */
  body.nav-collapsed .app-nav {
    width: 44px;
    padding: 1rem 0.25rem;
    overflow: hidden;
  }
  body.nav-collapsed .app-wrap {
    margin-left: 44px;
    width: calc(100% - 44px);
  }
  body.nav-collapsed .nav-item {
    text-indent: -9999px;
    padding: 0.6rem;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }
  body.nav-collapsed .nav-collapse-btn {
    justify-content: center;
    padding: 0.3rem;
  }
}
