/* ═══════════════════════════════════════════════════════════════════
   office-ui.css — Design-Fundament fürs Office-Cockpit (Welle 0, 03.07.2026)
   Ziel: kein Seiten-H-Scroll, Buttons ohne Textüberlauf, konsistente
   Tabellen/Chips/Toolbars. REIN ADDITIV: neue .ui-*-Klassen, dockt an die
   bestehenden --jk-*-Tokens an, überschreibt NICHTS Bestehendes.
   Anwendung erfolgt flächenweise (Welle 1: Schülerliste, Welle 2: Akte …).
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Buttons: Text bricht NIE mehr aus dem Knopf ─── */
body[data-page="office"] .ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--jk-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--jk-text);
  font: 600 0.84rem/1.25 var(--jk-font-body);
  cursor: pointer;
  text-align: center;
  white-space: normal;          /* lange deutsche Labels: umbrechen statt überlaufen */
  overflow-wrap: anywhere;
  max-width: 100%;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
body[data-page="office"] .ui-btn:hover { background: rgba(255,255,255,0.09); color: var(--jk-white); }
body[data-page="office"] .ui-btn:active { transform: translateY(1px); }
body[data-page="office"] .ui-btn:disabled { opacity: 0.5; cursor: default; }

body[data-page="office"] .ui-btn--primary {
  background: linear-gradient(135deg, var(--jk-pink), #c91074);
  border-color: transparent;
  color: #fff;
}
body[data-page="office"] .ui-btn--primary:hover { filter: brightness(1.08); color: #fff; }
body[data-page="office"] .ui-btn--danger {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.45);
  color: #fca5a5;
}
body[data-page="office"] .ui-btn--ghost { background: transparent; }
body[data-page="office"] .ui-btn--sm {
  padding: 5px 10px;
  min-height: 30px;
  font-size: 0.78rem;
  border-radius: 8px;
}
/* Icon-only-Knopf (für Aktionen in Tabellenzeilen) */
body[data-page="office"] .ui-btn--icon {
  padding: 5px 8px;
  min-height: 30px;
  min-width: 32px;
  font-size: 0.9rem;
  line-height: 1;
}

/* Button-Leisten: umbrechen statt quetschen */
body[data-page="office"] .ui-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ─── Toolbars (Suche/Filter/Sortierung in einer umbruchfähigen Zeile) ─── */
body[data-page="office"] .ui-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
body[data-page="office"] .ui-toolbar > input[type="search"],
body[data-page="office"] .ui-toolbar > input[type="text"] {
  flex: 1 1 160px;
  min-width: 0;
}
body[data-page="office"] .ui-toolbar > select { flex: 0 1 auto; min-width: 0; max-width: 100%; }

/* ─── Tabellen: scrollen im eigenen Kasten, nie die Seite ─── */
body[data-page="office"] .ui-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border: 1px solid var(--jk-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
body[data-page="office"] .ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
body[data-page="office"] .ui-table th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--jk-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--jk-border);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.03);
}
body[data-page="office"] .ui-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: top;
}
body[data-page="office"] .ui-table tbody tr:last-child td { border-bottom: none; }
body[data-page="office"] .ui-table tbody tr:hover td { background: rgba(231, 17, 131, 0.05); }
body[data-page="office"] .ui-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Zweizeilige Zelle: Hauptinfo + kleine Nebeninfo (spart Spalten) */
body[data-page="office"] .ui-cell-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--jk-text-muted);
  margin-top: 2px;
}
/* Sticky-Header für lange Tabellen im Scroll-Kasten */
body[data-page="office"] .ui-table--sticky th { position: sticky; top: 0; z-index: 1; }

/* ─── Chips & Status-Badges ─── */
body[data-page="office"] .ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--jk-text);
  border: 1px solid transparent;
  white-space: nowrap;
}
body[data-page="office"] .ui-chip--pink   { background: rgba(231,17,131,0.14);  color: #ff7ab8; }
body[data-page="office"] .ui-chip--cyan   { background: rgba(0,212,255,0.12);   color: #7fe3ff; }
body[data-page="office"] .ui-chip--green  { background: rgba(57,255,122,0.12);  color: #7dffab; }
body[data-page="office"] .ui-chip--yellow { background: rgba(255,212,0,0.12);   color: #ffe27a; }
body[data-page="office"] .ui-chip--red    { background: rgba(220,38,38,0.14);   color: #fca5a5; }

/* ─── Karten & Leerzustände ─── */
body[data-page="office"] .ui-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.02));
  border: 1px solid var(--jk-border);
  border-radius: 14px;
  padding: 16px;
}
body[data-page="office"] .ui-empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--jk-text-muted);
  font-size: 0.88rem;
}

/* ─── Formular-Raster (Welle 3: Modals/Stammdaten) ─── */
body[data-page="office"] .ui-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
}
body[data-page="office"] .ui-form-grid label { display: block; min-width: 0; }

/* ═══ Welle 1 — Schülerliste ═══ */

/* Kern-Fix gegen Seiten-H-Scroll: minmax(0,1fr) statt 1fr — breite Inhalte
   (Tabellen in der Akte) können das Grid nicht mehr aufsprengen. */
body[data-page="office"] .students-layout {
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}
body[data-page="office"] .students-detail {
  min-width: 0;
  overflow-x: auto; /* Übergangslösung Welle 1: Akte scrollt ggf. im Kasten,
                       nie die Seite. Welle 2 baut die Tabellen selbst um. */
}

/* Listenzeilen als Karten: Initialen-Punkt, Name + Chips, Nebenzeile */
body[data-page="office"] .students-list li[data-sid] {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}
body[data-page="office"] .stu-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 0.72rem/1 var(--jk-font-body);
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, rgba(231,17,131,0.75), rgba(0,212,255,0.55));
  flex: none;
}
body[data-page="office"] .stu-main { min-width: 0; }
body[data-page="office"] .stu-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
body[data-page="office"] .stu-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
body[data-page="office"] .stu-sub {
  display: block;
  color: var(--jk-text-muted);
  font-size: 0.74rem;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body[data-page="office"] .students-list .ui-chip { padding: 1px 7px; font-size: 0.64rem; }

/* Kopf über der Liste: Titelzeile mit Zähler */
body[data-page="office"] .students-count {
  color: var(--jk-text-muted);
  font-size: 0.74rem;
  padding: 6px 2px 2px;
}

/* Zurück-Leiste im Detail — nur im schmalen Ein-Spalten-Modus sichtbar */
body[data-page="office"] .students-back { display: none; margin-bottom: 10px; }

/* Schmale Fenster: Liste ODER Akte, nie gequetscht nebeneinander */
@media (max-width: 1100px) {
  body[data-page="office"] .students-layout { grid-template-columns: minmax(0, 1fr); }
  body[data-page="office"] .students-layout.show-detail .students-sidebar { display: none; }
  body[data-page="office"] .students-layout:not(.show-detail) .students-detail { display: none; }
  body[data-page="office"] .students-layout.show-detail .students-back { display: inline-flex; }
}

/* ═══ Welle 2 — Schüler-Akte ═══ */

/* Kopfbereich: Name + Chips + Status-Badges + Saldo-Karten immer sichtbar */
body[data-page="office"] .acc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
body[data-page="office"] .acc-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.4px;
}
body[data-page="office"] .acc-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin-top: 8px;
  min-height: 20px;
}
body[data-page="office"] .acc-head-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
body[data-page="office"] .acc-head-cards .acc-card { margin: 0; }

/* Aktionsleiste der Akte: wenige sichtbare Aktionen + „⋯ Aktionen"-Menü */
body[data-page="office"] .acc-actionbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  position: relative;
}

/* „Nächste Schritte"-Leiste (Codex-Batch 04.07.): zustandsabhängige Sofort-
   Aktionen ganz oben in der Akte. Erscheint NUR, wenn wirklich etwas ansteht
   (sonst .hidden). Macht die Akte zum Cockpit statt zur Karteikarte. */
body[data-page="office"] .acc-nextbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0 2px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(231, 17, 131, 0.28);
  background: linear-gradient(180deg, rgba(231, 17, 131, 0.10), rgba(231, 17, 131, 0.04));
}
body[data-page="office"] .acc-nextbar.hidden { display: none; }
body[data-page="office"] .acc-nextbar-label {
  font: 800 0.64rem/1 var(--jk-font-body);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--jk-pink);
  margin-right: 2px;
}
body[data-page="office"] .ui-btn--warn {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}
body[data-page="office"] .ui-btn--warn:hover { background: rgba(245, 158, 11, 0.26); color: #fde68a; }

/* Dropdown-Menü (⋯ Aktionen) */
body[data-page="office"] .ui-menu-wrap { position: relative; display: inline-flex; }
body[data-page="office"] .ui-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 265px;
  max-width: 92vw;
  max-height: 70vh;
  overflow-y: auto;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--jk-border);
  background: linear-gradient(180deg, rgba(18, 22, 30, 0.99), rgba(12, 15, 22, 0.99));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  display: none;
}
body[data-page="office"] .ui-menu.open { display: block; }
body[data-page="office"] .ui-menu .ui-menu-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--jk-text-muted);
  padding: 8px 10px 4px;
}
body[data-page="office"] .ui-menu .ghost-button,
body[data-page="office"] .ui-menu a.ghost-button,
body[data-page="office"] .ui-menu .ui-btn {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.84rem;
  white-space: normal;
}
body[data-page="office"] .ui-menu .ghost-button:hover,
body[data-page="office"] .ui-menu .ui-btn:hover {
  background: rgba(231, 17, 131, 0.12);
}
/* Kritische Aktionen im Menü optisch als Warnung abheben (Codex-Batch 04.07.:
   Archivieren, DSGVO) — damit sie nicht versehentlich wie Routine wirken. */
body[data-page="office"] .ui-menu .ghost-button.danger-item { color: #f87171; }
body[data-page="office"] .ui-menu .ghost-button.danger-item:hover {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

/* Sub-Reiter der Akte: moderne Pills, UMBRECHEN statt seitlich scrollen
   (Owner 04.07.: „nach rechts/links scrollbar verwirrt das Büro"). */
body[data-page="office"] .subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 16px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--jk-border);
}
body[data-page="office"] .subtabs .subtab {
  flex: none;
  border: none;
  background: transparent;
  color: var(--jk-text-muted);
  font: 600 0.82rem/1 var(--jk-font-body);
  padding: 10px 12px;
  border-radius: 9px 9px 0 0;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, background 0.15s;
}
body[data-page="office"] .subtabs .subtab:hover { color: var(--jk-white); background: rgba(255,255,255,0.04); }
body[data-page="office"] .subtabs .subtab.active {
  color: var(--jk-white);
  border-bottom-color: var(--jk-pink);
  background: rgba(231, 17, 131, 0.08);
}

/* Panels: eigener Scroll-Kasten (fixt ALLE Akte-Tabellen auf einmal) + Tabellen-Polish */
body[data-page="office"] .subtab-panel { overflow-x: auto; min-width: 0; margin-top: 12px; padding-top: 4px; }
body[data-page="office"] .subtab-panel .data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
body[data-page="office"] .subtab-panel .data-table th {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--jk-text-muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--jk-border);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  white-space: nowrap;
}
body[data-page="office"] .subtab-panel .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: top;
}
body[data-page="office"] .subtab-panel .data-table tbody tr:hover td { background: rgba(231, 17, 131, 0.05); }
body[data-page="office"] .subtab-panel .data-table .num,
body[data-page="office"] .subtab-panel .data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Buttons in Tabellenzellen: kompakt, ohne Zeilensprengung */
body[data-page="office"] .subtab-panel .data-table .ghost-button,
body[data-page="office"] .subtab-panel .data-table .primary-button {
  padding: 4px 9px;
  font-size: 0.74rem;
  white-space: normal;
}

/* ═══ Welle 3 — Ausbildungs-Fortschritt im Schülerinfo-Popup ═══ */

/* Sektion über die volle Popup-Breite (das Popup ist ein auto-fit-Grid) */
body[data-page="office"] .student-info-popup .tsum-section {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, rgba(231,17,131,0.06), rgba(255,255,255,0.02));
}
body[data-page="office"] .tsum-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
body[data-page="office"] .tsum-card {
  border: 1px solid var(--jk-border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  padding: 12px 14px;
}
body[data-page="office"] .tsum-card-head {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--jk-white);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
body[data-page="office"] .tsum-group-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--jk-text-muted);
  margin: 10px 0 4px;
}
body[data-page="office"] .tsum-group-label:first-of-type { margin-top: 0; }
body[data-page="office"] .tsum-row {
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) minmax(48px, 1.4fr) auto;
  align-items: center;
  gap: 9px;
  padding: 3px 0;
}
body[data-page="office"] .tsum-label {
  font-size: 0.8rem;
  color: var(--jk-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body[data-page="office"] .tsum-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
body[data-page="office"] .tsum-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--jk-pink), #ff7ab8);
}
body[data-page="office"] .tsum-bar-fill.done {
  background: linear-gradient(90deg, #22c55e, #7dffab);
}
body[data-page="office"] .tsum-val {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--jk-text-muted);
  white-space: nowrap;
  text-align: right;
}
body[data-page="office"] .tsum-val.done { color: #7dffab; font-weight: 700; }
body[data-page="office"] .tsum-exams {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
body[data-page="office"] .tsum-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: center;
  margin-top: 12px;
  font-size: 0.85rem;
}
body[data-page="office"] .tsum-meta strong { color: var(--jk-text-muted); font-weight: 700; margin-right: 4px; }

/* ═══ Welle 3 Teil 2 — Schülerinfo-Popup: nichts läuft mehr aus dem Kasten ═══ */
/* Owner 04.07.: „Vertrags-Link senden"-Button lief rechts aus dem Popup.
   dd-Inhalte (Buttons/Selects/Text) werden hart auf die Spaltenbreite begrenzt. */
body[data-page="office"] .student-info-popup { min-width: 0; }
body[data-page="office"] .student-info-popup section { min-width: 0; }
body[data-page="office"] .student-info-popup dd { min-width: 0; }
body[data-page="office"] .student-info-popup dd > button,
body[data-page="office"] .student-info-popup dd > .ghost-button,
body[data-page="office"] .student-info-popup dd > a,
body[data-page="office"] .student-info-popup dd > select,
body[data-page="office"] .student-info-popup dd > input {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
/* dd mit Button + Hilfetext: untereinander statt nebeneinander drängeln */
body[data-page="office"] .student-info-popup dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
body[data-page="office"] .student-info-popup dd .muted { flex-basis: 100%; }
