/* fleet-map.css — Fleet Operations Center (Dark, Bulung CI: Navy-Basis + Green-Akzent) */
:root {
  --navy: #040c2c;
  --panel: #071031;
  --panel-2: #0b1838;
  --panel-3: #10214c;
  --line: rgba(148, 170, 214, 0.10);
  --line-2: rgba(148, 170, 214, 0.18);
  --green: #a2c629;
  --green-hover: #b8d940;
  --green-soft: rgba(162, 198, 41, 0.13);
  --green-line: rgba(162, 198, 41, 0.30);
  --text: #eaf0fb;
  --text-2: #aebbd6;
  --muted: #7486a8;
  --st-free: #a2c629;
  --st-24: #f5a623;
  --st-48: #4aa3ff;
  --st-later: #6b7a99;
  --st-unknown: #8f95a3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="light"] {
  --navy: #f4f5f7; --panel: #ffffff; --panel-2: #ffffff; --panel-3: #eef1f6;
  --line: #e4e7ec; --line-2: #d6dbe4;
  --text: #040c2c; --text-2: #47536e; --muted: #8f95a3;
  --green-soft: rgba(162, 198, 41, 0.16);
  --shadow: 0 10px 34px rgba(4, 12, 44, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--navy);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- App-Gerüst ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.app::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50;
  background: linear-gradient(90deg, var(--green) 0%, var(--navy) 60%);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding-right: 18px; border-right: 1px solid var(--line); }
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--green-soft); border: 1px solid var(--green-line); color: var(--green);
}
.brand .mark svg { width: 18px; height: 18px; }
.brand .txt { line-height: 1.1; }
.brand .txt b { font-weight: 600; font-size: 0.95rem; letter-spacing: 0.01em; }
.brand .txt span { display: block; font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.kpis { display: flex; gap: 10px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.kpis::-webkit-scrollbar { display: none; }
.kpi {
  position: relative; padding: 7px 15px 8px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  min-width: 96px; flex: 0 0 auto; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--dot, var(--green)); opacity: 0.85; }
.kpi .k-label { font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.kpi .k-val { font-size: 1.5rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 0.62rem; color: var(--text-2); white-space: nowrap; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.modeswitch { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.modeswitch button {
  font: inherit; font-size: 0.78rem; font-weight: 500; letter-spacing: 0.02em;
  padding: 6px 15px; border: 0; background: transparent; color: var(--text-2);
  border-radius: 999px; cursor: pointer; display: flex; align-items: center; gap: 7px; transition: all 0.2s var(--ease);
}
.modeswitch button svg { width: 15px; height: 15px; }
.modeswitch button.active { background: var(--green); color: var(--navy); font-weight: 600; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text-2); transition: all 0.2s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Bühne (3 Zonen) ---------- */
.stage { display: grid; grid-template-columns: 288px 1fr 348px; min-height: 0; position: relative; }
.stage.no-left { grid-template-columns: 0 1fr 348px; }
.stage.no-right { grid-template-columns: 288px 1fr 0; }
.stage.no-left.no-right { grid-template-columns: 0 1fr 0; }

/* ---------- Sidebar links (Filter) ---------- */
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden; transition: opacity 0.2s var(--ease);
}
.sidebar::-webkit-scrollbar, .side-panel::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .side-panel::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.stage.no-left .sidebar { opacity: 0; pointer-events: none; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px 11px; position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.side-head h2 { margin: 0; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.side-head .reset { font: inherit; font-size: 0.7rem; color: var(--green); background: none; border: 0; cursor: pointer; }
.side-head .reset:hover { color: var(--green-hover); text-decoration: underline; }

.fgroup { padding: 4px 16px 16px; border-bottom: 1px solid var(--line); }
.fgroup > label { display: flex; align-items: center; gap: 6px; font-size: 0.64rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-2); margin-bottom: 9px; }
.fgroup > label svg { width: 13px; height: 13px; color: var(--muted); }
.fgroup.locked { opacity: 0.55; }
.lock-tag { font-size: 0.54rem; letter-spacing: 0.08em; color: var(--st-24); border: 1px solid rgba(245,166,35,0.4); border-radius: 4px; padding: 1px 5px; margin-left: auto; text-transform: none; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font: inherit; font-size: 0.74rem; padding: 5px 11px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 999px; transition: all 0.16s var(--ease); display: inline-flex; align-items: center; gap: 6px;
}
.pill:hover { border-color: var(--line-2); color: var(--text); }
.pill.on { background: var(--green); border-color: var(--green); color: var(--navy); font-weight: 600; }
.pill .cnt { font-size: 0.64rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.pill .swatch { width: 8px; height: 8px; border-radius: 50%; }

.finput {
  width: 100%; font: inherit; font-size: 0.82rem; padding: 8px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); outline: none; transition: border-color 0.16s var(--ease);
}
.finput:focus { border-color: var(--green-line); }
.finput::placeholder { color: var(--muted); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; accent-color: var(--green); }
.range-val { font-size: 0.78rem; color: var(--text); font-variant-numeric: tabular-nums; min-width: 62px; text-align: right; }

/* ---------- Karte ---------- */
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--navy); }
.map-overlay { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.map-toggle {
  font: inherit; font-size: 0.76rem; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; color: var(--text-2);
  background: rgba(7, 16, 49, 0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); transition: all 0.18s var(--ease);
}
:root[data-theme="light"] .map-toggle { background: rgba(255,255,255,0.85); }
.map-toggle svg { width: 15px; height: 15px; }
.map-toggle:hover { color: var(--text); }
.map-toggle.on { color: var(--green); border-color: var(--green-line); }

.legend {
  position: absolute; bottom: 30px; left: 14px; z-index: 5;
  background: rgba(7, 16, 49, 0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px;
}
:root[data-theme="light"] .legend { background: rgba(255,255,255,0.85); }
.legend h4 { margin: 0 0 7px; font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.legend .row { display: flex; align-items: center; gap: 7px; font-size: 0.72rem; color: var(--text-2); margin-top: 4px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

/* MapLibre-Controls ans Theme angleichen */
.maplibregl-ctrl-group { background: var(--panel-2) !important; border: 1px solid var(--line-2) !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(0.85); }
:root[data-theme="light"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: none; }
.maplibregl-ctrl-attrib { background: rgba(7,16,49,0.7) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

/* ---------- Side-Panel rechts (Detail) ---------- */
.side-panel { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
.stage.no-right .side-panel { opacity: 0; pointer-events: none; }
.sp-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 30px; color: var(--muted); gap: 14px; }
.sp-empty svg { width: 40px; height: 40px; opacity: 0.5; }
.sp-empty p { margin: 0; font-size: 0.85rem; line-height: 1.5; }

.sp-card { padding: 18px 18px 28px; animation: fadeUp 0.35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sp-kind { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.sp-title { font-size: 1.28rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.15; margin-top: 2px; }
.sp-close { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.sp-close:hover { color: var(--text); }
.sp-close svg { width: 18px; height: 18px; }

.status-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 0.74rem; padding: 5px 11px; border-radius: 999px; font-weight: 500; margin-bottom: 16px; }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

.sp-rows { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.sp-row { display: grid; grid-template-columns: 104px 1fr; gap: 10px; padding: 10px 13px; background: var(--panel-2); }
.sp-row .l { font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); align-self: center; }
.sp-row .v { font-size: 0.86rem; color: var(--text); word-break: break-word; }
.sp-row .v .flag { display: inline-flex; align-items: center; gap: 6px; }

.sp-section { margin-top: 20px; }
.sp-section h3 { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-2); margin: 0 0 10px; display: flex; align-items: center; gap: 7px; }
.sp-section h3 svg { width: 14px; height: 14px; color: var(--green); }
.route { position: relative; padding-left: 20px; }
.route::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--green-line); }
.route .stop { position: relative; padding: 3px 0 14px; }
.route .stop:last-child { padding-bottom: 0; }
.route .stop::before { content: ""; position: absolute; left: -18px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); border: 2px solid var(--green); }
.route .stop .role { font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.route .stop .city { font-size: 0.92rem; font-weight: 500; }
.route .stop .addr { font-size: 0.74rem; color: var(--text-2); }

.match { display: flex; align-items: center; gap: 11px; padding: 9px 11px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 7px; cursor: pointer; transition: all 0.16s var(--ease); }
.match:hover { border-color: var(--green-line); transform: translateX(2px); }
.match .st { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 7px currentColor; }
.match .info { flex: 1; min-width: 0; }
.match .info b { font-size: 0.82rem; font-weight: 600; }
.match .info span { display: block; font-size: 0.7rem; color: var(--text-2); }
.match .eta { font-size: 0.72rem; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }

.prec-tag { font-size: 0.62rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; }
.prec-tag .d { width: 6px; height: 6px; border-radius: 50%; }
.prec-city .d { background: var(--green); } .prec-postal .d { background: var(--st-48); } .prec-country .d { background: var(--st-later); }

/* Sidebar-Reopen-Griffe */
.grip { position: absolute; top: 50%; transform: translateY(-50%); z-index: 6; width: 22px; height: 54px; display: grid; place-items: center; cursor: pointer; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text-2); }
.grip:hover { color: var(--green); }
.grip svg { width: 14px; height: 14px; }
.grip.left { left: 0; border-left: 0; border-radius: 0 8px 8px 0; }
.grip.right { right: 0; border-right: 0; border-radius: 8px 0 0 8px; }
.grip[hidden] { display: none; }

@media (max-width: 960px) {
  .stage, .stage.no-left, .stage.no-right { grid-template-columns: 0 1fr 0; }
  .sidebar { position: absolute; z-index: 20; width: 288px; height: 100%; box-shadow: var(--shadow); }
  .side-panel { position: absolute; right: 0; z-index: 20; width: 348px; height: 100%; box-shadow: var(--shadow); }
  .stage.show-left .sidebar { opacity: 1; pointer-events: auto; }
  .stage.show-right .side-panel { opacity: 1; pointer-events: auto; }
  .kpi { min-width: 84px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
