/* ═══════════════════════════════════════════════════════════════════════════
   FAHRTENBUCH  ·  style.css
   Aesthetic: Clean Paper — sachlich, hell, dokumentenähnlich
   Fonts: Fraunces (headings) + Instrument Sans (body/inputs)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ───────────────────────────────────────────────────── */
:root {
  --bg:           #f4f2ee;
  --bg-card:      #ffffff;
  --bg-input:     #faf9f7;
  --bg-hover:     #f0ede8;
  --border:       #ddd9d2;
  --border-focus: #2c6fad;

  --text-primary:   #1a1916;
  --text-secondary: #4a4742;
  --text-muted:     #9a958e;

  --accent:       #2c6fad;
  --accent-light: #e8f0f9;
  --accent-alt:   #c0392b;
  --success:      #27ae60;
  --success-light:#e8f5ee;
  --warning:      #e67e22;
  --warning-light:#fdf3e7;

  --radius-sm:  5px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --shadow-card: 0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --shadow-focus: 0 0 0 3px rgba(44,111,173,.18);

  --transition: 150ms cubic-bezier(.4,0,.2,1);
  --font-head:  'Fraunces', serif;
  --font-body:  'Instrument Sans', sans-serif;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Subtiles Linienmuster im Hintergrund */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% 32px;
  opacity: .35;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(244,242,238,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
  color: var(--text-primary);
  user-select: none;
}

.logo-icon {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 7px;
  font-size: .9rem;
  color: #fff;
}

.header-nav {
  display: flex; gap: 3px;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Main Container ──────────────────────────────────────────────────────── */
.main-container {
  position: relative; z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px 80px;
}

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { display: none; animation: fadeUp .24s ease forwards; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form Card ───────────────────────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.form-header {
  padding: 26px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.form-header h1 {
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.2;
  color: var(--text-primary);
}

.form-subtitle {
  margin-top: 3px;
  font-size: .78rem;
  color: var(--text-muted);
}

form { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }

/* ── Field Groups ────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 5px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .field-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

.field-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .055em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.required { color: var(--accent-alt); font-size: .85em; }

.field-hint {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.field-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .92rem;
  padding: 11px 13px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: .5;
  cursor: pointer;
}

.field-input::placeholder { color: var(--text-muted); }

.field-input:focus {
  border-color: var(--border-focus);
  background: #fff;
  box-shadow: var(--shadow-focus);
}

.field-input.error { border-color: var(--accent-alt); }

textarea.field-input { resize: vertical; min-height: 80px; }

/* ── Segmented Control ───────────────────────────────────────────────────── */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segment { position: relative; }

.segment input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}

.segment-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 10px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  border-right: 1px solid var(--border);
}

.segment:last-child .segment-face { border-right: none; }

.seg-icon { width: 18px; height: 18px; flex-shrink: 0; }

.segment input:checked + .segment-face {
  background: var(--accent);
  color: #fff;
}

.segment-face:hover { background: var(--bg-hover); color: var(--text-primary); }
.segment input:checked + .segment-face:hover { background: var(--accent); color: #fff; }

/* ── Auto-only / Fahrrad toggles ─────────────────────────────────────────── */
.auto-only   { transition: opacity .22s, transform .22s; }
.auto-hidden { display: none; }

.auto-only.hidden {
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.bike-notice {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--warning-light);
  border: 1px solid #f0d0a8;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: .82rem;
  color: var(--warning);
}

.bike-notice svg { width: 17px; height: 17px; flex-shrink: 0; }
.bike-notice.show { display: flex; }

/* ── Km-Info ─────────────────────────────────────────────────────────────── */
.km-info {
  background: var(--accent-light);
  border: 1px solid #c2d8ef;
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: .84rem;
  color: var(--text-secondary);
}

.km-info strong { color: var(--accent); font-weight: 600; }
.km-info.hidden { display: none; }

/* ── Submit Button ───────────────────────────────────────────────────────── */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 50px;
}

.btn-submit:hover:not(:disabled) {
  background: #235a8f;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44,111,173,.25);
}

.btn-submit:active:not(:disabled) { transform: translateY(0); }

.btn-submit:disabled { opacity: .5; cursor: not-allowed; }

.btn-spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}

.btn-submit.loading .btn-text    { display: none; }
.btn-submit.loading .btn-spinner { display: block; }

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

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  border-radius: var(--radius-sm);
  padding: 0 13px;
  font-size: .84rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .28s ease, opacity .28s ease, padding .28s ease, margin .28s ease;
}

.toast.show {
  max-height: 80px;
  opacity: 1;
  padding: 11px 13px;
  margin-bottom: 4px;
}

.toast.success {
  background: var(--success-light);
  border: 1px solid #a8d8b8;
  color: var(--success);
}

.toast.error {
  background: #fdf0ef;
  border: 1px solid #f0b8b4;
  color: var(--accent-alt);
}

/* ── List View ───────────────────────────────────────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.list-header h1 {
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text-primary);
}

.btn-refresh {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.btn-refresh svg { width: 16px; height: 16px; }
.btn-refresh:hover { color: var(--accent); border-color: var(--accent); }
.btn-refresh.spin svg { animation: spin .6s linear infinite; }

/* ── Loading / Empty States ──────────────────────────────────────────────── */
.list-loading, .list-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: .88rem;
  text-align: center;
}

.list-empty svg { width: 44px; height: 44px; stroke: var(--border); }

.spinner-large {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.hidden { display: none !important; }

.btn-link {
  background: none; border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: .84rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}

/* ── Fahrten-Liste ───────────────────────────────────────────────────────── */
.fahrten-liste {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}

.fahrt-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  animation: fadeUp .2s ease forwards;
}

.fahrt-item:hover { border-color: #bbb6ae; }

.fahrt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

.fahrt-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.fahrt-badge.auto    { background: var(--accent-light); color: var(--accent); }
.fahrt-badge.fahrrad { background: var(--success-light); color: var(--success); }
.fahrt-badge svg { width: 11px; height: 11px; }

.fahrt-datum {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.fahrt-body {
  padding: 13px 15px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 520px) {
  .fahrt-body { grid-template-columns: 1fr 1fr; }
}

.fahrt-strecke {
  font-family: var(--font-head);
  font-size: .98rem;
  font-weight: 600;
  color: var(--text-primary);
  grid-column: 1 / -1;
}

.fahrt-meta { display: flex; flex-direction: column; gap: 1px; }

.fahrt-meta-label {
  font-size: .67rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
}

.fahrt-meta-value {
  font-size: .84rem;
  color: var(--text-secondary);
}

.fahrt-footer {
  padding: 9px 15px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
}

.fahrt-id {
  font-size: .7rem;
  color: var(--text-muted);
}

.btn-delete {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .74rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-delete svg { width: 12px; height: 12px; }

.btn-delete:hover {
  color: var(--accent-alt);
  border-color: #f0b8b4;
  background: #fdf0ef;
}

/* ── Confirm Dialog ──────────────────────────────────────────────────────── */
dialog.confirm-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 24px;
  max-width: 320px;
  width: 90vw;
  font-family: var(--font-body);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

dialog.confirm-dialog::backdrop {
  background: rgba(26,25,22,.45);
  backdrop-filter: blur(3px);
}

dialog.confirm-dialog p {
  margin-bottom: 18px;
  font-size: .92rem;
  color: var(--text-secondary);
}

.dialog-actions {
  display: flex; gap: 8px; justify-content: flex-end;
}

.btn-dialog {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-body);
  font-size: .84rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel {
  background: var(--bg-input);
  color: var(--text-secondary);
}
.btn-cancel:hover { border-color: #bbb; color: var(--text-primary); }

.btn-danger {
  background: #fdf0ef;
  color: var(--accent-alt);
  border-color: #f0b8b4;
}
.btn-danger:hover { background: var(--accent-alt); color: #fff; border-color: var(--accent-alt); }

/* ── Scrollbar (Webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb6ae; }

/* ── Desktop refinements ─────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .main-container { padding: 32px 24px 80px; }
  .form-header { padding: 28px 32px 20px; }
  form { padding: 24px 32px 28px; gap: 22px; }
}

