/* =====================================================================
   PM-Tools-Design fuer Iridium Map
   Uebernommen aus dem Design-System des PM-Tools-Stacks (design/tokens.css, design/components.jsx):
   Markenrot, weisser Kopfbereich mit roter Unterkante, Karten mit roter Oberkante, Konsolenschrift fuer Beschriftungen,
   Grossbuchstaben-Schaltflaechen, Segoe UI / Arial, kleine Rundungen, dezente Schatten.
   Wird nach style.css geladen und ueberschreibt nur die Optik. Die Symbolik auf Karte und Globus (Satelliten, Reichweiten,
   Verbindungen) bleibt bewusst unveraendert, sie hat eine eigene Bedeutung.
   ===================================================================== */
:root {
  --color-primary:       #cc252b;
  --color-primary-dark:  #a11920;
  --color-primary-light: #f7eaea;
  --color-bg:            #ffffff;
  --color-bg-alt:        #f3f4f6;
  --color-surface:       #ffffff;
  --color-border:        #e0e2e6;
  --color-border-strong: #c8cacd;
  --color-text:          #222222;
  --color-text-muted:    #666666;
  --color-text-subtle:   #999999;
  --color-text-inverse:  #ffffff;
  --color-success:       #2e7d32;
  --color-success-bg:    #eaf4eb;
  --color-success-border:#a8d5aa;
  --color-info:          #1976a8;
  --color-warning:       #b45309;
  --color-warning-bg:    #fffbeb;
  --color-warning-border:#fcd34d;
  --font-body: 'Segoe UI', 'Arial', sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --text-xs: 11px; --text-sm: 13px; --text-base: 14px; --text-md: 15px; --text-lg: 18px; --text-xl: 22px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;
  --radius-sm: 3px; --radius: 4px; --radius-md: 6px; --radius-lg: 8px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --header-height: 56px;
  --transition-fast: 0.12s ease;
  --tb-bottom: 56px;                 /* wird per JS aus der tatsaechlichen Hoehe des Kopfbereichs gesetzt */
}

/* ---------- Grundlagen ---------- */
html, body { font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text); -webkit-font-smoothing: antialiased; }
body { background: var(--color-bg-alt); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
input[type=range], input[type=checkbox] { accent-color: var(--color-primary); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--color-bg-alt); }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-subtle); }

/* ---------- Kopfbereich (wie AppHeader: weiss, 3 px rote Unterkante, Logo | Bereich, Aktionen rechts) ---------- */
.topbar {
  position: fixed; z-index: 1100; top: 0; left: 0; right: 0; max-width: none; box-sizing: border-box;
  height: calc(var(--header-height) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--space-8) 0;
  display: flex; align-items: center; gap: var(--space-1); overflow: visible;
  background: var(--color-bg); border: 0; border-bottom: 3px solid var(--color-primary); border-radius: 0; box-shadow: var(--shadow-sm);
}
.brand { padding: 0 var(--space-2) 0 0; color: var(--color-primary); font-size: var(--text-md); font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.brand { display: flex; align-items: center; }
.brand b { font-weight: 700; }
.hdr-sep { color: var(--color-border-strong); font-size: var(--text-lg); font-weight: 200; margin: 0 var(--space-2) 0 var(--space-1); user-select: none; }
.topbar button {
  border: 0; background: transparent; color: var(--color-text); font-size: var(--text-base); font-weight: 400;
  padding: 8px var(--space-3); min-height: 36px; border-radius: var(--radius); white-space: nowrap; flex: 0 0 auto; cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar button:hover { background: var(--color-bg-alt); }
.topbar button.active, .topbar button.on { background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; }
#btnSet { margin-left: auto; }          /* Karte/Globus links, Standort/Einstellungen rechts */

/* Karte und Globus beginnen unter dem Kopfbereich */
#map { position: fixed; left: 0; right: 0; bottom: 0; top: var(--tb-bottom); height: auto; width: auto; }
#globe { top: var(--tb-bottom); }
.map-error { top: calc(var(--tb-bottom) + 10px); }

/* ---------- Status unter dem Kopfbereich ---------- */
.map-view-info {
  top: calc(var(--tb-bottom) + 10px); left: 12px;
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-size: var(--text-sm); font-weight: 600; padding: 8px 12px;
}
.map-view-info::before { background: var(--color-success); box-shadow: 0 0 0 3px rgba(46,125,50,.18); }
.map-view-info.none::before { background: var(--color-text-subtle); box-shadow: none; }

/* ---------- Seitenfenster (Karte: weiss, Rahmen, rote Oberkante) ---------- */
.panel {
  right: 12px; top: calc(var(--tb-bottom) + 12px); width: 320px; box-sizing: border-box;
  max-height: calc(100vh - var(--tb-bottom) - 12px - 176px);
  background: var(--color-surface); border: 1px solid var(--color-border); border-top: 3px solid var(--color-primary);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--space-4) var(--space-5) var(--space-5);
}
.panel-title { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); align-items: center; margin-bottom: var(--space-2); }
.sec > .section:first-child, .summary { margin-top: var(--space-3); }
.panel-title button { color: var(--color-text-muted); font-size: 22px; border-radius: var(--radius); }
.panel-title button:hover { background: var(--color-bg-alt); color: var(--color-text); }
.section { border-top: 1px solid var(--color-border); }
.section-title { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; letter-spacing: .10em; text-transform: uppercase; color: var(--color-primary); }
label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text); }
label.check, .check { font-size: var(--text-base); font-weight: 400; text-transform: none; letter-spacing: 0; }
.check small { color: var(--color-text-subtle); font-size: var(--text-xs); }
.hint { font-size: var(--text-xs); color: var(--color-text-muted); line-height: 1.45; margin-top: 6px; }
.address-form, .position-form { margin-top: var(--space-3); }
.wide-btn { margin-top: var(--space-3); }
.muted { color: var(--color-text-muted); }
.coords { font-family: var(--font-mono); font-size: var(--text-base); color: var(--color-text); }
.sum-count b { color: var(--color-text); }
.sum-count span, .sum-line { color: var(--color-text); }
.sum-count span { color: var(--color-text-muted); }
.sum-note { color: var(--color-warning); }
.sat:hover { background: var(--color-bg-alt); }
.legend, .api-example { background: var(--color-bg-alt); }

/* ---------- Eingaben ---------- */
.address-form input, .position-form input, .refresh-section select, select {
  border: 1px solid var(--color-border); border-radius: var(--radius); padding: 8px 11px; font-size: var(--text-base);
  color: var(--color-text); background: var(--color-bg);
}
.address-form input:focus, .position-form input:focus, .refresh-section select:focus, select:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(204,37,43,.15);
}
.addr-results { border-color: var(--color-border); border-radius: var(--radius); }
.addr-results button { color: var(--color-text); }
.addr-results button:hover { background: var(--color-primary-light); }
#addrInfo.err { color: var(--color-primary); }

/* ---------- Schaltflaechen: primaer = dunkelrot, Grossbuchstaben; sekundaer = weiss mit Rahmen ---------- */
.address-form button, .position-form button {
  background: var(--color-primary-dark); color: var(--color-text-inverse); border: 0; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(161,25,32,.25); padding: 9px 16px; transition: background var(--transition-fast);
}
.address-form button:hover, .position-form button:hover { background: #8c141a; }
.wide-btn, .api-btn {
  background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); font-size: var(--text-base); font-weight: 400;
}
.wide-btn:hover, .api-btn:hover { background: var(--color-bg-alt); }
.api-docs { color: var(--color-primary); }
.seg { border: 1px solid var(--color-border); border-radius: var(--radius); }
.seg button { background: var(--color-bg); color: var(--color-text); border-right: 1px solid var(--color-border); font-size: var(--text-sm); font-weight: 600; }
.seg button:hover { background: var(--color-bg-alt); }
.seg button.active, .seg button.active:hover { background: var(--color-primary); color: var(--color-text-inverse); }

/* Zustands-Marken (Fenster/Luecke) wie DS-Badges */
.win-ctl > span { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text); }
.win-tag { font-family: var(--font-mono); font-weight: 600; letter-spacing: .04em; border-radius: var(--radius-sm); }
.win-row.win .win-tag { background: var(--color-success-bg); color: var(--color-success); }
.win-row.gap .win-tag { background: var(--color-warning-bg); color: var(--color-warning); }
.api-list code, .api-example code, .api-head code { font-family: var(--font-mono); }

/* ---------- Zeitleiste, Karten-Bedienelemente, Meldungen ---------- */
.timeline {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 6px 10px; color: var(--color-text);
}
.timeline button {
  background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); font-weight: 600;
}
.timeline button:hover { background: var(--color-bg-alt); }
#nowBtn { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: var(--color-text-inverse); font-size: var(--text-xs); letter-spacing: .04em; text-transform: uppercase; box-shadow: 0 2px 4px rgba(161,25,32,.25); }
#nowBtn:hover { background: #8c141a; }
#timeLabel { font-size: var(--text-sm); color: var(--color-text-muted); }
.map-fab, .leaflet-bar {
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border) !important; border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-bar a { color: var(--color-text); background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.leaflet-bar a:hover { background: var(--color-bg-alt); color: var(--color-primary); }
.map-fab:hover { background: var(--color-bg-alt); color: var(--color-primary); }
.toast { background: var(--color-text); color: var(--color-text-inverse); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: var(--text-sm); }
.map-error { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); border-left: 3px solid var(--color-warning); border-radius: var(--radius); }
.globe-attribution { font-family: var(--font-body); }

/* ---------- Mittlere Breiten ---------- */
@media (min-width: 701px) and (max-width: 1200px) {
  .panel { top: calc(var(--tb-bottom) + 12px); max-height: calc(100vh - var(--tb-bottom) - 12px - 176px); }
}

/* ---------- Niedrige Bildschirme (Handy quer): schmalerer Kopfbereich, Panel als Seitenleiste ---------- */
@media (min-width: 701px) and (max-height: 500px) {
  :root { --header-height: 46px; }
  .topbar button { min-height: 34px; padding: 6px 10px; }
  .panel { top: calc(var(--tb-bottom) + 6px); bottom: 8px; max-height: none; width: min(300px, 45vw); padding: var(--space-3) var(--space-4); }
}

/* ---------- Touch-Geraete: grosse Ziele, 16-px-Eingaben (kein iOS-Zoom) ---------- */
@media (pointer: coarse) {
  .topbar button { min-height: 44px; }
  .address-form input, .position-form input, .refresh-section select, select { font-size: 16px; min-height: 44px; }
  .address-form button, .position-form button { min-height: 44px; font-size: var(--text-sm); }
  .seg button { min-height: 44px; font-size: 14px; }
  .wide-btn { min-height: 44px; }
  .timeline button { min-height: 44px; min-width: 44px; }
}
@media (pointer: coarse) and (min-width: 701px) and (max-height: 500px) { .topbar button { min-height: 36px; } }

/* ---------- Handy Hochformat ---------- */
@media (max-width: 700px) {
  .topbar { padding: env(safe-area-inset-top) var(--space-2) 0; gap: var(--space-1); }
  .hdr-sep { display: none; }
  .brand b { display: none; }
  .brand-logo { height: 24px !important; margin-right: 0; }
  .brand:not(:has(.brand-logo)) { display: none; }
  .topbar button { flex: 1 1 0; min-height: 44px; padding: 8px 2px; font-size: var(--text-sm); text-align: center; }
  #btnSet { margin-left: 0; }
  .map-view-info { left: 8px; top: calc(var(--tb-bottom) + 8px); }
  .panel {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 70vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  }
  @supports (height: 1dvh) { .panel { max-height: 70dvh; } }
  .panel-title { font-size: var(--text-xl); }
  .hint { font-size: 12px; }
}

/* Copyright-Hinweis unten links (nur sichtbar, wenn BRAND_COPYRIGHT gesetzt ist) */
.copyright {
  position:fixed; z-index:900; left:10px; bottom:calc(8px + env(safe-area-inset-bottom));
  font-size:var(--text-xs); color:var(--color-text-subtle); pointer-events:none; user-select:none; white-space:nowrap;
}
@media (max-width:700px) {
  .copyright { bottom:calc(92px + env(safe-area-inset-bottom)); left:8px; }
}
