/* =========================================================
   Camper Control – globale Styles
   Cyan accent #03e9f4 · Dark base · keine externen Fonts
   ========================================================= */

:root {
    --bg-0: #0f1419;
    --bg-1: #161c23;
    --bg-2: #1c242d;
    --border: #2a3540;
    --border-strong: #3a4757;
    --text: #e6edf3;
    --text-muted: #8b97a8;
    --accent: #03e9f4;
    --accent-glow: rgba(3, 233, 244, 0.35);
    --success: #2ecc71;
    --danger: #ff5c5c;
    --warning: #ffb454;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    background: var(--bg-0);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(800px 400px at 10% -10%, rgba(3, 233, 244, 0.06), transparent 60%),
        radial-gradient(600px 300px at 100% 0%, rgba(3, 233, 244, 0.04), transparent 60%),
        var(--bg-0);
    padding-bottom: 40px;
}

/* ---------- Top Navigation ---------- */
.topbar {
    background: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar .brand {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar .brand .brand-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}
.topbar nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: color .15s, background .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.topbar nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.topbar nav a.active {
    color: var(--accent);
    background: rgba(3, 233, 244, 0.08);
}

/* ---------- Cards ---------- */
.tile {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color .2s, transform .2s;
}
.tile:hover {
    border-color: var(--border-strong);
}
.tile h2, .tile h3 { color: var(--text); }
.tile-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}
.tile-title .icon {
    width: 22px; height: 22px;
    color: var(--accent);
    flex: 0 0 22px;
}
.tile-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: -6px 0 14px;
}

/* ---------- Bento Grid ----------
   Eigene span-Klassen (NICHT col-*, das kollidiert mit Bootstrap max-width:50%).
   Handy + Tablet: 2 Kacheln nebeneinander · großer Bildschirm: 3 nebeneinander (.cols-3) */
.bento {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
}
.bento > * { min-width: 0; }
.bento .span-12 { grid-column: span 12; }
.bento .span-6  { grid-column: span 6; }
.bento .span-4  { grid-column: span 4; }
@media (min-width: 1200px) {
    .bento.cols-3 .span-6 { grid-column: span 4; }   /* Control Panel: 3 Kacheln pro Reihe */
}
@media (max-width: 800px) {
    .bento .span-4 { grid-column: span 6; }
}

/* ---------- Seitenbreite: Bildschirm nutzen statt schmaler Bootstrap-Container ---------- */
.container {
    max-width: 1600px;
    padding-left: 24px;
    padding-right: 24px;
}

/* ---------- Buttons ---------- */
.btn {
    --btn-bg: var(--bg-2);
    --btn-color: var(--text);
    background: var(--btn-bg);
    color: var(--btn-color);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 500;
    font-size: 0.95rem;
    min-height: 44px; /* Touch target */
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-accent {
    --btn-bg: var(--accent);
    --btn-color: #001316;
    border-color: var(--accent);
    box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-accent:hover {
    box-shadow: 0 0 18px var(--accent-glow);
    border-color: var(--accent);
}
.btn-on  { --btn-bg: rgba(46,204,113,0.15); --btn-color: var(--success); border-color: rgba(46,204,113,0.4); }
.btn-on:hover  { border-color: var(--success); }
.btn-off { --btn-bg: rgba(255,92,92,0.12); --btn-color: var(--danger); border-color: rgba(255,92,92,0.4); }
.btn-off:hover { border-color: var(--danger); }
.btn-ghost { --btn-bg: transparent; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-row .btn { flex: 1 1 auto; min-width: 80px; }

/* ---------- Status Badges ---------- */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--text-muted);
}
.badge-pill.on { background: rgba(46,204,113,0.15); color: var(--success); border-color: rgba(46,204,113,0.4); }
.badge-pill.off { background: rgba(255,92,92,0.12); color: var(--danger); border-color: rgba(255,92,92,0.4); }
.badge-pill.warn { background: rgba(255,180,84,0.12); color: var(--warning); border-color: rgba(255,180,84,0.4); }
.badge-pill .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

/* ---------- Metric / KPI display ---------- */
.kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.kpi-value {
    color: var(--text);
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 14px;
}

/* ---------- Battery progress ---------- */
.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--bg-2);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 6px;
    border: 1px solid var(--border);
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width .4s, background .3s;
    border-radius: 999px;
}
.progress-bar-fill.low { background: var(--danger); }
.progress-bar-fill.mid { background: var(--warning); }
.progress-bar-fill.high { background: var(--success); }

/* ---------- Detail list (heater status) ---------- */
.detail-list {
    list-style: none;
    padding: 0; margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}
.detail-list li {
    display: flex; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
}
.detail-list li:last-child { border-bottom: 0; }
.detail-list li strong { color: var(--text); font-weight: 600; }

/* ---------- Spinner ---------- */
.spinner {
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-stack {
    position: fixed;
    right: 20px; bottom: 20px;
    display: flex; flex-direction: column; gap: 10px;
    z-index: 9999;
    pointer-events: none;
}
.toast-item {
    background: var(--bg-1);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    pointer-events: auto;
    animation: toast-in .25s ease-out, toast-out .25s ease-in 3s forwards;
    max-width: 320px;
}
.toast-item.ok { border-left-color: var(--success); }
.toast-item.err { border-left-color: var(--danger); }
@keyframes toast-in  { from { transform: translateY(20px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }

/* ---------- Form (config page) ---------- */
.form-stack { display: grid; gap: 14px; max-width: 520px; }
.form-stack label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
    display: block;
}
.form-stack input[type="number"],
.form-stack input[type="text"] {
    width: 100%;
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.95rem;
    transition: border-color .15s;
}
.form-stack input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(3,233,244,0.15); }

/* ---------- Tables ---------- */
.gps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.gps-table th, .gps-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.gps-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: var(--bg-1);
}
.gps-table tbody tr:hover { background: rgba(3,233,244,0.04); }
.gps-table-wrap {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* ---------- Hero (home page) ---------- */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
}
.hero h1 {
    font-size: 2rem;
    margin: 0 0 10px;
    background: linear-gradient(120deg, var(--text), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p { color: var(--text-muted); margin: 0 0 30px; }
.hero img {
    max-width: min(560px, 100%);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* ---------- Map ---------- */
#map {
    height: 460px;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted) !important; }
.mt-3 { margin-top: 14px; }
.mb-3 { margin-bottom: 14px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* =========================================================
   Responsive Overrides (müssen am Ende stehen)
   ========================================================= */
/* Zwei Spalten innerhalb einer Kachel (z. B. Licht Bett/Tisch) */
.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* ---------- Handy: kompakter, damit 2 Kacheln nebeneinander passen ---------- */
@media (max-width: 600px) {
    .split-2 { gap: 8px; }
    .bento .split-2 .btn-row .btn { flex-basis: 100%; min-width: 0; padding-left: 4px; padding-right: 4px; }
    .split-2 .btn-row { display: grid; grid-template-columns: minmax(0, 1fr); }
    .container { padding-left: 10px; padding-right: 10px; }
    main.container { padding-top: 14px !important; }
    .bento { gap: 10px; }
    .tile { padding: 12px; border-radius: 10px; }
    .tile-title { font-size: 0.92rem; gap: 6px; margin-bottom: 10px; }
    .tile-title .icon { width: 18px; height: 18px; flex-basis: 18px; }
    .tile-subtitle { font-size: 0.75rem; margin: -4px 0 10px; }
    .kpi-row { grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
    .kpi-label { font-size: 0.68rem; }
    .kpi-value { font-size: 1.15rem; }
    .btn { padding: 8px 10px; font-size: 0.85rem; }
    .btn-row { gap: 6px; }
    .btn-row .btn { min-width: 0; flex: 1 1 calc(50% - 6px); }
    .tile > .btn { width: 100%; }
    /* Navigation als eine wischbare Zeile statt zwei Reihen */
    .topbar nav { flex-wrap: nowrap !important; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
    .topbar nav::-webkit-scrollbar { display: none; }
    .topbar nav a { padding: 8px 10px; white-space: nowrap; }
}

/* Kacheln, die am Handy die volle Breite brauchen (Formulare, Listen) */
@media (max-width: 600px) {
    .bento .wide-mobile { grid-column: span 12; }
}
