/*
  Wiederverwendbare Komponenten (Zusatzprompt §18) – Namen bewusst
  konzeptionell an die künftigen Flutter-Widgets angelehnt
  (ProjectCard, PrimaryButton, StatusBadge, EmptyState, BottomNavigation, …).
*/

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-surface-alt);
}

button {
  font-family: inherit;
  /* Browser setzen für <button> sonst eine feste UA-Textfarbe
     (z. B. "buttontext"), die unsere Theme-Variable ignoriert – dadurch
     blieb Text in Buttons wie .project-card im Dark Mode schwarz und
     unlesbar. */
  color: inherit;
}

/* ---------- App-Bar ----------
   Anlehnung an den bereitgestellten Referenz-Screen: heller, ruhiger
   Header ohne harte Trennlinie, mit einem dezenten farbigen Blur-Akzent
   statt eines vollflächigen Farbblocks. */
.app-bar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4) var(--space-4);
  background: var(--color-surface);
}

.app-bar__blob {
  position: absolute;
  top: -60px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 106, 44, 0.16), rgba(232, 106, 44, 0) 70%);
  pointer-events: none;
}

.app-bar__title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

.app-bar__brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-bar__brand img {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
}

.app-bar__badge {
  color: #d32f2f;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: 0 var(--space-2);
}

.icon-button {
  width: var(--touch-target);
  height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font-size: 20px;
}

.icon-button:hover {
  background: var(--color-surface-alt);
}

/* ---------- Bottom-Bar mit zentriertem FAB ----------
   §78: "+ Dokumentieren" ist ein PROMINENTER, ZENTRALER Einstieg – analog
   zum bereitgestellten Referenz-Screen wird der Kreis-Button mittig über
   der unteren Leiste "angehoben" dargestellt, statt unten rechts zu
   schweben. Ab Phase 2/3, sobald die eigentliche Bottom-Navigation
   (Übersicht/Timeline/Mängel/Mehr, §77) dazukommt, wird dieselbe
   .bottom-bar-Struktur um .bottom-nav__item-Elemente links/rechts vom FAB
   ergänzt. */
.bottom-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Variante mit Bereichs-Tabs links/rechts vom FAB (§77, ab Projekt-Detail) */
.bottom-bar--nav {
  justify-content: space-around;
  padding: 4px 8px 4px;
}

.bottom-bar--nav .bottom-nav__item {
  flex: none;
  width: 64px;
}

.bottom-bar--nav .fab {
  top: -22px;
}

.fab {
  position: absolute;
  left: 50%;
  top: -26px;
  transform: translateX(-50%);
  width: 60px;
  height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 4px solid var(--color-bg);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-size: 26px;
  line-height: 1;
  box-shadow: var(--shadow-fab);
  cursor: pointer;
}

.fab:active {
  transform: translateX(-50%) scale(0.96);
}

/* ---------- Status-Badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge--defect {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.status-badge--obstruction {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-badge--progress {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-badge--note {
  background: var(--color-surface-alt);
  color: var(--color-text-secondary);
}

.status-badge--phase {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

/* ---------- Project Card ---------- */
.project-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.project-card:active {
  transform: scale(0.98);
}

.project-card + .project-card {
  margin-top: var(--space-3);
}

.project-card__icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.project-card__body {
  flex: 1;
  min-width: 0;
}

.project-card__name {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card__address {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0;
  min-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card__progress-track {
  display: block;
  height: 8px;
  margin: var(--space-2) 0;
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  overflow: hidden;
}

.project-card__progress-fill {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}

.project-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-3);
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-5);
  color: var(--color-text-secondary);
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: var(--space-2);
}

.empty-state__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.empty-state__body {
  font-size: 14px;
  margin: 0;
  max-width: 260px;
}

/* ---------- Bottom Navigation (§77, ab Phase 2/3 aktiv) ---------- */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) 0;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.bottom-nav__item[aria-current="page"] {
  color: var(--color-primary);
  font-weight: 700;
}

.bottom-nav__icon {
  font-size: 20px;
}

/* ---------- Misc ---------- */
.preview-banner {
  background: #1b1a19;
  color: #f4f2f0;
  font-size: 9px;
  text-align: center;
  padding: 4px var(--space-3);
  line-height: 1.3;
}

.preview-banner strong {
  color: var(--color-primary);
}

.preview-banner__note {
  display: block;
  color: #a8a5a1;
  font-size: 8px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin: var(--space-5) 0 var(--space-2);
  padding: 0 var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- App-Bar Zurück-Button (Unterseiten) ---------- */
.app-bar__back {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-size: 18px;
  cursor: pointer;
  margin-right: var(--space-1);
}

.app-bar__back:hover {
  background: var(--color-surface-alt);
}

/* ---------- Formulare ---------- */
.form-field {
  margin-bottom: var(--space-4);
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.form-field input[type="text"],
.form-field textarea,
.form-field select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.form-field textarea {
  resize: vertical;
  min-height: 64px;
}

.form-field input[type="text"]:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.form-field__error {
  color: var(--color-danger);
  font-size: 12px;
  margin-top: 4px;
}

.form-slider-row {
  margin-bottom: var(--space-4);
}

.form-slider-row__value {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--color-primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.checkbox-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--color-primary);
}

/* ---------- App-Bar-Aktion (Suche) ---------- */
.app-bar__search {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  padding: var(--space-2);
}

/* ---------- Chip-Zeile (Such-Filter) ---------- */
.chip-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: 0 0 var(--space-3);
  margin: 0 -4px var(--space-2);
}

.chip {
  flex: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-contrast);
}

/* ---------- Berichts-/Backup-Listeneintrag ---------- */
.record-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: none;
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  text-align: left;
  box-shadow: var(--shadow-card);
}

.record-tile__icon {
  font-size: 22px;
}

.record-tile__body {
  flex: 1;
  min-width: 0;
}

.record-tile__title {
  font-weight: 700;
  margin: 0;
}

.record-tile__subtitle {
  color: var(--color-text-secondary);
  font-size: 12px;
  margin: 2px 0 0;
}

.record-tile__actions {
  display: flex;
  gap: var(--space-1);
}

.record-tile__open {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.record-tile__actions button {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  padding: var(--space-2);
}

/* ---------- Berichtsvorschau (druckähnliche Darstellung, §58) ---------- */
.report-preview {
  background: var(--color-surface);
  padding: var(--space-5);
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius-md);
  text-align: left;
}

.report-preview h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.report-preview__meta {
  color: var(--color-text-secondary);
  font-size: 12px;
  margin: 0 0 var(--space-4);
}

.report-preview__section-title {
  font-weight: 700;
  margin: var(--space-4) 0 var(--space-2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
}

.report-preview__row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

/* ---------- Segmented Control (Offen/Alle) ---------- */
.segmented {
  display: inline-flex;
  background: var(--color-surface-alt);
  border-radius: var(--radius-pill);
  padding: 3px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-card);
}

/* ---------- List Tile (Mehr-Menü, Einstellungen, Timeline, Mängel) ---------- */
.list-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.list-tile:disabled {
  cursor: default;
  opacity: 0.55;
}

.list-tile__icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--color-surface-alt);
}

.list-tile__body {
  flex: 1;
  min-width: 0;
}

.list-tile__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-tile__subtitle {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 2px 0 0;
}

.list-tile__trailing {
  flex: none;
}

/* ---------- Slider-Karte (Bereiche in der Übersicht) ---------- */
.area-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-3);
}

.area-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: var(--space-2);
}

.area-card__name {
  font-weight: 700;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Overlay / Sheet / Dialog ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay--center {
  align-items: center;
  padding: var(--space-5);
}

.sheet {
  width: 100%;
  max-height: 82%;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  padding: var(--space-2) 0 var(--space-5);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  margin: var(--space-2) auto var(--space-3);
}

.sheet__title {
  font-size: 15px;
  font-weight: 700;
  padding: 0 var(--space-4);
  margin: 0 0 var(--space-2);
}

.sheet__body {
  padding: 0 var(--space-4);
}

.dialog {
  width: 100%;
  max-width: 320px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.dialog__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 var(--space-2);
}

.dialog__body {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-4);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.dialog__actions .btn {
  padding: 0 var(--space-4);
  min-height: 40px;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

/* ---------- Toast (Speichern-Bestätigung, §127) ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ---------- Utilities ---------- */
/*
  Bewusst `u-hidden` und NICHT `is-hidden`: `.splash.is-hidden` (layout.css)
  blendet den Splash ueber opacity/visibility mit Transition aus. Eine
  globale `.is-hidden { display: none }` wuerde dort mitgreifen und die
  Ausblend-Animation abwuergen.
  Ersetzt direkte element.style.display-Zuweisungen — die CSP der Website
  erlaubt kein 'unsafe-inline' fuer style-src.
*/
.u-hidden { display: none; }

/* Statuszeile der Spracheingabe-Demo (vorher inline gesetzt). */
.voice-status-text {
  color: var(--color-text-secondary);
  font-size: 13px;
}
