/*
 * Verbindliches Design-System (Dark-Theme, bewusst als einziges Theme committet -
 * die App wird unterwegs/abends benutzt). Farben, Type-Scale und Spacing-Scale sind
 * fixe Tokens - jede Verwendung im Stylesheet muss einen dieser Werte referenzieren,
 * keine Ad-hoc-Zwischenwerte.
 */
:root {
  color-scheme: dark;

  /* Elevation-Ebene 1: Seitenhintergrund */
  --bg: #0f1115;
  /* Elevation-Ebene 2: Karten/Flaechen */
  --surface: #181b21;
  --surface-hover: #20242c;
  --surface-active: #262b34;
  --border: #2a2e36;

  --text: #f4f5f7;
  --text-muted: #9aa1ac;

  /* Akzent 1: Hero-Sign / Primaeraktionen (Blauverlauf) */
  --accent1-start: #12467a;
  --accent1-end: #0b3155;

  /* Akzent 2: Navigation/Call-to-Action (Amber, dunkler Text fuer Kontrast) */
  --accent2: #f0b429;
  --accent2-hover: #ffc94d;
  --accent2-active: #d99b00;
  --accent2-text: #1a1300;

  --success: #3e8e5b;
  --success-hover: #4aa46b;
  --success-active: #347a4d;
  --success-bg: rgba(62, 142, 91, 0.16);
  --success-text: #0f1115;
  /* Aufgehellter Success-Ton fuer Text auf dunklem Grund (reines --success auf Schwarz
     erreicht als Fliesstext keinen ausreichenden WCAG-AA-Kontrast). */
  --success-on-dark: #5ebd82;

  --error: #c1503a;
  --error-hover: #d0644e;
  --error-active: #a8402c;
  --error-bg: rgba(193, 80, 58, 0.16);
  --error-text: #ffffff;
  /* Aufgehellter Error-Ton fuer Text auf dunklem Grund, siehe --success-on-dark. */
  --error-on-dark: #e07862;

  --focus-ring: #5b9dff;

  /* Type-Scale: 12/13/14/16/19/22/30px - keine anderen Groessen verwenden */
  --fs-1: 12px;
  --fs-2: 13px;
  --fs-3: 14px;
  --fs-4: 16px;
  --fs-5: 19px;
  --fs-6: 22px;
  --fs-7: 30px;

  /* Spacing-Scale: 4/8/12/16/24/32/48px - jeder Abstand in der App muss hierauf abbilden */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Elevation-Ebene 2 (Karten): dezenter Schatten */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.3);
  /* Elevation-Ebene 3 (Hero-Sign): deutlich staerkerer Schatten */
  --shadow-hero: 0 12px 28px rgba(5, 20, 38, 0.55), 0 4px 12px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  * {
    transition-duration: 120ms;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs-4);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: var(--space-5) var(--space-4) var(--space-7);
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.topbar h1 {
  font-size: var(--fs-5);
  margin: 0;
  letter-spacing: 0.02em;
}

.icon-btn {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: var(--space-7);
  height: var(--space-7);
  font-size: var(--fs-5);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.icon-btn:active {
  background: var(--surface-active);
}

h2 {
  font-size: var(--fs-6);
  margin: 0 0 var(--space-3);
}

h3 {
  font-size: var(--fs-3);
  margin: 0 0 var(--space-2);
}

p.hint {
  color: var(--text-muted);
  font-size: var(--fs-3);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
  margin-top: var(--space-4);
}

input[type='text'],
input[type='password'],
input[type='search'] {
  width: 100%;
  padding: var(--space-4) var(--space-3);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  min-height: var(--space-7);
}

input[type='text']:hover,
input[type='password']:hover,
input[type='search']:hover {
  border-color: var(--text-muted);
}

select {
  width: 100%;
  padding: var(--space-3);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  min-height: var(--space-7);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  min-height: var(--space-7);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  font-weight: 700;
  font-size: var(--fs-4);
  cursor: pointer;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-compact {
  width: auto;
  min-height: auto;
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-3);
}

.btn-primary {
  background: var(--accent2);
  color: var(--accent2-text);
}

.btn-primary:hover {
  background: var(--accent2-hover);
}

.btn-primary:active {
  background: var(--accent2-active);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}

.btn-secondary:active {
  background: var(--surface-active);
}

.btn-success {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success-on-dark);
}

.btn-success:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
  color: var(--success-text);
}

.btn-success:active {
  background: var(--success-active);
  border-color: var(--success-active);
  color: var(--success-text);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--error);
  color: var(--error-on-dark);
}

.btn-danger:hover {
  background: var(--error-hover);
  border-color: var(--error-hover);
  color: var(--error-text);
}

.btn-danger:active {
  background: var(--error-active);
  border-color: var(--error-active);
  color: var(--error-text);
}

.btn-block-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-card);
}

.dropzone {
  border: 3px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: var(--space-4);
}

.dropzone:hover {
  border-color: var(--focus-ring);
  background: var(--surface-hover);
}

.dropzone.dragover {
  border-color: var(--focus-ring);
  background: var(--surface-hover);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.checkbox-row input {
  width: var(--space-5);
  height: var(--space-5);
}

.progress-track {
  height: var(--space-4);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  margin: var(--space-4) 0;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent1-start), var(--accent1-end));
}

.failure-list {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0;
}

.failure-list li {
  padding: var(--space-2) var(--space-3);
  border-left: 4px solid var(--error);
  background: var(--surface);
  margin-bottom: var(--space-2);
  font-size: var(--fs-3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Nächster Stopp: Autobahn-Hinweisschild - Elevation-Ebene 3 (staerkster Schatten,
   Blauverlauf statt Flaechenfarbe, deutlich von Karten (Ebene 2) unterscheidbar) */
.next-stop-sign {
  background: linear-gradient(160deg, var(--accent1-start), var(--accent1-end));
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-hero);
}

.next-stop-sign .label {
  font-size: var(--fs-2);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(244, 245, 247, 0.7);
  margin-bottom: var(--space-2);
}

.next-stop-sign .stop-name {
  font-size: var(--fs-6);
  font-weight: 800;
  margin: 0 0 var(--space-1);
}

.next-stop-sign .stop-address {
  font-size: var(--fs-4);
  opacity: 0.85;
  margin: 0 0 var(--space-4);
}

.next-stop-sign .metrics {
  display: flex;
  gap: var(--space-5);
}

.next-stop-sign .metric-value {
  font-size: var(--fs-7);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.next-stop-sign .metric-unit {
  font-size: var(--fs-2);
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.next-stop-sign .actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.upcoming-list h3 {
  font-size: var(--fs-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: var(--space-5) 0 var(--space-2);
}

.upcoming-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.upcoming-item:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-card-hover);
}

.upcoming-item:active {
  background: var(--surface-active);
  transform: translateY(1px);
}

.upcoming-item .name {
  font-weight: 600;
}

.upcoming-item .address {
  font-size: var(--fs-2);
  color: var(--text-muted);
}

.upcoming-item .duration {
  font-weight: 700;
  white-space: nowrap;
}

.map-section {
  margin-top: var(--space-5);
}

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

.map-heading-row h3 {
  margin: 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--focus-ring);
  font-weight: 600;
  font-size: var(--fs-2);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.link-btn:hover {
  background: var(--surface-hover);
}

.link-btn:active {
  background: var(--surface-active);
}

.link-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.map-container {
  height: 280px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-pin span {
  display: block;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.map-pin-location span {
  width: 14px;
  height: 14px;
  background: var(--focus-ring);
}

.map-pin-stop span {
  width: 12px;
  height: 12px;
  background: var(--accent1-start);
}

.map-pin-next span {
  width: 22px;
  height: 22px;
  background: var(--accent2);
  border-color: var(--accent1-end);
}

.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.error-banner {
  background: var(--error-bg);
  border: 2px solid var(--error);
  color: var(--text);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  padding: var(--space-2) 0;
}

.spinner {
  width: var(--space-5);
  height: var(--space-5);
  flex-shrink: 0;
  border: 3px solid var(--border);
  border-top-color: var(--focus-ring);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    opacity: 0.6;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-sheet {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-4) var(--space-6);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
  border-top: 1px solid var(--border);
}

.modal-sheet h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  gap: var(--space-2);
}

.list-row .list-meta {
  font-size: var(--fs-2);
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  font-size: var(--fs-1);
  font-weight: 700;
  background: var(--surface-hover);
  color: var(--text);
}

.badge-active {
  background: var(--success);
  color: var(--success-text);
}

/* Adressliste-Übersicht */
.stop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-2);
}

.stop-row:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-card-hover);
}

.stop-row-done {
  opacity: 0.6;
}

.stop-row-name {
  font-weight: 600;
}

.stop-row-address {
  font-size: var(--fs-2);
  color: var(--text-muted);
}

.stop-row-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.status-open {
  background: var(--surface-hover);
  color: var(--text);
}

.status-done {
  background: var(--success-bg);
  color: var(--success-on-dark);
}

.status-not-found {
  background: var(--error-bg);
  color: var(--error-on-dark);
}
