/* Assistenzstunden – Buchungs-Oberfläche
   Ein schlichtes, funktionales Layout. Hell/Dunkel je nach Gerät. */

:root {
  color-scheme: light dark;
  --paper:       #f8f7f3;
  --surface:     #ffffff;
  --surface-2:   #f0efe9;
  --ink:         #1b1e1c;
  --ink-soft:    #4c534e;
  --ink-faint:   #79817b;
  --line:        #dedbd0;
  --accent:      #2f6f5e;
  --accent-ink:  #1d4a3d;
  --on-accent:   #f6faf8;
  --frei:        #2f7d52;
  --frei-bg:     #e4f0e7;
  --belegt:      #8a6a2c;
  --belegt-bg:   #eee7d6;
  --fehler:      #a83e28;
  --fehler-bg:   #f5e2dc;
  --radius:      10px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #141716;
    --surface:   #1c211f;
    --surface-2: #232927;
    --ink:       #e9eae6;
    --ink-soft:  #b4bbb5;
    --ink-faint: #838b85;
    --line:      #333b37;
    --accent:    #5aa68e;
    --accent-ink:#8fc7b6;
    --on-accent: #0e1512;
    --frei:      #74bd90;
    --frei-bg:   #1c2b22;
    --belegt:    #c39a54;
    --belegt-bg: #2a2619;
    --fehler:    #d9765d;
    --fehler-bg: #301c17;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
}

.wrap {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- Kopf --- */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.schule { color: var(--ink-faint); font-size: 0.9rem; }

main.wrap { padding-top: 1.5rem; padding-bottom: 2.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.12rem; margin: 0; }

.intro { color: var(--ink-soft); margin: 0 0 1.6rem; }
.leer-hinweis { color: var(--ink-faint); }

.chip {
  display: inline-block;
  padding: 0.05em 0.45em;
  border-radius: 6px;
  font-size: 0.85em;
  font-weight: 600;
}
.chip.frei   { color: var(--frei);   background: var(--frei-bg); }
.chip.belegt { color: var(--belegt); background: var(--belegt-bg); }

/* --- Assistenten-Block --- */
.assi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1.1rem;
}
.assi-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.assi-info { margin: 0.15rem 0 0; color: var(--ink-faint); font-size: 0.9rem; }
.assi-frei {
  margin: 0;
  flex: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--frei);
  white-space: nowrap;
}
.assi-frei[data-null="True"] { color: var(--ink-faint); }

/* --- Wochengitter --- */
.gitter-scroll { overflow-x: auto; }
.gitter {
  border-collapse: separate;
  border-spacing: 4px;
  width: 100%;
  min-width: 340px;
}
.gitter th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 0.2rem;
  text-align: center;
}
.gitter th.stunde { text-align: right; padding-right: 0.5rem; white-space: nowrap; }
.gitter td {
  text-align: center;
  border-radius: 7px;
  font-size: 0.82rem;
  height: 2.2rem;
  padding: 0;
}
.gitter .z-leer   { background: transparent; }
.gitter .z-belegt { background: var(--belegt-bg); color: var(--belegt); }
.gitter .z-frei   { background: var(--frei-bg); padding: 0; }
.gitter .z-frei a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--frei);
  font-weight: 700;
  text-decoration: none;
  border-radius: 7px;
}
.gitter .z-frei a:hover,
.gitter .z-frei a:focus-visible {
  background: var(--frei);
  color: var(--on-accent);
  outline: none;
}

/* --- Formular / Slotkarte --- */
.zurueck { margin: 0 0 0.8rem; }
.zurueck a, .ergebnis a { color: var(--accent-ink); }

.slotkarte {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0 0 1.3rem;
}
.slotkarte strong { font-size: 1.05rem; }
.slotkarte span { color: var(--ink-soft); font-size: 0.92rem; }

.buchform { display: flex; flex-direction: column; gap: 1rem; }
.buchform label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.buchform input {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.buchform input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.hinweis { color: var(--ink-faint); font-size: 0.86rem; margin: 0; }

button[type="submit"] {
  align-self: flex-start;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1.4rem;
  cursor: pointer;
}
button[type="submit"]:hover { background: var(--accent-ink); }
button[type="submit"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Meldungen / Ergebnis --- */
.fehler {
  color: var(--fehler);
  background: var(--fehler-bg);
  border-radius: 8px;
  padding: 0.7rem 1rem 0.7rem 1.4rem;
  margin: 0 0 1.2rem;
}
ul.fehler { padding-left: 1.6rem; }

.ergebnis h1 { margin-bottom: 0.8rem; }
.ergebnis.ok h1 { color: var(--frei); }
.ergebnis.fehlgeschlagen h1 { color: var(--fehler); }

.fuss {
  color: var(--ink-faint);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  padding-bottom: 2rem;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ================= Admin ================= */
.adminnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.adminnav .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}
.adminnav-titel { font-weight: 700; color: var(--ink-faint); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.08em; }
.adminnav a { color: var(--ink-soft); text-decoration: none; padding: 0.25rem 0; }
.adminnav a:hover { color: var(--accent-ink); }
.adminnav a[aria-current="page"] { color: var(--accent-ink); font-weight: 700; border-bottom: 2px solid var(--accent); }

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.7rem;
  margin: 1rem 0 1.6rem;
}
.kachel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.kachel .zahl { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.kachel.alarm { border-color: color-mix(in srgb, var(--fehler) 55%, var(--line)); background: var(--fehler-bg); }
.kachel.alarm .zahl, .kachel.alarm { color: var(--fehler); }

.ok-hinweis { color: var(--frei); }
.mehr { font-size: 0.9rem; }
.mehr a, .link-zelle a { color: var(--accent-ink); }

.konfliktbox {
  border: 1px solid color-mix(in srgb, var(--fehler) 45%, var(--line));
  background: var(--fehler-bg);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.6rem;
}
.konfliktbox h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }

.adminliste { list-style: none; padding: 0; margin: 0.8rem 0 0; display: flex; flex-direction: column; gap: 0.6rem; }
.adminliste li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
}
.adminliste .l { display: flex; flex-direction: column; gap: 0.15rem; }
.adminliste small { color: var(--ink-faint); font-size: 0.82rem; }
.adminliste small.notiz { color: var(--ink-soft); font-style: italic; }

.aktionen { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.aktionen form { margin: 0; }
button.klein {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  color: var(--accent-ink);
  background: var(--accent-wash);
  cursor: pointer;
}
button.klein:hover { background: var(--accent); color: var(--on-accent); }
button.klein.gefahr { border-color: color-mix(in srgb, var(--fehler) 60%, transparent); color: var(--fehler); background: var(--fehler-bg); }
button.klein.gefahr:hover { background: var(--fehler); color: #fff; }
button.klein:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabelle-scroll { overflow-x: auto; margin: 1rem 0; }
.admintabelle { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.admintabelle th, .admintabelle td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admintabelle thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); background: var(--surface-2); }
.admintabelle tr.zeile-konflikt td { background: var(--fehler-bg); }
.admintabelle tr.inaktiv-zeile td { color: var(--ink-faint); }
.admintabelle tr.notiz-zeile td { font-style: italic; color: var(--ink-soft); font-size: 0.82rem; padding-top: 0.1rem; border-bottom: 1px solid var(--line); }
.admintabelle .kuerzel { color: var(--ink-faint); font-size: 0.8rem; }
.admintabelle .faecher-zelle { max-width: 16rem; }
.admintabelle .link-zelle a { font-family: var(--f-mono, monospace); font-size: 0.78rem; word-break: break-all; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.pill.belegt   { color: var(--belegt);   background: var(--belegt-bg);   border-color: color-mix(in srgb, var(--belegt) 40%, transparent); }
.pill.konflikt { color: var(--fehler);   background: var(--fehler-bg);   border-color: color-mix(in srgb, var(--fehler) 40%, transparent); }

details.neu-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 1.4rem;
  background: var(--surface);
}
details.neu-form > summary { cursor: pointer; padding: 0.5rem 0; font-weight: 600; font-size: 0.9rem; color: var(--accent-ink); }
details.neu-form .buchform { margin: 0.6rem 0 0.4rem; }
details.neu-form .buchform label { flex-direction: row; align-items: center; gap: 0.5rem; }
details.neu-form .buchform input { max-width: 16rem; }

/* --- Gezielte Suche --- */
.suche-link { margin: -0.6rem 0 1.6rem; }
.suche-link a { color: var(--accent-ink); font-weight: 600; font-size: 0.95rem; }

.sucheform {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.6rem;
}
.sucheform label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.sucheform select {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.sucheform select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sucheform button { align-self: flex-end; }

.treffer h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }
.trefferliste { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.trefferliste li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}
.trefferliste .l { display: flex; flex-direction: column; gap: 0.1rem; }
.trefferliste .l small { color: var(--ink-faint); font-size: 0.82rem; }
.trefferliste .btn {
  flex: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 8px;
  padding: 0.4rem 1rem;
  text-decoration: none;
}
.trefferliste .btn:hover { background: var(--accent-ink); }
.trefferliste .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Flash-Meldungen --- */
.flash {
  border-radius: 8px;
  padding: 0.7rem 1rem;
  margin: 0 0 1.3rem;
  font-size: 0.95rem;
  border: 1px solid;
}
.flash-erfolg  { color: var(--frei);   background: var(--frei-bg);   border-color: color-mix(in srgb, var(--frei) 40%, transparent); }
.flash-warnung { color: var(--belegt); background: var(--belegt-bg); border-color: color-mix(in srgb, var(--belegt) 45%, transparent); }

/* --- Pflege-Formular --- */
.pflegeform { display: flex; flex-direction: column; gap: 1.4rem; }
.pflegeform fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  margin: 0;
  background: var(--surface);
}
.pflegeform legend {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding: 0 0.4rem;
}
.pflegeform .feld {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 0.6rem;
}
.pflegeform .feld:first-of-type { margin-top: 0; }
.pflegeform select,
.pflegeform input[type="text"] {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  max-width: 22rem;
}
.pflegeform .check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin: 0.35rem 0;
}
.pflegeform input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex: none; }
.pflegeform select:focus-visible,
.pflegeform input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Klassenstufen- und Fächer-Raster aus Häkchen */
.ks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.35rem 0.8rem;
  margin: 0.5rem 0;
}
.ks-grid .check { margin: 0; }
.ks-check { justify-content: flex-start; }
.pflegeform fieldset > .ks-grid { grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr)); }

details.fkanon {
  margin-top: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.2rem 0.8rem;
  background: var(--paper);
}
details.fkanon > summary {
  cursor: pointer;
  padding: 0.55rem 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-ink);
}
details.fkanon[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 0.5rem; }
.fach-gruppe { margin: 0.7rem 0; }
.fach-gruppe[hidden] { display: none; }
.gruppe-titel {
  margin: 0 0 0.2rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
}
.fkanon-hint[hidden] { display: none; }

.raster-scroll { overflow-x: auto; margin-top: 0.4rem; }
.raster { border-collapse: separate; border-spacing: 3px; min-width: 320px; }
.raster th {
  font-size: 0.8rem; font-weight: 600; color: var(--ink-faint);
  padding: 0.15rem 0.3rem; text-align: center;
}
.raster th.stunde { text-align: right; }
.raster td {
  position: relative;
  text-align: center;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-2);
}
.raster td.gebucht { background: var(--belegt-bg); }
.raster .marker { color: var(--belegt); font-size: 0.7rem; position: absolute; top: 1px; right: 3px; }
.raster .marker.warn { color: var(--fehler); }
.hinweis .marker { color: var(--belegt); position: static; font-size: 0.8rem; }
.hinweis .marker.warn { color: var(--fehler); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .assi-kopf { flex-direction: column; gap: 0.3rem; }
}
