/* baupunch Brand CSS — extrahiert aus base.html */

/* ── Design-Tokens ──────────────────────────────────────────
   Single Source of Truth für Farben/Radien/Schatten/Abstände.
   Hält die Tür für eine spätere Tailwind-`@theme`-Migration offen,
   ohne jetzt einen Build-Step einzuführen. */
:root {
  /* Flächen */
  --color-bg: #f6f8fa;          /* Seitenhintergrund */
  --color-surface: #fff;        /* Karten, Tabellen, Eingabefelder */
  --color-surface-2: #f0f3f6;   /* Tabellenkopf, Hover-Flächen */
  --color-surface-3: #eef1f4;   /* Tags, Karten-Marker */

  /* Text / dunkle Marke */
  --color-ink: #1C2833;         /* Primärfarbe: Text, Header, Buttons */
  --color-ink-deep: #111a22;    /* Header-Unterkante */
  --color-muted: #5b6673;       /* Sekundärtext, Labels — 5,25:1 auf surface-2 (AA) */
  --color-line: #dfe4ea;        /* Rahmen, Trennlinien */
  --color-table-head: #e8ecf0;  /* thead: eine Stufe dunkler als Zebra-Even */

  /* Text auf dunklem Grund (Header/Nav) */
  --color-on-ink: #fff;
  --color-on-ink-muted: #ffffffcc;
  --color-on-ink-soft: #ffffff22;   /* Nav-Hover-Overlay */

  /* Akzent */
  --color-accent: #FFB300;
  --color-accent-hover: #e6a200;
  --color-accent-soft: #f6f0dc;          /* Treffer-Hover */
  --color-accent-glow: rgba(255, 179, 0, .2);  /* Focus-Ring */

  /* Status: Warnung (innerhalb Geofence) */
  --color-warn-bg: #fff4e5;
  --color-warn-fg: #8a5a00;
  --color-warn-line: #f0c27a;

  /* Status: Erfolg / Gefahr — EIN konsolidiertes Paar (vorher drei Rottöne:
     #b91c1c danger, #c0392b .neg, #d1242f Legenden-Dot). */
  --color-success: #1a7f37;
  --color-success-bg: #e4f5e9;
  --color-danger: #c0392b;
  --color-danger-bg: #fbe6e3;
  --color-danger-line: #f0a3a3;

  /* Radien */
  --radius-sm: 6px;   /* Controls: Buttons, Inputs, Tags, Badges */
  --radius-md: 8px;   /* Inputs / kleine Container */
  --radius-lg: 12px;  /* Karten, Tabellen, KPI, Overlays */

  /* Schatten — Elevation für Karten/Tabellen (vorher nur 1px-Border) */
  --shadow-sm: 0 1px 2px rgba(28, 40, 51, .06), 0 1px 3px rgba(28, 40, 51, .05);
  --shadow-md: 0 2px 10px rgba(28, 40, 51, .09);   /* Hover / angehoben */
  --shadow-pop: 0 6px 18px rgba(0, 0, 0, .12);     /* schwebende Overlays */

  /* Typo-Skala + Zeilenhöhen + Gewichte */
  --fs-xs: .72rem;    /* th, Badges, Tags */
  --fs-sm: .8rem;     /* Labels, kpi-label, Meta */
  --fs-base: .9rem;   /* Body / Tabellenzellen */
  --fs-md: 1rem;
  --fs-lg: 1.15rem;   /* h2 */
  --fs-xl: 1.45rem;   /* h1 */
  --fs-2xl: 1.7rem;   /* KPI-Zahlen */
  --lh-tight: 1.25;   /* Headings */
  --lh-base: 1.5;     /* Body / Absätze */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Abstände — gemeinsamer Layout-Rhythmus auf 4px-Raster (Gaps, Margins,
     Container-Padding). Feinjustierte Control-Paddings bleiben bewusst literal. */
  --space-xs: .25rem;
  --space-sm: .5rem;
  --space-md: .75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;  /* Abstand zwischen Karten/Sektionen */

  /* Abwärtskompatibilität: von map.css/Altcode referenzierte Kurznamen. */
  --fg: var(--color-ink);
  --muted: var(--color-muted);
  --line: var(--color-line);
  --accent: var(--color-accent);
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, sans-serif;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--color-ink);
  margin: 0;
  background: var(--color-bg);
}

/* Links tragen die Marke (Ink + Amber-Hover) statt Browser-Blau.
   Header/Nav haben spezifischere Selektoren und bleiben unberührt. */
a { color: var(--color-ink); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--color-accent); }

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--color-ink);
  border-bottom: 1px solid var(--color-ink-deep);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 60px;   /* Höhe stabil über alle Seiten, auch wenn die Nav wrappt */
  gap: var(--space-lg);
}

header a {
  color: var(--color-on-ink);
  text-decoration: none;
}

header a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

/* ── Main layout ─────────────────────────────────────────── */
main { max-width: 1000px; margin: 1.4rem auto; padding: 0 var(--space-xl); }

h1 { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
/* Seitenkopf: Titel links, primäre Aktion (z. B. „Neue Baustelle") rechts —
   getrennt von der Such-/Filterzeile, die direkt über der Liste sitzt. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); }
.page-head h1 { margin: 0; }

/* ── Table ───────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  text-align: left;
  padding: .5rem .7rem;
  border-bottom: 1px solid var(--color-line);
}

th {
  background: var(--color-table-head);  /* dunkler als Zebra-Even → Kopf hebt sich ab */
  font-size: var(--fs-xs);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* Zebra + Hover für bessere Lesbarkeit (portalweit). */
tbody tr:nth-child(even) { background: var(--color-surface-2); }
tbody tr:hover { background: var(--color-accent-soft); }

/* Zahlen-Spalten rechtsbündig mit Tabellen-Ziffern. */
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Analytics-Abschlusszeilen (unterwegs/pause/unbekannt) vom Orte-Block absetzen. */
tr.subtotal td { color: var(--color-muted); }
tr:not(.subtotal) + tr.subtotal td { border-top: 2px solid var(--color-line); }

/* ── Helpers ─────────────────────────────────────────────── */
.muted { color: var(--color-muted); }

.tag {
  font-size: .75rem;
  padding: .1rem .4rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface-3);
}

/* Semantische Tag-Tints (Status: offen/genehmigt/abgelehnt …) — zurückhaltend,
   damit der neutrale .tag der Default bleibt. */
.tag.warn { background: var(--color-warn-bg); color: var(--color-warn-fg); }
.tag.ok { background: var(--color-success-bg); color: var(--color-success); }
.tag.danger { background: var(--color-danger-bg); color: var(--color-danger); }

/* Soll/Ist-Saldo: positiv (erfüllt/Überstunde) vs. negativ (Defizit). */
.pos { color: var(--color-success); }
.neg { color: var(--color-danger); }
.tag.pos { background: var(--color-success-bg); color: var(--color-success); }
.tag.neg { background: var(--color-danger-bg); color: var(--color-danger); }

/* ── Cards / Forms ───────────────────────────────────────── */
form.card, .card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;   /* klarer Sektionsrhythmus (vorher 1rem: klebte) */
  box-shadow: var(--shadow-sm);
}

label {
  display: block;
  font-size: .8rem;
  color: var(--color-muted);
  margin-top: .6rem;
}

input, textarea, select {
  width: 100%;
  padding: .45rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--color-surface);
  color: var(--color-ink);
}

/* Select: OS-Default-Chrome (Pfeil/Fläche) entfernen und durch eigenen
   Chevron ersetzen, damit Dropdowns wie die übrigen Felder aussehen.
   Der Chevron-Strich ist %235b6673 = --color-muted (Data-URI erlaubt kein var()). */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%235b6673' stroke-width='1.5' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  cursor: pointer;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* ── Buttons ─────────────────────────────────────────────────
   EIN Button-System: natives <button> und .btn teilen Padding/Größe/Gewicht,
   damit z. B. „Anmelden" (nativ) und „CSV-Export" (.btn) gleich hoch sind. */
button {
  background: var(--color-accent);
  color: var(--color-ink);
  border: 0;
  padding: .45rem .8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: var(--space-md);
  font-size: .85rem;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}

button:hover { background: var(--color-accent-hover); }

.btn {
  display: inline-block;
  background: var(--color-accent);
  color: var(--color-ink);
  padding: .45rem .8rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: .85rem;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
}

.btn:hover { background: var(--color-accent-hover); }

/* Kompakte Variante (Tabellenzeilen, Toolbars) — ersetzt die verstreuten
   Inline-Styles `margin:0;padding:.2rem .5rem`. */
.btn-sm, button.btn-sm {
  padding: .2rem .5rem;
  font-size: .78rem;
  margin-top: 0;
}

.btn.secondary {
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-ink);
  cursor: pointer;
  font-weight: 400;
}

.btn.secondary:hover { background: var(--color-surface-2); }

/* ── Filters / Layout helpers ────────────────────────────── */
.filters { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: flex-end; }
.filters > div { flex: 0 0 auto; }
.filters label { margin-top: 0; }
.filters input, .filters select { width: auto; }

/* Editor-Formular (Baustellen/Orte anlegen+bearbeiten): vertikale Spalte statt
   horizontalem Filter-Wrap — sonst drückt die breite Karte das Name-Feld um. */
.editor-form { flex-direction: column; align-items: stretch; max-width: 680px; }
.editor-form > div { flex: 0 0 auto; }
.editor-form input[name="name"] { width: 100%; box-sizing: border-box; }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.err { color: var(--color-danger); }

/* Utilities — ersetzen verstreute Inline-Styles in Templates. */
.w-num { width: 6rem; }                 /* schmale Zahlen-Inputs */
.card--flush { padding: 0; }            /* Karten mit randlosem Inhalt (Karte/Tabelle) */
.mt-0 { margin-top: 0; }
.mt-md { margin-top: var(--space-md); }
.ml-auto { margin-left: auto; }

img.selfie {
  max-width: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-line);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: .72rem;
  padding: .08rem .35rem;
  border-radius: var(--radius-sm);
  background: var(--color-warn-bg);
  color: var(--color-warn-fg);
  border: 1px solid var(--color-warn-line);
  white-space: nowrap;
}

.badge.outside {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: var(--color-danger-line);
}

/* ── Navigation ──────────────────────────────────────────── */
nav.mainnav { display: flex; gap: .2rem; flex-wrap: wrap; }

nav.mainnav a {
  padding: .35rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--color-on-ink);
  text-decoration: none;
}

nav.mainnav a:hover { background: var(--color-on-ink-soft); }

/* Kein Bold im Aktiv-Zustand: die Amber-Fläche markiert bereits — Bold würde
   die Zeilenbreite je nach aktiver Seite ändern und die Nav umbrechen lassen. */
nav.mainnav a.active {
  background: var(--color-accent);
  color: var(--color-ink);
}

nav.mainnav a.active:hover { background: var(--color-accent-hover); }

/* Nutzername + Logout im Header: auf dunklem Hintergrund immer weiß */
header span.muted {
  color: var(--color-on-ink-muted);
}

/* User-Block bricht nicht um; Sprachumschalter als segmentierte Ghost-Gruppe
   auf dem dunklen Header (vorher: weiße Einzel-Kästchen direkt am Namen). */
.user-block { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-sm); }
.lang-switch { display: inline-flex; }
.lang-switch form { margin: 0; }
.lang-switch button {
  margin: 0;
  padding: .18rem .45rem;
  font-size: var(--fs-xs);
  font-weight: var(--fw-normal);
  background: transparent;
  color: var(--color-on-ink-muted);
  border: 1px solid #ffffff44;
  border-radius: 0;
}
.lang-switch form + form button { border-left: none; }
.lang-switch form:first-child button { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.lang-switch form:last-child button { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.lang-switch button:hover { background: var(--color-on-ink-soft); color: var(--color-on-ink); }

header span.muted a {
  color: var(--color-on-ink);
  text-decoration: none;
}

header span.muted a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

/* ── KPI / Grid ──────────────────────────────────────────── */
.grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.kpi { font-size: var(--fs-2xl); font-weight: var(--fw-bold); color: var(--color-ink); line-height: var(--lh-tight); }

.kpi-label {
  color: var(--color-muted);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ── Notiz-Übersetzung (Entry-Detail, HTMX-Lazy-Load) ────── */
.note-translation {
  margin-top: var(--space-md);
  border-top: 1px solid var(--color-line);
  padding-top: var(--space-sm);
}
.note-translation-meta { font-size: var(--fs-sm); }
.note-translation-text { white-space: pre-wrap; }
.note-translation-unavailable { margin-top: var(--space-sm); }

/* ── Copy-Box ────────────────────────────────────────────── */
.copybox { display: flex; gap: var(--space-sm); }
.copybox input { font-family: ui-monospace, monospace; font-size: .8rem; }

/* ── Row / Table Helpers ─────────────────────────────────── */
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

tr.archived { opacity: .55; }

form.inline { margin: 0; }
form.inline select { margin-top: 0; width: auto; }

/* ── Geocode Widget ──────────────────────────────────────── */
.geocode-widget { min-width: 14rem; }

/* Suchbox + Treffer-Dropdown: die Treffer schweben als Overlay unter dem Feld,
   statt die Karte nach unten zu drücken. */
.geocode-search { position: relative; }
.geocode-bar { display: flex; gap: .4rem; align-items: stretch; }
.geocode-bar input { flex: 1 1 auto; }
.geocode-bar .btn { margin-top: 0; white-space: nowrap; }

.geocode-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; }

.geocode-hits {
  list-style: none;
  margin: .2rem 0 0;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 12rem;
  overflow-y: auto;
  background: var(--color-surface);
  box-shadow: var(--shadow-pop);
}

.geocode-hits li + li { border-top: 1px solid var(--color-line); }

.geocode-hit {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0;
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: 0;
  padding: .4rem .55rem;
  font-size: .82rem;
}

.geocode-hit:hover { background: var(--color-accent-soft); }

.geocode-current {
  display: block;
  margin-top: .35rem;
  font-size: .82rem;
  color: var(--color-muted);
}

.geocode-status { display: flex; align-items: center; gap: var(--space-sm); margin-top: .35rem; flex-wrap: wrap; }
.geocode-empty {
  margin: .2rem 0 0;
  padding: .4rem .55rem;
  font-size: .82rem;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}

/* ── Segment-Buttons (Statusfilter) ─────────────────────────────────────── */
.status-filter { display: flex; gap: 0; }

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: .35rem .6rem;
  font-size: .82rem;
  cursor: pointer;
  border: 1px solid var(--color-line);
  border-right: none;
  background: var(--color-surface);
  color: var(--color-ink);
  margin: 0;
}

.seg-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.seg-btn:last-child { border-right: 1px solid var(--color-line); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.seg-btn:hover { background: var(--color-surface-2); }

.seg-btn input[type="radio"] { display: none; }

.seg-btn:has(input:checked),
.seg-btn.active {
  background: var(--color-ink);
  color: var(--color-on-ink);
  border-color: var(--color-ink);
}

/* Segment-Buttons sind hier echte <button>: Standard-Button-Look neutralisieren. */
.status-filter .seg-btn { margin-top: 0; font-weight: 400; }
.status-filter .seg-btn:hover:not(.active):not(:disabled) { background: var(--color-surface-2); }
.seg-btn:disabled { opacity: .4; cursor: default; }

/* Timesheets-Periodenleiste: Umschalter links, Zeitraum-Label rechts. */
.period-bar { display: flex; align-items: center; gap: var(--space-lg); flex-wrap: wrap; }
.period-label { font-size: .85rem; }

/* Toolbar: etwas weniger Padding als normales Card */
.card.toolbar { padding: .7rem var(--space-lg); }

/* ── Charts (Analytics) ──────────────────────────────────── */
.chart-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* Feste Höhe, damit Chart.js (maintainAspectRatio:false) nicht ins Endlose wächst. */
.chart-box { position: relative; height: 260px; }
