/* finnland-reiseapp — mobile-first, dark Polar-Night theme */

:root {
  --bg: #0b1220;
  --panel: #101a2e;
  --panel-2: #0d1526;
  --line: #1e2c47;
  --text: #e7eefc;
  --muted: #8fa3c4;
  --accent: #7c6cff;
  --accent-2: #22c55e;
  --danger: #f87171;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* versteckt schlägt Klassen-display (Login/App-Toggle) */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ── Login ── */
.login-view {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.login-card h1 { font-size: 20px; margin: 0; text-align: center; }
.login-card .muted { color: var(--muted); font-size: 12.5px; text-align: center; margin: 0 0 8px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px; /* >=16px verhindert iOS-Zoom */
}
.login-card button {
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 10px;
  padding: 13px;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
}
.login-card button:active { filter: brightness(1.15); }
.login-error { color: var(--danger); font-size: 13px; margin: 0; text-align: center; }

/* ── App-Shell ── */
#app-view { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  height: 40px;
  padding: calc(4px + var(--safe-top)) 8px 4px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .title { font-weight: 600; font-size: 13px; color: var(--muted); }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 17px;
  min-width: 40px; min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn:active { background: var(--panel-2); }

/* ── Drawer (Hamburger-Menü) ── */
#drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, 0.6);
  z-index: 50;
}
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(300px, 82vw);
  background: var(--panel);
  border-right: 1px solid var(--line);
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  z-index: 60;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 10px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.drawer-title { font-weight: 600; font-size: 13.5px; }
.drawer-sep { border: none; border-top: 1px solid var(--line); margin: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14.5px;
  text-align: left;
  padding: 13px 16px;
  min-height: 48px;
  cursor: pointer;
}
.nav-item:active { background: var(--panel-2); }
.nav-item.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.logout { color: var(--muted); margin-top: auto; }

main#content { flex: 1; padding: 12px; }
.tab .placeholder-card {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

@media (min-width: 700px) {
  main#content { max-width: 1080px; width: 100%; margin: 0 auto; }
  #map { height: calc(100dvh - 230px); }
}

/* ── Karte ── */
#map { height: calc(100dvh - 220px); min-height: 380px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); z-index: 1; }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.75); }
.dm {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #0a1020;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.dm.sm { width: 24px; height: 24px; flex: 0 0 24px; }
.poi {
  width: 30px; height: 30px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: #132042;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.leaflet-popup-content { margin: 12px 14px; }
.pop h3 { margin: 0 0 2px; font-size: 14px; }
.pop .d { font-size: 11.5px; color: #5b6b86; margin-bottom: 6px; }
.pop .n { font-size: 12.5px; line-height: 1.5; color: #243247; }
.leaflet-control-attribution { background: rgba(10, 15, 28, 0.7) !important; color: #7d8ea9 !important; }
.leaflet-control-attribution a { color: #9cc1ff !important; }

/* ── Etappenliste ── */
.stages-list { display: flex; flex-direction: column; gap: 4px; }
.phase-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted);
  margin: 14px 4px 4px;
}
.phase-head:first-child { margin-top: 4px; }
.swatch { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.stage-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  min-height: 52px;
}
.stage-row:active { border-color: var(--accent); }
.stage-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stage-main .route { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.stage-main .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.km { background: #182947; border-radius: 6px; padding: 1px 6px; font-size: 10.5px; color: #bcd0f2; }

/* ── Stellplätze (Stays) ── */
.stays-block {
  display: flex; flex-direction: column; gap: 4px;
  margin: -6px 0 8px 34px;
}
.stay-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
}
.fav-btn { background: none; border: none; cursor: pointer; font-size: 15px; opacity: 0.35; min-width: 30px; min-height: 30px; }
.fav-btn.on { opacity: 1; }
.stay-name { font-weight: 600; }
.stay-meta { color: var(--muted); font-size: 11.5px; }
.p4n { color: #9cc1ff; font-size: 11.5px; }
.stay-del { background: none; border: none; cursor: pointer; font-size: 13px; margin-left: auto; min-width: 30px; min-height: 30px; }
.stay-add {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 14px;
  min-height: 38px;
  cursor: pointer;
  font-size: 12.5px;
}
.stay-form {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px;
}
.stay-form input, .stay-form select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}
.stay-form .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-actions { display: flex; gap: 8px; }
.form-actions button {
  flex: 1; min-height: 44px;
  border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.form-actions .cancel-stay { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.form-error { color: var(--danger); font-size: 12px; margin: 0; }
.stay-pin {
  width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: #132042;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.6);
}
.stay-pin.fav { box-shadow: 0 0 0 2px #facc15, 0 2px 8px rgba(0, 0, 0, 0.6); }
.stay-del-in-popup { margin-top: 6px; }

/* ── Notfall-Tab (Großschrift) ── */
.nf-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.nf-card h2 { font-size: 16px; margin: 0 0 10px; color: var(--text); }
.nf-country {
  display: flex; gap: 14px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.nf-country:last-child { border-bottom: none; }
.nf-flag { font-size: 30px; }
.nf-land { color: var(--muted); font-size: 12.5px; }
.nf-big { font-size: 20px; font-weight: 700; margin: 2px 0; }
.nf-big a { color: var(--danger); text-decoration: none; }
.nf-small { font-size: 13px; color: var(--muted); }
.nf-line { padding: 5px 0; font-size: 14px; line-height: 1.5; }
.nf-hint { color: var(--muted); font-size: 11.5px; text-align: center; }

.update-hint {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
  z-index: 1000;
}

/* ── Positions-Karte + Pin ── */
.pos-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.pos-row { display: flex; align-items: center; gap: 10px; }
.pos-icon { font-size: 18px; }
.pos-info { flex: 1; min-width: 0; }
.pos-text { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-time { font-size: 11.5px; color: var(--muted); }
.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 10px;
  padding: 10px 14px;
  min-height: 40px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-accent:disabled { opacity: 0.6; }
.btn-ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-width: 40px; min-height: 40px;
  font-size: 15px;
  cursor: pointer;
}
.btn-ghost.active { border-color: var(--accent); color: var(--accent); }
.pos-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.form-grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid3 label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 11px; color: var(--muted);
}
.form-grid3 label:last-child { grid-column: 1 / -1; }
.pos-form input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  min-height: 40px;
}
.pos-form input[name="note"] { font-size: 16px; }
.form-actions { margin-top: 8px; }
.form-actions button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 8px;
  padding: 11px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}
.pos-pin {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: #132042;
  box-shadow: 0 0 0 2px var(--accent-2), 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* ── Checklisten ── */
.progress-card, .cl-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.progress-head {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--muted);
  margin-bottom: 6px;
}
.progress-track {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill { height: 100%; background: var(--accent-2); border-radius: 3px; transition: width 0.3s ease; }
.cl-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.cl-title { font-weight: 600; font-size: 14px; }
.cl-count {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11.5px;
  color: var(--muted);
}
.cl-count.complete { background: rgba(34, 197, 94, 0.15); color: var(--accent-2); }
.cl-item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 6px;
  min-height: 44px;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.45;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.cl-item:last-child { border-bottom: none; }
.cl-check {
  flex: 0 0 24px; height: 24px;
  border: 2px solid var(--muted);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
  color: #0a1020;
}
.cl-item.done .cl-check { background: var(--accent-2); border-color: var(--accent-2); }
.cl-item.done .cl-text { color: var(--muted); text-decoration: line-through; }

/* ── Segment-Umschalter (Trip / Eigene Listen) ── */
.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 12px;
}
.seg-btn {
  flex: 1;
  min-height: 42px;
  background: transparent;
  border: none;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.active { background: var(--accent); color: #fff; }
.btn-accent.wide { width: 100%; margin-bottom: 12px; }
.list-new-form {
  display: flex; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
}
.list-new-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}
.list-new-form button {
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.list-card .cl-head { margin-bottom: 6px; }
.list-tools { display: flex; gap: 4px; }
.icon-mini {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  min-width: 34px; min-height: 34px;
  font-size: 13px;
  cursor: pointer;
}
.icon-mini.danger.confirm { border-color: var(--danger); color: var(--danger); }
.list-items { display: flex; flex-direction: column; }
.list-item-row { display: flex; align-items: stretch; gap: 4px; }
.list-item-row .cl-item { flex: 1; }
.list-item-row .item-del { align-self: center; }
.list-add-form { display: flex; gap: 6px; margin-top: 8px; }
.list-add-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  min-height: 40px;
}
.list-add-form button {
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 8px;
  min-width: 40px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

/* ── park4night-Suche im Stellplatz-Formular ── */
.stay-form .p4n-search {
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 40px;
  font-size: 12.5px;
  cursor: pointer;
}
.stay-form .p4n-search:disabled { opacity: 0.5; }
.p4n-results { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.p4n-loading { color: var(--muted); font-size: 12px; padding: 4px; }
.p4n-hit {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  min-height: 38px;
}
.p4n-hit:hover { border-color: var(--accent); }
