/* ==========================================================
   Everhorse – Design System (finaler Styleguide)
   Graphite Black · Warm Ivory · Burnt Copper
   Schrift: Manrope (Headlines) + Inter (UI/Text)
   Weiche Radien, sehr dezente Schatten, viel Innenabstand.
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ---- Light Mode (Standard-Oberfläche laut Styleguide) ---- */
  --bg-base:        #F7F5F0;   /* Warm Ivory */
  --bg-raised:      #FFFFFF;
  --bg-card:        #FFFFFF;
  --surface:        #E8E5DE;   /* Soft Stone */
  --field-bg:       #FFFFFF;
  --border-subtle:  #DAD7D0;   /* Card Border */

  --text-primary:   #17191C;   /* Primary Text / Graphite */
  --text-muted:     #656762;   /* Secondary Text */
  --text-faint:     #96958D;   /* Muted Text */
  --placeholder:    #96958D;

  --accent:         #C85C3D;   /* Burnt Copper */
  --accent-light:    #E0714D;  /* Bright Copper (Hover) */
  --accent-dark:     #963F2C;  /* Deep Copper */
  --accent-glow:    rgba(200, 92, 61, 0.14);

  --steel-blue:     #607887;
  --sage:           #718875;
  --warn-amber:     #C8873D;
  --danger:         #B24A38;

  /* Primary (dunkel) für Hauptbuttons/Navigation-Akzente */
  --primary:        #17191C;
  --primary-text:   #F7F5F0;

  --shadow-soft:    0 8px 24px rgba(23, 25, 28, 0.08);
  --shadow-card:    0 4px 16px rgba(23, 25, 28, 0.06);

  --radius-sm:      8px;
  --radius-control: 12px;
  --radius-card:    18px;
  --radius-lg:      24px;
  --radius-sheet:   28px;
  --radius-pill:    999px;

  --tap-target-min: 54px;

  --font-head: 'Manrope', -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Dark Mode ---- */
:root[data-theme="dark"] {
  --bg-base:        #17191C;   /* Graphite Black */
  --bg-raised:      #24272A;
  --bg-card:        #24272A;
  --surface:        #2C3032;
  --field-bg:       #1E2124;
  --border-subtle:  #34383B;

  --text-primary:   #F7F5F0;
  --text-muted:     #A7AAA3;
  --text-faint:     #7C7F79;
  --placeholder:    #7C7F79;

  --accent:         #D96845;   /* etwas heller im Dark Mode */
  --accent-light:    #E0714D;
  --accent-dark:     #963F2C;
  --accent-glow:    rgba(217, 104, 69, 0.18);

  --primary:        #F7F5F0;   /* im Dark Mode: heller Primärbutton */
  --primary-text:   #17191C;

  --shadow-soft:    0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-card:    0 4px 16px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .app-header__mark, .view__title, .dashboard-stat strong, .board-card strong,
.appointment-card strong { font-family: var(--font-head); }

/* ---------- Offline-Banner ---------- */
.offline-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warn-amber);
  color: #24160A;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  text-align: center;
  justify-content: center;
}

.offline-banner .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #24160A; flex: none;
}
.offline-banner[hidden] { display: none; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
}

.app-header__mark {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sync-indicator { font-size: 11px; color: var(--text-faint); }
.sync-indicator[data-state="syncing"] { color: var(--warn-amber); }
.sync-indicator[data-state="synced"]  { color: var(--sage); }
.sync-indicator[data-state="error"]   { color: var(--danger); }

.app-header__right { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
a.theme-toggle { text-decoration: none; }

.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Views ---------- */
.view-root {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 140px;
  position: relative;
}

.view__title {
  font-size: 30px;
  font-weight: 800;
  margin: 22px 0 4px;
  letter-spacing: -0.025em;
}

.view__sub { color: var(--text-muted); font-size: 14px; margin: 0 0 22px; line-height: 1.5; }
.view[hidden] { display: none; }

.profile-section-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  margin: 26px 0 6px;
  letter-spacing: -0.01em;
}

/* ---------- Profilbild ---------- */
.profile-photo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.profile-photo-preview, .profile-photo-placeholder {
  width: 62px; height: 62px; border-radius: 50%; object-fit: cover; flex: none;
  border: 2px solid var(--border-subtle);
}
.profile-photo-placeholder {
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 10px; text-align: center;
}

/* ---------- Formularfelder ---------- */
.field { margin: 16px 0; }
.field label {
  display: block; font-size: 12px; color: var(--text-muted);
  margin-bottom: 7px; font-weight: 600; letter-spacing: 0.01em;
}
.field input, .field select,
.modal-card input, .modal-card select {
  width: 100%;
  min-height: var(--tap-target-min);
  background: var(--field-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-size: 16px;
  padding: 0 16px;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder, .modal-card input::placeholder { color: var(--placeholder); }
.field input:focus, .field select:focus,
.modal-card input:focus, .modal-card select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Buttons ---------- */
.modal-btn {
  flex: 1;
  min-height: var(--tap-target-min);
  border-radius: var(--radius-control);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  border: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.modal-btn--ghost { background: var(--bg-card); color: var(--text-primary); }
.modal-btn--primary {
  background: var(--accent); color: #F7F5F0; border-color: var(--accent);
}
.modal-btn--primary:active { background: var(--accent-dark); }
.modal-btn--dark {
  background: var(--primary); color: var(--primary-text); border-color: var(--primary);
}

.horse-report-btn {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; min-height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Fahrtenbuch / Listen ---------- */
.export-btn { display: inline-block; text-align: center; text-decoration: none; margin-bottom: 18px; }
.fahrtenbuch-list { display: flex; flex-direction: column; gap: 10px; }
.fahrtenbuch-entry {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.fahrtenbuch-entry__route { font-size: 15px; font-weight: 600; }
.fahrtenbuch-entry__meta { color: var(--text-muted); font-size: 13px; margin: 4px 0 10px; }
.fahrtenbuch-entry__km { display: flex; align-items: center; gap: 8px; }
.fahrtenbuch-entry__km input {
  width: 90px; min-height: 40px; background: var(--field-bg);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: 0 10px; font-size: 14px;
}
.fahrtenbuch-entry__km label { font-size: 13px; color: var(--text-muted); }

.horse-photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 22px; }
.horse-photos-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--radius-control); border: 1px solid var(--border-subtle);
}

/* ---------- Dashboard-Widgets ---------- */
.dashboard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.dashboard-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 10px; text-align: center;
  box-shadow: var(--shadow-card);
}
.dashboard-stat strong {
  display: block; font-size: 26px; font-weight: 800; color: var(--accent);
  letter-spacing: -0.02em;
}
.dashboard-stat span { font-size: 11px; color: var(--text-muted); }
.inactive-widget { margin-bottom: 20px; }
.inactive-client-row, .dashboard-request-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 12px 16px; margin-bottom: 8px; font-size: 14px;
}
.inactive-client-row span, .dashboard-request-row span { color: var(--text-muted); font-size: 12px; }

/* ---------- Wochenraster / Tag ---------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 12px; }
.week-nav strong { font-size: 15px; font-family: var(--font-head); }
.week-nav .horse-report-btn { min-width: 42px; padding: 8px 12px; }

.view-mode-toggle {
  display: inline-flex; background: var(--surface);
  border-radius: var(--radius-pill); padding: 4px; margin-bottom: 16px;
}
.view-mode-btn {
  border: none; background: none; color: var(--text-muted);
  font-size: 13px; font-weight: 600; padding: 8px 20px; border-radius: var(--radius-pill);
  font-family: var(--font-body);
}
.view-mode-btn.is-active { background: var(--accent); color: #F7F5F0; }

.week-grid { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; }
.day-card {
  flex: none; width: 170px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 12px;
  box-shadow: var(--shadow-card);
}
.day-card--today { border-color: var(--accent); border-width: 2px; }
.day-card--past { opacity: 0.5; }
.day-card__header { font-size: 13px; font-weight: 700; font-family: var(--font-head); margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.day-card__today-badge { color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.day-card__no-tour {
  font-size: 12px; color: var(--text-muted); text-align: center;
  padding: 10px 0; border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-control); background: none; width: 100%; min-height: 40px;
}

.lane-block {
  margin-bottom: 10px; border-radius: var(--radius-control);
  background: var(--surface); border: 1px solid var(--border-subtle);
  padding: 10px; min-height: 54px;
}
.lane-block--empty { border-style: dashed; background: none; }
.lane-block__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.lane-block__title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.lane-block__region { font-size: 12px; color: var(--text-primary); font-weight: 600; }
.lane-add-stop-btn { background: none; border: none; color: var(--accent); font-size: 11px; font-weight: 600; padding: 0; }
.lane-move-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-muted); font-size: 12px;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.lane-block__body { display: flex; flex-direction: column; gap: 6px; }
.lane-block__gap { text-align: center; color: var(--text-faint); font-size: 12px; padding: 10px 0; margin: 0; }

/* Termin-/Anfrage-Karte (antippbar, KEIN Drag mehr) */
.board-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control); padding: 10px 12px; font-size: 12px;
  cursor: pointer; box-shadow: var(--shadow-card);
}
.board-card strong { display: block; font-size: 13px; margin-bottom: 2px; font-weight: 700; }
.board-card .board-card__meta { color: var(--text-muted); font-size: 11px; }

.known-badge {
  display: inline-block; background: var(--sage); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill);
  vertical-align: middle;
}
.followup-badge {
  display: inline-block; background: var(--accent-glow); color: var(--accent);
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill);
  vertical-align: middle;
}

/* Eingang-Karten */
.inbox-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 16px 18px; box-shadow: var(--shadow-card);
}
.inbox-card__actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Cockpit-Kartenstapel ---------- */
.card-stack { position: relative; min-height: 320px; }
.card-stack__empty { color: var(--text-muted); text-align: center; padding-top: 80px; font-size: 14px; }
.appointment-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card); padding: 22px;
  touch-action: pan-y; position: absolute; top: 0; left: 0; right: 0;
  cursor: grab; user-select: none; box-shadow: var(--shadow-soft);
}
.appointment-card:active { cursor: grabbing; }
.card-top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.appointment-card strong { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.card-tools { display: flex; gap: 6px; flex: none; }
.card-tool-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border-subtle); background: var(--surface);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
}
.card-tool-btn:active { transform: scale(0.94); }
.card-mic-btn.is-recording {
  background: var(--danger); border-color: var(--danger); color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(178, 74, 56, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(178, 74, 56, 0); }
}
.swipe-hint { display: flex; justify-content: space-between; margin-top: 18px; font-size: 12px; font-weight: 600; color: var(--text-muted); opacity: 0; transition: opacity 0.15s ease; }
.appointment-card.is-swiping-left .swipe-hint, .appointment-card.is-swiping-right .swipe-hint { opacity: 1; }
.appointment-card.is-swiping-right { border-color: var(--sage); }
.appointment-card.is-swiping-left  { border-color: var(--danger); }

/* ---------- Quick-Add-Button ---------- */
.quick-add-button {
  position: fixed; left: 20px; bottom: 100px;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--accent); color: #F7F5F0;
  font-size: 28px; font-weight: 300; line-height: 1;
  box-shadow: var(--shadow-soft); z-index: 25;
}

.mic-button {
  position: fixed; right: 20px; bottom: 100px;
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--accent); color: #F7F5F0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft); z-index: 25;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(23, 25, 28, 0.55);
  display: flex; align-items: flex-end; z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 26px 22px calc(24px + env(safe-area-inset-bottom)); width: 100%;
  max-height: 85dvh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.voice-result-body p { margin: 10px 0; font-size: 14px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- Detail-Karte (Termin/Anfrage antippen) ---------- */
.detail-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); font-size: 14px; }
.detail-row:last-of-type { border-bottom: none; }
.detail-row__label { color: var(--text-muted); min-width: 90px; flex: none; font-size: 13px; }
.detail-row__value { color: var(--text-primary); font-weight: 500; }
.detail-photo { width: 100%; border-radius: var(--radius-control); margin-top: 10px; border: 1px solid var(--border-subtle); }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--bg-raised); border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom); z-index: 30;
}
.bottom-nav__item {
  flex: 1; min-height: var(--tap-target-min);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; font-weight: 600; font-family: var(--font-body);
}
.bottom-nav__item svg { width: 21px; height: 21px; stroke: currentColor; }
.bottom-nav__item.is-active { color: var(--accent); }

button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Install-Banner (Homescreen) ---------- */
.install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--primary);
  color: var(--primary-text);
  padding: 12px 16px;
}
.install-banner[hidden] { display: none; }
.install-banner__text { display: flex; flex-direction: column; }
.install-banner__text strong { font-size: 14px; font-weight: 700; }
.install-banner__text span { font-size: 12px; opacity: 0.85; }
.install-banner__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.install-banner__btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-control); font-size: 13px; font-weight: 700;
  padding: 9px 16px; cursor: pointer;
}
.install-banner__close {
  background: none; border: none; color: var(--primary-text);
  font-size: 16px; opacity: 0.7; cursor: pointer; padding: 4px 8px;
}

/* ---------- Embed-Code ---------- */
.embed-code-box {
  width: 100%;
  min-height: 120px;
  background: var(--field-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  resize: vertical;
}

.embed-preview {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
}

/* Der Marken-Kasten, wie er auf der Website des Anwenders erscheint */
.everhorse-embed-box {
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  overflow: hidden;
  max-width: 480px;
  background: var(--bg-card);
}
.everhorse-embed-box__footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border-subtle); background: var(--bg-base);
}
.everhorse-embed-box__footer a { color: var(--accent); text-decoration: none; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Desktop ---------- */
@media (min-width: 640px) {
  .app-header, .view-root { max-width: 620px; margin: 0 auto; width: 100%; }
  .app-header { background: var(--bg-base); }
  .bottom-nav {
    left: 50%; right: auto; transform: translateX(-50%);
    max-width: 620px; width: 100%;
    border-left: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .quick-add-button { left: calc(50% - 310px + 20px); }
  .modal-overlay { align-items: center; justify-content: center; }
  .modal-card { max-width: 480px; border-radius: var(--radius-sheet); max-height: 82dvh; }

  /* Touren-Ansicht darf auf Desktop breiter werden für alle 7 Tage */
  .view-root.is-wide { max-width: 1040px; }
  .view-root.is-wide ~ * { /* Platzhalter */ }
  .week-grid:not(.week-grid--day) {
    display: grid; grid-template-columns: repeat(7, 1fr); overflow-x: visible;
  }
  .week-grid:not(.week-grid--day) .day-card { width: auto; }
}
