/* ============================================================
   FF Design-System — Tokens & Base (eingespielt via /ff-design)
   Single Source of Truth: ~/.claude/ff-design/ff-design.css
   FF-CI: Rot #C8102E, Weiß, Schwarz · Open Sans · plakativ-kantig.
   ============================================================ */

/* Open Sans selbst-gehostet → offline-fähig (Variable Font 400–800, latin) */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/public/vendor/opensans/open-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Brand */
  --brand: #C8102E;            /* FF-Rot */
  --brand-deep: #9d0c24;       /* hover/pressed — gleicher Farbton, dunkler */
  --brand-ink: #6b0818;        /* für sehr seltenen Text-Akzent */

  /* Surfaces — Weiß + sehr leichtes Grau für Lesbarkeit */
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f4f5;          /* neutrales Grau für Form-Felder, Tabellen-Zebra */
  --bg-accent: #ffe5e7;          /* dezent rotes Wash für aktive Bereiche */

  /* Ink — Schwarz/Anthrazit-Skala (neutral, keine Wärme) */
  --ink: #000000;                /* Headlines, Buttons */
  --ink-soft: #1a1a1a;           /* Body */
  --ink-muted: #595959;          /* Hilfe-Texte */
  --ink-faint: #9a9a9a;          /* Placeholder */

  /* Lines */
  --line: #e5e5e5;
  --line-strong: #bdbdbd;

  /* Semantic (für Status — NICHT Branding) */
  --warn: #b45309;
  --warn-bg: #fef5e7;
  --err: var(--brand);
  --err-bg: #ffe5e7;
  --ok-bg: #ecfaf1;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* Type — Open Sans (selbst-gehostet, oben). Fallback: System-Sans. */
  --font-display: var(--font-sans, "Open Sans"), -apple-system, BlinkMacSystemFont,
                  "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ui: var(--font-display);

  /* Radius — eher kantig, CI ist plakativ */
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 4px;
  --r-4: 6px;

  /* Shadow — kaum sichtbar, plakativer Look bevorzugt scharfe Kanten */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.08);

  /* Touch target minimum */
  --touch: 44px;
}

/* Plakative FF-Headlines — ExtraBold, leichtes negatives Tracking */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.4rem); }
h3 { font-weight: 700; }
h4 { font-weight: 700; }

a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { color: var(--brand-deep); text-decoration: underline; text-underline-offset: 3px; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---- Projekt-Tokens auf FF-Kanon gemappt (vormals eigenes Blau/Slate-Schema) ---- */
:root {
  --bg: var(--bg-subtle);       /* war #eef2f7 (Blau-Grau) */
  --text: var(--ink-soft);      /* war #0f172a */
  --accent: var(--brand);       /* war #0b5ed7 — jetzt FF-Rot */
  --danger: var(--brand-deep);  /* war #b42318 */
  --ok: #0f7b3e;                /* an FF --ok angeglichen (war #127a37) */
  --card: var(--bg-elevated);   /* war #ffffff */
  --border: var(--line);        /* war #d0d7e2 (Blau-Grau) */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.35;
  text-rendering: optimizeLegibility;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: var(--r-4);
  padding: 1.6rem;
  box-shadow: var(--shadow-2);
}

.login-form { display: grid; gap: .7rem; }
.login-form input {
  font-size: 1.1rem;
  padding: .75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  transition: border-color .15s, box-shadow .15s;
}
.login-form input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, .15);
}
button, .btn-link {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: var(--r-2);
  font-size: 1rem;
  font-weight: 700;
  padding: .7rem .9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, transform .04s;
}
button:not(:disabled):hover, .btn-link:hover { background: var(--brand-deep); color: #fff; }
button:not(:disabled):active { transform: translateY(1px); }
button.secondary {
  background: var(--ink-soft);
}
button.secondary:not(:disabled):hover { background: #000; }

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: var(--brand);
  border-bottom: none;
  padding: .4rem .7rem;
}
.topbar strong {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.topbar strong::before {
  content: "";
  width: 14px;
  height: 14px;
  background: #fff;
  display: inline-block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: nowrap;
}

/* Buttons auf der roten Topbar: weiß umrandet, transparent */
.topbar .secondary {
  background: transparent;
  border: 1px solid rgba(255,255,255,.6);
  color: #fff;
}
.topbar .secondary:not(:disabled):hover { background: rgba(255,255,255,.16); color: #fff; }

.offline-chip {
  font-size: .84rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .01em;
  padding: .26rem .42rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.switch-dot {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: #ffffff;
  display: grid;
  place-items: center;
  font-size: .95rem;
}
.switch-dot-loading {
  animation: spinner-hand 1.2s linear infinite;
}

@keyframes spinner-hand {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.switch-label {
  min-width: 2.2rem;
  text-align: center;
  padding-right: .15rem;
}
/* Status-Chips als weiße Pillen mit farbiger Schrift — kontrastieren auf der roten Topbar */
.offline-switch-on {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--ok);
}
.offline-switch-off {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--brand);
}
.offline-switch-loading {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--ink-muted);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .42rem .58rem;
  font-size: .9rem;
  border-radius: 999px;
  white-space: nowrap;
}

.btn-icon {
  font-size: 1.02rem;
  line-height: 1;
}

#offlinePrepareBtn[disabled] {
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.6);
  cursor: progress;
}

.danger-btn {
  background: var(--brand-deep);
}

.logout-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  font-size: 1.3rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.offline-hint {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 25;
  padding: .5rem .7rem;
  background: var(--warn);
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.18);
}

#map {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
}

#map .maplibregl-ctrl-top-left,
#map .maplibregl-ctrl-top-right {
  top: 42px;
}

.overlay-buttons {
  position: fixed;
  right: .8rem;
  bottom: 6.3rem;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

/* Locate-Fadenkreuz ausblenden, solange das Detail-Panel offen ist */
#panel:not([hidden]) ~ .overlay-buttons { display: none; }

.round {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  font-size: 1.4rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 12px rgba(0,0,0,.2);
}
.round.disabled {
  background: var(--ink-faint);
  color: #fff;
  opacity: .72;
}

.gps-status {
  position: fixed;
  left: .7rem;
  bottom: 1rem;
  z-index: 60;
  background: rgba(0, 0, 0, .85);
  color: #fff;
  border-radius: 999px;
  padding: .4rem .75rem;
  font-size: .85rem;
}
.gps-status.error {
  background: var(--brand);
}
.gps-howto-btn {
  margin-left: .45rem;
  border: 1px solid rgba(255,255,255,.45);
  background: rgba(255,255,255,.16);
  color: #fff;
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .82rem;
  font-weight: 700;
}

.panel {
  position: fixed;
  z-index: 70;
  left: .7rem;
  right: .7rem;
  bottom: .7rem;
  max-height: 62vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-4);
  padding: .9rem 1rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.14);
  font-size: 1.08rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.22;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .6rem;
}

.panel-close-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-2);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  background: var(--brand);
}

.panel-compact {
  display: grid;
  gap: .4rem;
}

.kv {
  display: grid;
  grid-template-columns: minmax(150px, 44%) 1fr;
  gap: .55rem;
  border-bottom: 1px solid var(--line);
  padding: .1rem 0 .34rem;
  align-items: start;
}

.kv b {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.kv span {
  line-height: 1.22;
  overflow-wrap: anywhere;
}
.kv-actions {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}
.map-link {
  color: var(--brand);
  text-decoration: underline;
  font-weight: 650;
}
.copy-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-2);
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--ink-soft);
}

#detailsBtn {
  margin-top: .55rem;
  width: 100%;
  font-weight: 650;
}

.panel-details {
  margin-top: .72rem;
  padding: .72rem .78rem;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--bg-subtle);
}

.panel-details .kv {
  grid-template-columns: minmax(170px, 48%) 1fr;
}

.panel-assets {
  margin-top: .85rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: .58rem;
  flex-wrap: wrap;
}

.panel-assets::before {
  content: "Anhänge";
  width: 100%;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: .15rem;
}
.panel-assets a { text-decoration: none; }
.asset-thumb-button {
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 8px;
}
.thumb {
  width: 116px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--r-3);
  border: 1px solid var(--line);
  cursor: pointer;
}

.media-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(2, 6, 23, 0.72);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.media-overlay[hidden] {
  display: none !important;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(2, 6, 23, 0.62);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.confirm-overlay[hidden] {
  display: none !important;
}

.confirm-dialog {
  width: min(480px, 100%);
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: var(--r-4);
  padding: 1.2rem;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}

.confirm-dialog h3 {
  margin: 0 0 .45rem;
}

.confirm-dialog p {
  margin: 0;
  color: var(--ink-soft);
}

.confirm-actions {
  margin-top: .9rem;
  display: flex;
  gap: .55rem;
  justify-content: flex-end;
}

.media-dialog {
  width: min(1200px, 100%);
  height: min(92vh, 100%);
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--r-4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.media-header {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: .5rem;
  color: #f8fafc;
  padding: .5rem .7rem;
  border-bottom: 1px solid #334155;
}

#mediaTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sekundär-Buttons auf dem dunklen Media-Header: heller Umriss statt Schwarz */
.media-header .secondary {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
}
.media-header .secondary:not(:disabled):hover { background: rgba(255,255,255,.26); }

.media-zoom-controls {
  display: flex;
  gap: .4rem;
}

.media-gallery-controls {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.media-gallery-controls span {
  min-width: 3.2rem;
  text-align: center;
  font-weight: 700;
  letter-spacing: .01em;
}

.close-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-2);
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
  background: var(--brand);
  justify-self: end;
}

.media-stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #020617;
  touch-action: none;
}

.media-image {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  will-change: transform;
  cursor: grab;
  user-select: none;
}

.media-image.dragging {
  cursor: grabbing;
}

.media-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  background: #111827;
}

.marker-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.3);
}

@media (min-width: 900px) {
  .panel {
    right: auto;
    width: 470px;
  }
}

@media (max-width: 640px) {
  button, .btn-link { font-size: 1.06rem; padding: .88rem 1rem; }
  .topbar { height: 60px; }
  .topbar-actions { gap: .3rem; }
  .offline-chip { font-size: .74rem; padding: .2rem .35rem; }
  .switch-dot { width: 1.45rem; height: 1.45rem; font-size: .86rem; }
  .switch-label { min-width: 1.9rem; }
  .action-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 999px;
    justify-content: center;
    gap: 0;
  }
  .action-btn .btn-text { display: none; }
  .action-btn .btn-icon { font-size: 1.18rem; }
  .offline-hint { top: 60px; }
  #map { top: 60px; }
  #map .maplibregl-ctrl-top-left,
  #map .maplibregl-ctrl-top-right { top: 46px; }
  .round { width: 58px; height: 58px; }
  .gps-status { font-size: .95rem; }
  .panel {
    font-size: 1.12rem;
    max-height: 66vh;
    padding: .95rem;
  }
  .panel h2 { font-size: 1.34rem; }
  .kv { grid-template-columns: minmax(140px, 45%) 1fr; gap: .5rem; }
  .panel-details .kv { grid-template-columns: minmax(150px, 47%) 1fr; }
  .thumb { width: 110px; height: 80px; }
}

@media (pointer: coarse) {
  .media-zoom-controls { display: none; }
}
