/* ===========================================================================
   nxt-Level-Dienstplan · Web-Tool · Stylesheet
   ========================================================================= */

:root {
  --bg:       #f4f5fb;
  --surface:  #ffffff;
  --surface-2:#f7f7fc;
  --line:     #e6e7ef;
  --line-2:   #d8d9e3;
  --text:     #1c1c1f;
  --text-2:   #4a4a55;
  --text-3:   #7a7a86;
  --accent:   #4f53ec;
  --accent-2: #6063f3;
  --accent-soft: rgba(79, 83, 236, .10);

  /* Art-Farben — angepasst an die iOS/Android-App */
  --art-zusatz:      #2563eb;  /* blau */
  --art-ausfall:     #dc2626;  /* rot */
  --art-haltausfall: #dc2626;
  --art-umleitung:   #ea580c;  /* orange */
  --art-sev:         #9333ea;  /* purple */
  --art-vorplan:     #0891b2;  /* cyan */
  --art-spaeter:     #ca8a04;  /* yellow-700 */
  --art-parameter:   #4f46e5;  /* indigo */
  --art-sonstiges:   #6b7280;  /* gray */

  --shadow-1: 0 1px 2px rgba(15, 17, 41, .04), 0 1px 3px rgba(15, 17, 41, .06);
  --shadow-2: 0 4px 14px rgba(15, 17, 41, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181a23;
    --surface-2: #1f2230;
    --line: #2a2d3b;
    --line-2: #3a3d4d;
    --text: #f1f1f7;
    --text-2: #c2c4d0;
    --text-3: #888a98;
    --accent-soft: rgba(99, 103, 243, .18);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 6px 20px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Sticky-Footer-Pattern: Body als flex-column, .main füllt mit `flex:1`,
     .ft bleibt am Boden. `100dvh` respektiert die dynamische Browser-UI auf
     Mobil — wichtig, damit der Footer nicht hinter der Adressleiste landet. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----- Header ------------------------------------------------------------ */
.hd {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.hd-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: url('/web/assets/app-icon.png') center/cover no-repeat;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-weight: 700; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .8px; text-transform: uppercase; }

.nav { display: flex; gap: 4px; margin-left: auto; }
.nav-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 9px;
  color: var(--text-2); font-weight: 600; font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.is-active {
  background: var(--accent-soft); color: var(--accent);
}
@media (max-width: 480px) {
  .nav-item span { display: none; }
}

/* ----- Main / Footer ----------------------------------------------------- */
.main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1100px; margin: 0 auto;
  padding: 28px 20px 40px;
}
.ft {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.ft-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 16px 20px; font-size: 13px; color: var(--text-3);
}
.ft-sep { opacity: .6; }
.ft a { color: var(--text-3); }

/* ----- Karten / Hero ----------------------------------------------------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 22px; padding: 28px 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7a3fe7 60%, #b14fee);
  box-shadow: 0 12px 30px rgba(79, 83, 236, .25);
}
.hero::after {
  content: ''; position: absolute; inset: -40% -10% auto auto;
  width: 60%; height: 200%;
  background: radial-gradient(closest-side, rgba(255,255,255,.18), transparent);
}
.hero h1 { margin: 6px 0 4px; font-size: clamp(22px, 4vw, 30px); font-weight: 800; }
.hero p { margin: 0; opacity: .92; font-size: 15px; max-width: 60ch; }
.hero-eyebrow { font-size: 11px; letter-spacing: 1.6px; font-weight: 800; opacity: .85; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px 20px; }
.card h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }

.grid {
  display: grid; gap: 18px;
}
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.tile {
  display: block; padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-1);
  color: inherit; transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); text-decoration: none; }
.tile-icon {
  width: 44px; height: 44px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 12px;
}
.tile h3 { margin: 0 0 4px; font-size: 17px; }
.tile p  { margin: 0; color: var(--text-2); font-size: 14px; }

/* ----- Formulare --------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; margin-bottom: 6px;
  font-weight: 600; font-size: 13px; color: var(--text-2);
}
.input, .input-file {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit;
}
.input:focus, .input-file:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
  border-color: transparent;
}
.input-file::-webkit-file-upload-button {
  margin-right: 12px; padding: 7px 12px;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface-2); cursor: pointer; font: inherit;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1; min-width: 150px; margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: 10px;
  font: 600 14px/1 inherit;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(79, 83, 236, .35);
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost {
  background: var(--surface-2); color: var(--text-2); box-shadow: none;
  border: 1px solid var(--line);
}

/* ----- Banner ------------------------------------------------------------ */
.banner {
  margin: 14px 0; padding: 12px 14px;
  border-radius: 12px; font-size: 14px;
  border: 1px solid transparent;
}
.banner-err { background: #fde9ec; color: #a30419; border-color: #f6c1c8; }
.banner-info { background: #e7eaff; color: #2233a6; border-color: #c4caf8; }
.banner-ok  { background: #e3f7e6; color: #11623a; border-color: #b9e6c2; }
@media (prefers-color-scheme: dark) {
  .banner-err { background: rgba(220, 38, 38, .15); color: #ff8a98; }
  .banner-info { background: rgba(99, 103, 243, .15); color: #aab1ff; }
  .banner-ok  { background: rgba(34, 197, 94, .15); color: #8ee9b1; }
}

/* ----- Pills / Chips ----------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font: 700 11px/1.4 -apple-system, monospace;
  letter-spacing: .3px;
  white-space: nowrap;
}
.pill-solid { color: #fff; background: var(--art); }
.pill-soft  { color: var(--art); background: color-mix(in srgb, var(--art) 14%, transparent); }
.pill-ghost {
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--line);
}

.pill-aktuell {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--art); color: #fff;
  font: 700 11px/1.4 inherit; letter-spacing: .4px;
}
.pill-aktuell::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #fff;
}

/* Art-Variablen pro Klasse — werden überall via var(--art) angezogen */
.art-zusatz      { --art: var(--art-zusatz); }
.art-ausfall     { --art: var(--art-ausfall); }
.art-haltausfall { --art: var(--art-haltausfall); }
.art-umleitung   { --art: var(--art-umleitung); }
.art-sev         { --art: var(--art-sev); }
.art-vorplan     { --art: var(--art-vorplan); }
.art-spaeter     { --art: var(--art-spaeter); }
.art-parameter   { --art: var(--art-parameter); }
.art-sonstiges   { --art: var(--art-sonstiges); }

/* ----- Treffer-Karte ----------------------------------------------------- */
.tk {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--art, var(--line-2));
  border-radius: 14px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
a.tk:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); text-decoration: none; }
.tk-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.tk-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--art) 18%, transparent);
  color: var(--art); font-weight: 800;
}
.tk-titel { flex: 1; min-width: 0; }
.tk-titel-zeile {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text);
}
.tk-meta-zeile {
  display: flex; align-items: center; gap: 8px;
  margin-top: 3px; font-size: 12.5px; color: var(--text-3);
  flex-wrap: wrap;
}
.tk-chev { color: var(--text-3); flex-shrink: 0; }

.tk-fuss {
  padding: 10px 16px; border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}

/* ----- FPLO-Detail ------------------------------------------------------- */
.detail-hero {
  border-radius: 18px; padding: 22px 22px 24px;
  background: linear-gradient(135deg, var(--art), color-mix(in srgb, var(--art) 60%, #000));
  color: #fff;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--art) 35%, transparent);
}
.detail-hero h1 { margin: 6px 0 4px; font-size: 24px; font-weight: 800; }
.detail-hero .chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.detail-hero .chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: 12px; font-weight: 700;
}

.regelung {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.regelung:last-child { border-bottom: 0; }
.regelung-kopf {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.regelung-strecke { font-weight: 700; }
.regelung-laufweg {
  margin: 8px 0 0; padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font: 12.5px/1.55 ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  white-space: pre;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  color: var(--text);
}

/* ----- Dienst-Anzeige ---------------------------------------------------- */
.dienst-kopf {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px;
}
.dienst-num {
  font-size: 22px; font-weight: 800; letter-spacing: .5px;
  font-feature-settings: "tnum";
}
.dienst-tag { color: var(--text-2); font-size: 14px; }
.dienst-stat { margin-left: auto; color: var(--text-3); font-size: 13px; }

.fahrt {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 16px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}
.fahrt:first-child { border-top: 0; }
.fahrt-zug {
  font-weight: 800; font-size: 16px;
  font-feature-settings: "tnum";
}
.fahrt-linie {
  display: inline-block; margin-top: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 11px; letter-spacing: .4px;
}
.fahrt-fplos { display: flex; flex-direction: column; gap: 8px; }
.fahrt-fplos .tk { box-shadow: none; }

.empty {
  padding: 28px; text-align: center;
  color: var(--text-3); border: 1.5px dashed var(--line);
  border-radius: 14px; background: var(--surface);
}
.empty strong { color: var(--text); }

/* ----- Ladezustand ------------------------------------------------------- */
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }
