/*
 * Terminplaner – App-Shell + Feature-Styles (Mobile-First, N.8).
 * Palette „Modern Court": Slate + Neon-Lime. Tokens: web/design/DESIGN.md.
 */

/* Manrope, selbst gehostet – kein Google-Fonts-CDN (DSGVO). Variable Font 400–800. */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/manrope-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/manrope-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Marke */
  --slate: #1e293b;
  --slate-deep: #0f172a;
  --neon: #ccff00;
  --neon-tint: #f7fdcc;
  --neon-ink: #5c6b00;

  /* Neutralstufen */
  --text: #1f2933;
  --muted: #64748b;
  --muted-soft: #8a979e;
  --disabled: #b3bec3;

  /* Flächen */
  --canvas: #eef2f3;
  --surface: #ffffff;
  --surface-alt: #f4f7f8;

  /* Linien */
  --border: #e3e8ea;
  --border-soft: #ebeff1;

  /* Status */
  --danger: #c0392b;
  --danger-tint: #f0d4d4;
  --free-bg: #f4fadb;
  --free-ink: #5b6b1f;
  --booked-bg: #eef1f5;
  --booked-ink: #64748b;

  /* Radien */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 44px;

  /* Schatten */
  --shadow-card: 0 6px 18px -12px rgba(31, 41, 51, .25);

  --tabbar-height: 4.25rem;
}

* { box-sizing: border-box; }
html { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  container-type: inline-size;
  background: var(--canvas);
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button { font-family: inherit; }

/* App-Rahmen – wie ein Phone-Frame, zentriert auf breiten Screens.
   Feste Höhe: es scrollt nur .view, damit Tab-Bar (mobil) bzw. Nav-Rail (Desktop)
   stehen bleiben, statt mit dem Dokument wegzuscrollen. */
body > main {
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface-alt);
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header"
    "view"
    "tabbar";
}

/* Header */
body > main > header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem;
  color: #ffffff;
  background: var(--slate);
}
body > main > header .logo {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.02em;
}
body > main > header .logo img { display: block; }
body > main > header .datenschutz {
  color: #ffffff;
  opacity: .8;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
}

/* Content-Outlet */
.view {
  grid-area: view;
  overflow-y: auto;
  padding: 1.125rem 1.25rem 1.5rem;
}

/* Bottom-Tab-Bar */
.tabbar {
  grid-area: tabbar;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: var(--tabbar-height);
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.tabbar a .tab-icon { font-size: 1.35rem; line-height: 1; }
.tabbar a.is-active { color: var(--slate); font-weight: 800; }
.tabbar a.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 34px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--neon);
}

/* ---------- Verfügbarkeit (Feature-Modul availability) ---------- */

.page-title {
  margin: 0 0 1rem;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--slate);
}

.section-label {
  margin: 0 0 .625rem;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--slate);
}

.availability {
  display: grid;
  gap: 1rem;
  grid-template-areas:
    "week"
    "form"
    "lead"
    "slots";
}
b-week-strip { grid-area: week; }
b-slot-form  { grid-area: form; }
b-lead-time  { grid-area: lead; }
b-slot-list  { grid-area: slots; }

.surface {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 1.125rem;
}

/* Wochenleiste */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .625rem;
}
.week-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.week-days {
  display: flex;
  gap: .4375rem;
}
.day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .0625rem;
  padding: .5625rem .125rem;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  cursor: pointer;
}
.day-name { font-size: 11px; font-weight: 700; color: var(--muted); }
.day-date { font-size: 13px; font-weight: 800; color: var(--text); }
.day-count {
  margin-top: .25rem;
  font-size: 11px;
  font-weight: 800;
  color: var(--neon-ink);
}
.day.is-today { border-color: var(--muted-soft); }
.day.is-selected {
  border-color: var(--slate);
  background: var(--canvas);
  box-shadow: inset 0 0 0 1px var(--slate);
}

/* Umschalter Einzeltermine | Zeitfenster */
.segmented {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  background: #e9eef0;
}
.segmented button {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--slate);
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(31, 41, 51, .12);
}

/* Formularfelder */
.form-row { display: flex; gap: .75rem; }
.form-field { flex: 1; display: block; }
.form-row + .form-field { margin-top: .75rem; }   /* Abstand nur zwischen Zeilen, nicht innerhalb */
.form-label {
  display: block;
  margin-bottom: .375rem;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.form-field input {
  width: 100%;
  height: 46px;
  padding: 0 .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
}
.form-field input:focus-visible {
  outline: none;
  border-color: var(--slate);
}

.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice {
  flex: 1 1 5rem;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.choice.is-active {
  border-color: var(--slate);
  background: var(--canvas);
  color: var(--slate);
  font-weight: 800;
}

.button-primary {
  width: 100%;
  height: 50px;
  margin-top: 1rem;
  border: none;
  border-radius: 14px;
  background: var(--neon);
  color: var(--slate-deep);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.button-primary:disabled {
  background: var(--border);
  color: var(--disabled);
  cursor: not-allowed;
}

/* Vorschau Modus B */
.preview {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: .875rem 0 0;
  padding: .75rem .875rem;
  border: 1px solid #dfe98f;
  border-radius: var(--r-md);
  background: var(--neon-tint);
  color: var(--neon-ink);
  font-size: 13.5px;
  font-weight: 700;
}
.preview-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: var(--neon);
}
.preview strong { color: #3d4700; }

/* Vorlaufzeit */
.lead-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.125rem;
}
.lead-title { font-size: 15px; font-weight: 800; }
.lead-hint { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: .75rem; }
.stepper-value {
  min-width: 52px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--slate);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.icon-button:disabled { color: var(--disabled); cursor: not-allowed; }

/* Slot-Liste */
.slot-list {
  display: flex;
  flex-direction: column;
  gap: .5625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.slot {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8125rem 1rem;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--neon);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 14px -12px rgba(31, 41, 51, .3);
}
.slot.is-booked { border-left-color: var(--booked-ink); }
.slot-time { font-size: 17px; font-weight: 800; }
.slot-duration { flex: 1; font-size: 12px; font-weight: 700; color: var(--muted-soft); }

.pill {
  padding: .25rem .625rem;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.is-free { background: var(--free-bg); color: var(--free-ink); }
.pill.is-booked { background: var(--booked-bg); color: var(--booked-ink); }
.pill.is-late { background: var(--surface-alt); color: var(--disabled); }

.remove {
  border: none;
  background: none;
  color: #c4ccd0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.remove:hover { color: var(--danger); }

.empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* ---------- Anmeldung (Feature-Modul auth) ---------- */

.login {
  max-width: 26rem;
  margin: 0 auto;
}
.login .surface { margin-top: 1rem; }
.login .form-field + .form-field { margin-top: .75rem; }

body > main > header .header-actions {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
}
.logout {
  border: none;
  background: none;
  color: #ffffff;
  opacity: .8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* Ohne Sitzung gibt es nichts zu navigieren – die Tab-Bar bleibt weg. */
body.is-anonymous .tabbar { display: none; }

/* ---------- Trainees (Feature-Modul trainees) ---------- */

.field-hint {
  margin: .5rem 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.trainee-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.trainee {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.trainee.is-revoked { opacity: .6; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  background: var(--canvas);
  color: var(--slate);
  font-size: 16px;
  font-weight: 800;
}
.trainee-name {
  flex: 1;
  min-width: 6rem;
  font-size: 16px;
  font-weight: 800;
}
.trainee-status {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.trainee.is-revoked .trainee-status { color: var(--danger); }

.button-ghost {
  height: 40px;
  padding: 0 .875rem;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--slate);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.button-ghost.is-small { height: 36px; font-size: 13px; }
.button-ghost.is-danger { color: var(--danger); }
.button-danger {
  width: 100%;
  height: 46px;
  margin-top: .5rem;
  border: none;
  border-radius: 14px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.sheet .button-ghost { width: 100%; height: 46px; margin-top: .5rem; border: none; color: var(--muted); }

/* QR-Fenster */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 35, 38, .45);
}
.sheet {
  width: min(100%, 440px);
  padding: 1.25rem 1.375rem 1.875rem;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
  text-align: center;
}
.sheet-grip {
  width: 40px;
  height: 4px;
  margin: 0 auto 1.125rem;
  border-radius: 2px;
  background: #dfe5e7;
}
.sheet-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.qr {
  display: block;
  width: min(70vw, 240px);
  height: auto;
  margin: 1rem auto;
  border-radius: var(--r-md);
}
.sheet-link {
  margin: 0 0 1rem;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Drucken (F1.4): nur der QR-Code samt Link kommt aufs Papier – kein App-Chrome. */
@media print {
  body { background: #ffffff; }
  body > main { height: auto; overflow: visible; }
  body > main > header, .tabbar { display: none; }
  b-trainees > *:not(b-qr-sheet) { display: none; }   /* Titel, Formular, Liste bleiben am Bildschirm */
  .sheet-backdrop {
    position: static;
    display: block;
    background: none;
  }
  .sheet {
    width: 100%;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .sheet-grip, .sheet button { display: none; }
  .qr { width: 60mm; }
  .sheet-link { border: none; background: none; color: var(--text); }
}

/* ---------- Buchungen des Trainers (Feature-Modul bookings) ---------- */

.booking-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.booking {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--slate);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.booking-who {
  flex: 1;
  min-width: 8rem;
  font-size: 16px;
  font-weight: 800;
}
.booking-when {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}
.booking-actions {
  display: flex;
  gap: .5rem;
}
.move-targets {
  flex-basis: 100%;
  padding-top: .75rem;
  border-top: 1px solid var(--border-soft);
}
.move-targets .field-hint { margin: 0 0 .5rem; }
.move-targets .button-ghost { margin-top: .5rem; }
.move-targets .choice {          /* anklickbares Ziel, kein deaktiviertes Feld */
  flex: 1 1 9rem;
  color: var(--slate);
  font-weight: 800;
}
.move-targets .choice:hover {
  border-color: var(--slate);
  background: var(--canvas);
}

/* ---------- Trainee-Seite (Feature-Modul booking) ---------- */

/* Kein App-Chrome hinter dem privaten Link: der Trainee ist kein Admin. */
body.is-trainee > main {
  max-width: 480px;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas: "view";
  background: var(--surface-alt);
}
body.is-trainee > main > header,
body.is-trainee .tabbar { display: none; }
body.is-trainee .view { padding: 0; }

.trainee-head {
  padding: 1.5rem 1.375rem 1.75rem;
  background: var(--slate);
  color: #ffffff;
}
.trainee-coach {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.trainee-greeting {
  margin: .75rem 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.trainee-sub {
  margin: .25rem 0 0;
  font-size: 14px;
  font-weight: 500;
  opacity: .75;
}

.trainee-body { padding: 1.25rem 1.375rem 1.5rem; }
.trainee-body .section-label { margin-top: 1.5rem; }
.trainee-body .section-label:first-child { margin-top: 0; }

.day-heading {
  margin: 1.25rem 0 .625rem;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.free-slot {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .875rem 1rem;
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--neon);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
}
.free-slot-time { font-size: 19px; font-weight: 800; }
.free-slot-duration { flex: 1; font-size: 12px; font-weight: 700; color: var(--muted-soft); }
.free-slot-chevron { color: var(--muted-soft); font-size: 20px; font-weight: 800; }

.confirmation {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid #dfe98f;
  border-radius: var(--r-lg);
  background: var(--neon-tint);
  color: var(--neon-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}
.confirmation-text { flex: 1; }
.confirmation strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #3d4700;
}
.confirmation-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--neon);
  color: var(--slate-deep);
  font-weight: 800;
}

.sheet-sub {
  margin: .375rem 0 1rem;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
}
.change-request {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  color: #3a4750;
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
}
.sheet-feedback {
  margin: 0 0 .5rem;
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-ink);
}

.trainee-foot {
  padding: 1.5rem 1.375rem 2rem;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.trainee-foot a { color: var(--muted); }

/* Hinweise (Kollision, „n Slots erzeugt") */
.hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 700;
}
.hint.is-info { background: var(--neon-tint); color: var(--neon-ink); }
.hint.is-error { background: var(--danger-tint); color: var(--danger); }

/* Desktop / breite Screens: Nav-Rail links, Inhalt zweispaltig */
@container (min-width: 48em) {
  body > main {
    max-width: 1040px;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "header header"
      "tabbar view";
    box-shadow: 0 0 0 1px var(--border);
  }
  .view { padding: 1.75rem 2.25rem; }
  .tabbar {
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    height: auto;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 1rem .5rem;
    gap: .25rem;
    align-content: start;
  }
  .tabbar a {
    flex-direction: row;
    justify-content: flex-start;
    gap: .7rem;
    padding: .7rem .9rem;
    border-radius: 10px;
    font-size: 14px;
  }
  .tabbar a .tab-icon { font-size: 1.2rem; }
  .tabbar a.is-active { background: var(--surface-alt); }
  .tabbar a.is-active::before {
    top: 50%;
    left: 0;
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
  }

  .availability {
    grid-template-columns: 1fr 22rem;
    grid-template-areas:
      "week  form"
      "slots lead"
      "slots .";
    align-items: start;
    column-gap: 1.5rem;
  }
}
