/* Schiffsradar24 Web-App: Karte + Flotte + Logbuch + Alarme + Konto in einer App, Hell/Dunkel */

:root {
  --a-flaeche: #ffffff; --a-flaeche2: #f4f7f9; --a-text: #1a2b3c; --a-leise: #6b7785; --a-rand: #e3e9ee;
  --a-akzent: #0f7f87; --a-gruen: #31ae86; --a-link: #1f8a68;
  --sr-nav-h: calc(58px + env(safe-area-inset-bottom));
  color-scheme: light;
}
html[data-thema="dunkel"] {
  --a-flaeche: #121b24; --a-flaeche2: #182430; --a-text: #e3eaf1; --a-leise: #9aa8b6; --a-rand: #2a3846;
  --a-akzent: #3cc3b8; --a-gruen: #3cc79a; --a-link: #5fd3ad;
  color-scheme: dark;
  /* Variablen der Karte und des Flotten-Managers umfaerben */
  --sr-dunkel: #e3eaf1; --sr-grau: #9aa8b6; --sr-rand: rgba(255, 255, 255, .12); --sr-schatten: 0 2px 12px rgba(0, 0, 0, .5);
  --fmm-dunkel: #e3eaf1; --fmm-grau: #9aa8b6; --fmm-hell: #182430; --fmm-rand: #2a3846;
  --fml-navy: #cfe0f5;
}
html, body { background: var(--a-flaeche); }

/* Installiert laeuft die App ohnehin im Vollbild - Vollbild-Knopf ausblenden, Notch/Home-Leiste beruecksichtigen */
.sr-app-installiert #sr-btn-fs { display: none; }
@media (display-mode: standalone) {
  #sr-btn-fs { display: none; }
  #sr-top { padding-top: env(safe-area-inset-top); }
  #sr-status { margin-bottom: env(safe-area-inset-bottom); }
}

#sr-app-install {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--sr-nav-h) + 10px); z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--a-flaeche); color: var(--a-text); border-radius: 14px; box-shadow: 0 6px 24px rgba(16, 42, 67, .25);
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  animation: sr-ai-ein .25s ease-out;
}
@keyframes sr-ai-ein { from { transform: translateY(20px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #sr-app-install { animation: none; } }
#sr-app-install img { border-radius: 9px; flex-shrink: 0; }
.sr-ai-text { flex: 1; min-width: 0; }
.sr-ai-text b { display: block; }
.sr-ai-text span { color: var(--a-leise); font-size: 13px; }
.sr-ai-share { width: 17px; height: 17px; vertical-align: -3px; fill: none; stroke: #0a84ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-ai-ok { border: 0; background: var(--a-akzent); color: #fff; font-weight: 700; border-radius: 9px; padding: 9px 12px; cursor: pointer; }
.sr-ai-x { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--a-leise); cursor: pointer; padding: 0 2px; }
@media (min-width: 700px) { #sr-app-install { left: auto; width: 380px; } }

/* --------- Leiste unten: Karte | Flotte | Logbuch | Alarme | Konto --------- */
#sr-app { bottom: var(--sr-nav-h); }
#sr-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--sr-nav-h); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--a-flaeche); border-top: 1px solid var(--a-rand); box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
#sr-nav button { flex: 1; min-width: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 600 11px/1.2 inherit; font-family: inherit; color: var(--a-leise); cursor: pointer; -webkit-tap-highlight-color: transparent; padding: 0; }
#sr-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sr-nav button[aria-current="page"] { color: var(--a-akzent); }
#sr-nav button[aria-current="page"] svg { stroke-width: 2.2; }
@media (min-width: 700px) { #sr-nav { justify-content: center; } #sr-nav button { flex: 0 1 120px; font-size: 12px; } }

/* --------- Bereiche ueber der Karte (scrollbar) --------- */
.bereich { position: fixed; top: 0; left: 0; right: 0; bottom: var(--sr-nav-h); z-index: 30; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--a-flaeche); padding: calc(14px + env(safe-area-inset-top)) 14px 28px; box-sizing: border-box;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--a-text); }
.bereich[hidden] { display: none; }
.bereich > div { max-width: 980px; margin-left: auto; margin-right: auto; }
.bereich h2 { font-size: 22px; font-weight: 700; }
.bereich h3 { font-size: 18px; font-weight: 700; }
.bereich h4 { font-size: 16px; font-weight: 700; }
.bereich a { color: var(--a-link); }
.bereich input, .bereich select, .bereich textarea, .bereich button { font-family: inherit; }
/* Laden: statt Text ("... wird geladen") nur ein dezenter Kreisel */
.bereich .fml-laden, .bereich .fmm-laden, .bereich .b-laden, #sr24a > p.sr24a-leise:only-child {
  font-size: 0 !important; color: transparent !important; height: 90px; margin: 0; padding: 0; position: relative; }
.bereich .fml-laden::after, .bereich .fmm-laden::after, .bereich .b-laden::after, #sr24a > p.sr24a-leise:only-child::after {
  content: ""; position: absolute; left: 50%; top: 40px; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%;
  border: 3px solid var(--a-rand); border-top-color: var(--a-akzent); animation: a-dreh .8s linear infinite;
  opacity: 0; animation-delay: .25s; animation-fill-mode: forwards; }
@keyframes a-dreh { from { opacity: 1; transform: rotate(0); } to { opacity: 1; transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bereich .fml-laden::after, .bereich .fmm-laden::after, .bereich .b-laden::after { animation: none; opacity: .6; } }

/* Hell/Dunkel-Schalter: in der Kartenleiste (.sr-btn) und als runder Knopf oben rechts in den Bereichen */
.a-thema-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.a-thema-ecke { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 35; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--a-rand); background: var(--a-flaeche); color: var(--a-text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); -webkit-tap-highlight-color: transparent; }
.bereich[hidden] .a-thema-ecke { display: none; }
.bereich h2:first-child, .bereich .fml-kopf, .bereich .fmm-steuer { padding-right: 46px; }

/* Gast-Hinweis in Flotte/Alarme */
.b-gast { max-width: 520px; margin: 40px auto 0; text-align: center; }
.b-gast .ico { font-size: 40px; }
.b-gast p { color: var(--a-leise); }
.b-knoepfe { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.b-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 700;
  text-decoration: none !important; border: 1px solid var(--a-rand); color: var(--a-text) !important; background: var(--a-flaeche); }
.b-btn-p { background: var(--a-gruen); border-color: var(--a-gruen); color: #fff !important; }

/* --------- Konto (eigene Ansicht der App) --------- */
#konto { max-width: 620px; }
.k-kopf { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.k-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--a-akzent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex: 0 0 auto; }
.k-kopf h2 { margin: 0; font-size: 22px; }
.k-badge { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--a-flaeche2); color: var(--a-leise); }
.k-badge-p { background: #fff4d6; color: #8a5a00; }
.k-karte { background: var(--a-flaeche); border: 1px solid var(--a-rand); border-radius: 14px; margin: 0 0 14px; overflow: hidden; }
.k-karte h3 { margin: 0; padding: 14px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--a-leise); }
.k-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--a-rand);
  color: var(--a-text) !important; text-decoration: none !important; font-weight: 600; min-height: 52px; box-sizing: border-box; }
.k-karte h3 + .k-zeile { border-top: 0; }
.k-zeile span { color: var(--a-leise); font-weight: 400; font-size: 14px; text-align: right; }
.k-rot { color: #d64545 !important; }
.k-segment { display: flex; border: 1px solid var(--a-rand); border-radius: 10px; overflow: hidden; margin: 6px 16px 16px; }
.k-segment button { flex: 1; min-height: 42px; border: 0; border-left: 1px solid var(--a-rand); background: var(--a-flaeche); color: var(--a-text); font-weight: 600; font-size: 14px; cursor: pointer; }
.k-segment button:first-child { border-left: 0; }
.k-segment button[aria-pressed="true"] { background: var(--a-akzent); color: #fff; }
.k-premium { background: linear-gradient(135deg, #1e293b, #334155); color: #fff; border: 0; padding: 16px; }
.k-premium p { color: #cbd5e1; margin: 6px 0 12px; font-size: 14px; }
.k-premium .b-btn { background: #e6af07; border-color: #e6af07; color: #1e293b !important; }
.k-fuss { text-align: center; color: var(--a-leise); font-size: 12px; margin: 20px 0 0; }
.k-fuss a { color: var(--a-leise) !important; }

/* --------- Dunkelmodus: Karten-Oberflaeche (die Karte selbst bleibt vorerst hell) --------- */
html[data-thema="dunkel"] #sr-search,
html[data-thema="dunkel"] .sr-btn,
html[data-thema="dunkel"] .sr-sheet,
html[data-thema="dunkel"] #sr-info,
html[data-thema="dunkel"] #sr-results,
html[data-thema="dunkel"] #sr-status,
html[data-thema="dunkel"] #sr-flotte,
html[data-thema="dunkel"] .sr-chip { background-color: var(--a-flaeche2) !important; color: var(--a-text) !important; border-color: var(--a-rand) !important; }
html[data-thema="dunkel"] #sr-q { color: var(--a-text); background: transparent; }
/* Kartenknoepfe (Zoom, Kompass, Standort), Karteninfo (i) und Maszstab: dunkel mit hellen Symbolen */
html[data-thema="dunkel"] .maplibregl-ctrl-group,
html[data-thema="dunkel"] .maplibregl-ctrl-attrib.maplibregl-compact,
html[data-thema="dunkel"] .maplibregl-ctrl-attrib { background-color: var(--a-flaeche2) !important; color: var(--a-text); }
html[data-thema="dunkel"] .maplibregl-ctrl-group button + button { border-top-color: var(--a-rand); }
html[data-thema="dunkel"] .maplibregl-ctrl-group .maplibregl-ctrl-icon,
html[data-thema="dunkel"] .maplibregl-ctrl-attrib-button { filter: invert(1) hue-rotate(180deg); }
html[data-thema="dunkel"] .maplibregl-ctrl-attrib a { color: var(--a-link); }
html[data-thema="dunkel"] .maplibregl-ctrl-scale { background-color: rgba(18, 27, 36, .85); color: var(--a-text); border-color: var(--a-text); }
html[data-thema="dunkel"] #sr-info .sr-close,
html[data-thema="dunkel"] #sr-info .sr-mf-btn,
html[data-thema="dunkel"] #sr-info .sr-teilen-btn,
html[data-thema="dunkel"] #sr-info .sr-alarm-btn { background: rgba(18, 27, 36, .9); color: var(--a-text); }
