/* ===================================================================
   Zeugniswerk Klasse — Companion-Shell (iPad-PWA)
   Ergänzt ../src/styles.css: App-Rahmen (Kopfleiste + untere Tab-Leiste),
   Tresor-/Startbildschirm, Modal, Toasts, Klassen-/Schülerverwaltung.
   Touch-optimiert, nutzt die Variablen aus styles.css.
   =================================================================== */

html, body { height: 100%; overscroll-behavior: none; }
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  font-size: 15px;
}

/* App-Container ist im Companion die SCROLL-Fläche (nicht die ganze Höhe). */
#app {
  height: auto;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}
.zw-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}

/* ---- Kopfleiste ---- */
.zw-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.zw-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-family: var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.zw-brand .ti { color: var(--accent); font-size: 19px; }
.zw-brand span { font-size: 15px; }
.zw-class-switch { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.zw-classbtn {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 7px 12px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent-text);
  border: 1px solid var(--accent-soft); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zw-classbtn .kb-muted { font-weight: 400; }
.zw-save { display: flex; align-items: center; gap: 5px; color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.zw-save .ti-circle-check { color: var(--accent-2); }
.zw-save .spin { animation: zw-spin 1s linear infinite; }
@keyframes zw-spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) { .zw-save span { display: none; } .zw-brand span { display: none; } }

/* ---- Untere Tab-Leiste ---- */
.zw-nav {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
}
.zw-navbtn {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; border-radius: 12px; background: transparent; border: 0;
  color: var(--text-3); font-size: 11px; font-weight: 500; cursor: pointer; min-height: 52px;
}
.zw-navbtn .ti { font-size: 21px; }
.zw-navbtn.active { color: var(--accent); background: var(--accent-soft); }

/* Das HTML-Attribut `hidden` MUSS verstecken — sonst überschreibt z. B.
   `.zw-gate { display:flex }` das voreingestellte `display:none` von [hidden],
   und der Sperrbildschirm bliebe trotz `el.hidden = true` über der App liegen. */
[hidden] { display: none !important; }

/* ---- Tresor-/Startbildschirm ---- */
.zw-gate {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--bg); background-image: var(--bg-grad);
}
.zw-gate-card { width: 100%; max-width: 380px; text-align: center; padding: 26px 22px; }
.zw-gate-card h1 { font-size: 21px; margin: 6px 0 4px; font-family: var(--font-display); }
.zw-gate-card p { color: var(--text-2); margin: 0 0 16px; }
.zw-gate-card .zw-modal-in { margin-bottom: 10px; }
.zw-gate-card .big { width: 100%; justify-content: center; margin-top: 4px; }
.zw-gate-card .ghost { width: 100%; justify-content: center; margin-top: 10px; }
.zw-gate-card .zw-gate-reset { margin-top: 16px; font-size: 12.5px; min-height: 0; color: var(--text-3); }
.zw-gate-card .zw-gate-reset:hover { color: var(--warn-text); }

.zw-welcome-icon {
  width: 64px; height: 64px; margin: 0 auto 6px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: #fff; box-shadow: var(--shadow-accent);
}
.zw-welcome-icon .ti { font-size: 32px; }

/* ---- Welcome ---- */
.zw-welcome { max-width: 460px; margin: 8vh auto 0; text-align: center; padding: 0 8px; }
.zw-welcome h1 { font-size: 24px; font-family: var(--font-display); margin: 10px 0 8px; }
.zw-welcome p { color: var(--text-2); margin: 0 auto 22px; max-width: 30em; }
.zw-welcome-actions { display: flex; flex-direction: column; gap: 10px; max-width: 320px; margin: 0 auto; }
.zw-welcome-actions .big { justify-content: center; }

/* ---- Buttons groß (Touch) ---- */
.big { padding: 12px 18px; font-size: 15px; border-radius: 12px; }
button { min-height: 38px; }
.zw-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

/* ---- Klassenliste ---- */
.zw-classlist { display: flex; flex-direction: column; gap: 10px; }
.zw-classcard { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.zw-classcard.active { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent) inset; }
.zw-classcard-main { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.zw-classcard-name { font-weight: 600; font-size: 16px; }
.zw-classcard-sub { color: var(--text-2); font-size: 13px; }
.zw-classcard-stats { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.zw-classcard-actions { display: flex; gap: 4px; }
.zw-tag { font-size: 11px; font-weight: 600; color: var(--accent-2-text); background: var(--accent-2-bg); padding: 1px 7px; border-radius: 999px; vertical-align: middle; }

/* ---- Schülerliste ---- */
.zw-studlist { display: flex; flex-direction: column; }
.zw-studrow { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--border); }
.zw-studrow:last-child { border-bottom: 0; }
.zw-studname { flex: 1 1 auto; }
.zw-addstud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.zw-addstud input, .zw-addstud select { flex: 1 1 120px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); }
.zw-addstud select { flex: 0 0 64px; }
.zw-addstud button { flex: 0 0 auto; }

/* ---- leere Zustände ---- */
.zw-empty { text-align: center; padding: 28px 18px; }
.zw-empty .ti { font-size: 34px; color: var(--text-3); }
.zw-empty p { margin: 8px 0 0; }
.zw-empty-sub { color: var(--text-3); font-size: 13px; }

/* ---- Modal (askText) ---- */
.zw-modal-back {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(20, 20, 30, .45); backdrop-filter: blur(2px);
}
.zw-modal { width: 100%; max-width: 360px; padding: 20px; }
.zw-modal-t { font-weight: 600; font-size: 17px; font-family: var(--font-display); }
.zw-modal-msg { color: var(--text-2); margin: 6px 0 12px; font-size: 13.5px; }
.zw-modal-in {
  width: 100%; padding: 11px 12px; margin-top: 10px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-size: 16px;
}
.zw-modal-err { color: #c0392b; font-size: 13px; margin-top: 8px; }
.zw-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.zw-cf-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.zw-cf-grid .fld select, .zw-cf-grid .fld input { font-size: 16px; }

/* ---- Passwort-Stärke-Anzeige ---- */
.zw-pwmeter { margin: 8px 0 2px; }
.zw-pwbar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.zw-pwbar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--text-3); transition: width .2s ease, background .2s ease; }
.zw-pwlabel { font-size: 12px; margin-top: 5px; color: var(--text-3); }
button:disabled, button[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ---- Toasts ---- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 90vw; padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-md); font-size: 13.5px; font-weight: 500; opacity: 1; transform: translateY(0); transition: opacity .3s, transform .3s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-info { background: var(--accent); color: #fff; }
.toast-warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid color-mix(in srgb, var(--warn-text) 30%, transparent); }

/* ---- kleine Korrekturen für die wiederverwendeten Module ---- */
.page-title { margin-top: 4px; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); }
/* width:100% — sonst dehnen sich <select>/<input> im Spalten-Flex nicht auf
   die volle Breite (Formularsteuerelemente haben eine intrinsische Eigenbreite,
   daher greift align-items:stretch nicht); auf iOS wird sonst der Text abgeschnitten. */
.fld select, .fld input { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-size: 15px; }

/* iOS Safari schneidet bei <select> den Text unten ab, wenn eine große
   line-height geerbt wird (Body = 1.5). Systemweit für ALLE Selects der
   iPad-App: line-height auf normal zurücksetzen und genügend Höhe geben,
   damit der gewählte Eintrag vollständig sichtbar bleibt (native Optik). */
select { line-height: normal; }
.fld select, .sp-fld select, .zw-addstud select { min-height: 42px; }
