/* ============================================================
   Dawtastic — admin.css (admin panel only)
   ============================================================ */

body.admin {
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.admin-title {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}

/* Breite: Die Projekttabelle braucht mit allen Aktionen ~1650 px — auf
   großen Bildschirmen soll sie ohne Inline-Scrolling passen, deshalb kaum
   Seitenrand. Auf schmalen Geräten scrollt .admin-table-wrap weiterhin. */
.admin-main {
  max-width: 1760px;
  margin: 0 auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

/* login */
.admin-login {
  max-width: 420px;
  margin: 8vh auto 0;
}

/* toolbar */
.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-toolbar input {
  flex: 1;
  min-width: 220px;
}
.admin-count {
  color: var(--muted);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* table */
.admin-table-wrap {
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  font-size: 0.95rem;
}
.admin-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }

/* Namenszellen (Projekte, Klassen-Beschriftung, Packs, Videos): lange Namen
   werden mit … abgeschnitten, der volle Name steht im title. */
.admin-name {
  font-weight: 600;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Projektname + Stift nebeneinander; nur der Text wird abgeschnitten, der
   Stift bleibt immer sichtbar (260 + Stift < 320). */
.admin-name__text {
  display: inline-block;
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-rename {
  vertical-align: middle;
  margin-left: 6px;
  padding: 4px 6px;
  color: var(--muted);
}
.admin-rename svg { width: 14px; height: 14px; }
.admin-rename:hover, .admin-rename:focus-visible { color: var(--text); }
/* Die Pack-/Video-Tabellen standen ohne Scroll-Container in der Karte und
   ragten deshalb über deren Rand hinaus. Der Container ist jetzt da; die
   Karte selbst darf nichts überstehen lassen. */
.admin-packs .admin-table-wrap { max-width: 100%; }
.admin-packs { overflow: hidden; }
.admin-token-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
}
.admin-token-link:hover { text-decoration: underline; }
.admin-date { color: var(--muted); white-space: nowrap; font-size: 0.85rem; font-family: var(--font-mono); }
.admin-audio { white-space: nowrap; }
.admin-audio small { color: var(--muted); }

/* status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.badge--ok { color: var(--ok); }
.badge--blocked { color: var(--danger); border-color: var(--danger); }

/* row actions */
.admin-actions {
  display: flex;
  gap: 6px;
  /* NICHT umbrechen: in einer Tabelle bestimmt der Inhalt die Spaltenbreite —
     mit wrap darf die Spalte schrumpfen und die Knöpfe stapeln sich
     untereinander (Zeilen werden riesig). Passt die Zeile nicht, scrollt
     .admin-table-wrap waagerecht. */
  flex-wrap: nowrap;
}
.admin-actions .btn { flex: 0 0 auto; white-space: nowrap; }
/* Zusatz-Aktionen im Pack-Dialog (Ersetzen/Banner) — abgesetzt von
   Abbrechen/Speichern, damit sie nicht wie Bestätigen aussehen */
.pack-edit-extra {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pack-edit-extra .btn.is-on { border-color: var(--accent); color: var(--accent); }
/* Zahlen-/Statusspalten nicht umbrechen („76.3 MB" stand auf zwei Zeilen) */
.admin-audio, .admin-date { white-space: nowrap; }
.admin-actions .btn {
  min-height: 36px;
  min-width: 36px;
  padding: 0.3em 0.7em;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* ---- V15: Klassen-Karten ---- */
.class-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.class-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface2, var(--surface));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.class-card.is-locked { border-color: var(--danger); }
.class-card__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.class-card__label { font-size: 1.05rem; font-weight: 600; }
.class-card__meta { color: var(--muted); font-size: 13px; line-height: 1.5; }
.class-card__switches { display: flex; gap: 6px; flex-wrap: wrap; }
.class-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  min-height: 36px;
  user-select: none;
}
.class-switch input { accent-color: var(--accent); margin: 0; }
.class-switch.is-on { border-color: var(--text); color: var(--text); }
.class-switch--lock.is-on { border-color: var(--danger); color: var(--danger); }
.class-card__actions { flex-wrap: wrap; }
.class-archive { margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.class-archive summary { cursor: pointer; padding: 6px 0; }
.class-cards--archive { margin-top: 10px; }
.class-cards--archive .class-card { opacity: 0.75; }
.admin-subhead {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 0 8px;
}
.admin-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.admin-check input { accent-color: var(--accent); margin: 0; }
.invite-options { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
/* V15.1: Clip-Auswahl (Formular + Dialog) */
.invite-videos { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 6px; margin: 0 0 14px; }
.invite-videos legend { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 6px; }
.clip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.clip-list--dialog { max-height: 50vh; overflow-y: auto; margin-bottom: 8px; }
.clip-list .admin-check { white-space: normal; min-height: 36px; color: var(--text); }
.clip-list .admin-check small { color: var(--muted); }
.clips-dialog { max-width: 640px; width: min(96vw, 640px); }
.class-card__clips { color: var(--muted); font-size: 13px; }
.class-card__clips strong { color: var(--text); font-weight: 600; }
.invite-options .admin-check { white-space: normal; min-height: 32px; }
.admin-pin {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
}
.admin-pin--missing { color: var(--accent); }
.settings-pin input { font-family: var(--font-mono); letter-spacing: 0.2em; }
.settings-pin-hint { margin: -6px 0 12px; font-size: 13px; }
/* ---- V15: Verlauf ---- */
.history-dialog { max-width: 760px; width: min(96vw, 760px); }
.history-list { max-height: 55vh; overflow-y: auto; border-top: 1px solid var(--line); }
.history-day {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 10px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.history-row__time { font-family: var(--font-mono); font-size: 13px; min-width: 96px; }
.history-row__body { flex: 1 1 auto; min-width: 0; }
.history-row__summary { color: var(--muted); font-size: 12px; margin-top: 2px; }
.history-row .badge { margin-left: 6px; }
.history-trash {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.history-trash strong { color: var(--text); }

.admin-empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 16px;
  margin: 0;
}

/* ============================================================
   V4: Werkzeuge column + settings dialog
   ============================================================ */

/* table column */
.admin-tools { white-space: nowrap; }
.admin-tools-icons {
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  cursor: default;
}
.admin-brief-flag {
  margin-left: 8px;
  cursor: default;
}

/* settings dialog (base .dialog/.dialog-overlay come from app.css) */
.settings-dialog {
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.settings-project {
  margin-top: 4px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-modules {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  padding: 10px 14px 12px;
  margin: 14px 0 6px;
}
.settings-modules legend {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 6px;
}
.settings-module {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px; /* touch-friendly */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.settings-module input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-brief { margin-top: 14px; }
.settings-brief textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.5em 0.8em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.settings-brief textarea:focus { border-color: var(--accent); }

.settings-dialog .dialog-actions { margin-top: 18px; }
.settings-dialog .btn { min-height: 44px; }

/* ---- Sample-Packs (V9.4) ---- */

.admin-packs { margin-top: 24px; padding: 16px; }
.admin-packs h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.admin-packs-hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.admin-pack-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.admin-pack-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.admin-pack-form button[type='submit'] { align-self: flex-start; }

.admin-pack-status { margin: 0; font-size: 14px; color: var(--muted); }

/* ---- Globale Bibliothek: Übersicht + Packs-Toolbar (V12) ---- */
.lib-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.lib-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.lib-stat strong { font-size: 1.6rem; line-height: 1.1; font-weight: 600; }
.lib-stat__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.lib-stat small { color: var(--muted); font-size: 12px; }
.packs-toolbar { margin-bottom: 14px; }

/* ---- Instrumente eines Projekts übernehmen (V12) ---- */
#sounds-list { margin-bottom: 14px; }
#sounds-list .micpick-item { flex-wrap: wrap; gap: 4px 10px; }
.sound-meta { color: var(--muted); font-size: 12px; }
#sounds-form { margin-bottom: 14px; }

/* ---- Klassencodes (V11) ---- */
.admin-hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; line-height: 1.5; }
.admin-hint strong { color: var(--text); font-weight: 600; }
.admin-pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 14px;
  /* Beschriftungen brechen unterschiedlich um — Felder trotzdem auf einer
     Linie halten, statt sie an der Oberkante auszurichten. */
  align-items: end;
}
.admin-pack-grid .field { margin-bottom: 10px; min-width: 0; }
.invite-code {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--accent2);
}
.invite-row--off td { opacity: 0.55; }
.invite-uses--full { color: var(--accent); }
.admin-toolbar select { min-height: 40px; background: var(--surface2); border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; }

.admin-packs-table { margin-top: 4px; }

/* ============================================================
   V13: Klassencode-Extras (Auftrag, Verlängern, QR, Filter-Links)
   + Upload-Fortschritt + Sammel-Export
   ============================================================ */

/* Arbeitsauftrag im Anlege-Formular — gleiche Optik wie settings-brief */
.invite-brief-field textarea {
  width: 100%;
  min-height: 72px;
  padding: 0.5em 0.8em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text);
  outline: none;
  resize: vertical;
}
.invite-brief-field textarea:focus { border-color: var(--accent); }

/* 📋-Indikator in der Code-Zelle: Auftrag hinterlegt, Klick klappt ihn auf */
.invite-brief-flag {
  background: none;
  border: none;
  padding: 4px 6px;
  margin-left: 6px;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  line-height: 1;
}
.invite-brief-flag:hover,
.invite-brief-flag.is-open { color: var(--text); }
.invite-brief-row td {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap; /* eine Zeile = ein Schritt, wie eingegeben */
}

/* Klick-Filter: „X Projekte" am Code bzw. Code-Zelle in der Projektliste */
.invite-projects-link {
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--accent2);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.invite-projects-link:hover { color: var(--text); }

/* Aktionen in abgelaufenen Zeilen NICHT ausgrauen — dort sitzt gerade der
   prominente „Verlängern"-Knopf */
.invite-row--off td:last-child { opacity: 1; }

/* Verlängern-Dialog: vier große Stunden-Knöpfe statt Freitext */
.extend-choices {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}
.extend-choices .btn {
  flex: 1 1 auto;
  min-height: 48px; /* touch-freundlich */
}

/* Upload-Fortschritt (Packs & Videos): Balken + Prozent + Abbrechen.
   Orange = es läuft gerade etwas (aktiv-Regel des Design-Systems). */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-progress__bar {
  flex: 1;
  min-width: 120px;
  height: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
}
.upload-progress__pct {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 4ch;
  text-align: right;
}

/* QR-Overlay: Klassencode-Direktlink an die Wand werfen */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000; /* wie .ask-overlay: über allem */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}
.qr-card {
  /* Weiß ist Pflicht: der QR braucht eine helle Ruhezone, sonst scannt
     im abgedunkelten Klassenraum kein iPad. */
  background: #fff;
  border-radius: 12px;
  padding: 2.5vmin 4vmin 2vmin;
  text-align: center;
}
.qr-card__img {
  display: block;
  margin: 0 auto;
  width: 62vmin; /* ≥ ~60 % der kleineren Viewport-Kante — Projektionsgröße */
  height: 62vmin;
  image-rendering: pixelated;
}
.qr-card__code {
  margin-top: 1.5vmin;
  font-family: var(--font-mono);
  font-size: clamp(28px, 7vmin, 84px);
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #000;
}
.qr-card__url {
  font-family: var(--font-mono);
  font-size: clamp(12px, 2vmin, 20px);
  color: #555;
  word-break: break-all;
}
.qr-overlay__hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
