/* ----------------------------------------------------------- *
 * Klassenraum-App — iOS-9-kompatibles Stylesheet
 *
 * Bewusst ohne CSS Custom Properties, CSS Grid, flex-gap,
 * feste Klebe-Positionen, inset oder neue CSS-Funktionen. Das iPad im Kurssaal
 * laeuft noch mit iOS 9 / Mobile Safari.
 * ----------------------------------------------------------- */

* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #5b1313;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select {
  font-family: inherit;
  font-size: 1rem;
}

button,
a,
.roster-row,
#guest-search-results .result {
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.18);
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.topbar h1 {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0.8rem;
}

.nav-arrow {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 2rem;
  font-weight: 300;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
}
.nav-arrow:active { background: rgba(255, 255, 255, 0.08); }

/* ---------------- Day list ---------------- */
.day-list {
  padding: 1rem;
}

.day-session {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 1.25rem 1rem;
  min-height: 56px;
  margin-bottom: 0.75rem;
  text-decoration: none;
  color: #ffffff;
}
.day-session:active { background: rgba(255, 255, 255, 0.13); }

.day-session .time {
  font-size: 1.1rem;
  font-weight: 600;
  width: 5rem;
  min-width: 5rem;
}

.day-session .group {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  font-size: 1rem;
  min-width: 0;
  padding-right: 0.75rem;
}

.day-session .group .designation,
.day-session .group .staffing {
  display: block;
  color: rgba(255, 255, 255, 0.67);
  margin-top: 0.18rem;
}
.day-session .group .designation { font-size: 0.85rem; }
.day-session .group .staffing { font-size: 0.8rem; }

.day-session .badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.67);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.day-session .badge.confirmed { background: #5fd17a; color: #003a18; }
.day-session .badge.running { background: #f4ad42; color: #4a2900; }
.day-session .badge.past { background: rgba(255, 255, 255, 0.13); color: rgba(255, 255, 255, 0.67); }
.day-session .badge.upcoming { background: transparent; border: 1px solid rgba(255, 255, 255, 0.13); }

/* ---------------- Session detail ---------------- */
.session-meta {
  padding: 0.5rem 1rem 0.75rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.95rem;
}

.session-meta .session-team {
  margin-top: 0.4rem;
  text-align: center;
}

.session-meta .team-chip {
  display: inline-block;
  margin: 0.16rem 0.12rem;
  padding: 0.18rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.8rem;
}
.session-meta .team-chip span { color: rgba(255, 255, 255, 0.67); }

.staffing-card {
  margin: 0.25rem 1rem 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
}

.staffing-card-header {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: start;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.staffing-card-header > div {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  padding-right: 0.75rem;
}
.staffing-card h2 {
  margin: 0.1rem 0 0.2rem;
  font-size: 1rem;
}
.staffing-card .muted {
  margin: 0;
  font-size: 0.85rem;
}
.section-eyebrow {
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-staffing-grid,
.modal .staffing-grid {
  border: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.session-staffing-grid label,
.modal .staffing-grid > label {
  display: block;
  float: left;
  width: 50%;
  padding: 0 0.38rem 0.75rem;
}
.session-staffing-grid label:nth-child(2n+1),
.modal .staffing-grid > label:nth-child(2n+1) {
  clear: left;
}
.session-staffing-grid label > span,
.modal .staffing-grid > label > span {
  display: block;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}
.session-staffing-grid select,
.modal select,
.modal input[type="password"],
.modal input[type="text"] {
  width: 100%;
  padding: 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: #6e1818;
  color: #ffffff;
  font-size: 0.95rem;
}
.session-staffing-grid select:disabled { opacity: 0.65; }

.staffing-save-status {
  clear: both;
  min-height: 1.2rem;
  margin: 0.7rem 0 0;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.85rem;
}
.staffing-save-status.dirty { color: #f4ad42; }
.staffing-save-status.error { color: #f08585; }

/* ---------------- Guest search ---------------- */
.add-guest-bar {
  position: relative;
  padding: 0.5rem 1rem 1rem;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}
.add-guest-bar input {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 1rem;
  min-width: 0;
}
.add-guest-bar input::-webkit-input-placeholder { color: rgba(255, 255, 255, 0.67); }
.add-guest-bar input::placeholder { color: rgba(255, 255, 255, 0.67); }
.add-guest-bar input:focus { outline: 2px solid #ffffff; }
#guest-search-clear {
  width: 56px;
  margin-left: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 1.4rem;
  cursor: pointer;
}
#guest-search-results {
  position: absolute;
  top: 100%;
  left: 1rem;
  right: 1rem;
  background: #6e1818;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  max-height: 60%;
  overflow-y: auto;
  z-index: 10;
}
#guest-search-results:empty { display: none; }
#guest-search-results .result {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  cursor: pointer;
  min-height: 56px;
}
#guest-search-results .result:last-child { border-bottom: none; }
#guest-search-results .result:active { background: rgba(255, 255, 255, 0.13); }

/* ---------------- Roster ---------------- */
.roster { padding: 0 1rem; }
.roster-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  cursor: pointer;
  min-height: 56px;
}
.roster-row .marker {
  width: 2.4rem;
  height: 2.4rem;
  line-height: 2.4rem;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 2.4rem;
  flex: 0 0 2.4rem;
}
.roster-row.absent .marker { color: rgba(255, 255, 255, 0.67); }
.roster-row.present .marker { color: #ffffff; }
.roster-row .name {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
  font-size: 1.05rem;
  padding: 0 1rem;
}
.roster-row .meta {
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.8rem;
  white-space: nowrap;
}
.roster-row.scan .meta { color: #5fd17a; }

/* ---------------- Guests section ---------------- */
.guests-section {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  margin-top: 1rem;
}
.guests-section h2 {
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.67);
  margin: 0 0 0.5rem;
}
.guests-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.guests-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}
.guests-list li:last-child { border-bottom: none; }

/* ---------------- Confirm button ---------------- */
.confirm-button {
  display: block;
  margin: 1.5rem 1rem 1.2rem;
  width: -webkit-calc(100% - 2rem);
  width: calc(100% - 2rem);
  padding: 1.1rem;
  background: #ffffff;
  color: #5b1313;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.confirm-button:active { -webkit-transform: translateY(1px); transform: translateY(1px); }
.confirm-button.disabled { opacity: 0.5; pointer-events: none; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #5b1313;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 1.5rem;
  width: 420px;
  max-width: 100%;
  margin: 0 auto;
}
.modal h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 700;
}
.modal .staffing-grid {
  margin: 1rem -0.38rem 0.25rem;
}
.pin-label,
.pin-teacher-label {
  display: block;
  margin-top: 0.75rem;
}
.pin-label > span,
.pin-teacher-label > span {
  display: block;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}
.checkbox-label {
  display: block;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.modal-actions {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 1rem;
}
.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}
.modal-actions .btn-primary { margin-left: 0.75rem; }

.btn-primary,
.btn-secondary {
  border-radius: 10px;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: #ffffff;
  color: #5b1313;
  border: none;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.13);
}

.error-banner {
  background: #f08585;
  color: #4a0000;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

.muted { color: rgba(255, 255, 255, 0.67); }
.center { text-align: center; }

/* ---------------- Bottom actions ---------------- */
.bottom-actions {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  margin-top: 2rem;
}
.btn-link {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.inline-form { display: inline; }

/* ---------------- Setup screen ---------------- */
.setup-body {
  padding: 2rem 1rem;
}
.setup-card {
  width: 440px;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 2rem;
  margin: 0 auto;
}
.setup-card h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}
.setup-card form.stack {
  margin-top: 1rem;
}
.setup-card label {
  display: block;
  margin-bottom: 0.85rem;
}
.setup-card label > span {
  display: block;
  color: rgba(255, 255, 255, 0.67);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.setup-card input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 1rem;
}
.setup-card .btn-primary {
  width: 100%;
  margin-top: 0.2rem;
}

@media (max-width: 520px) {
  .topbar h1 { font-size: 1.05rem; margin: 0 0.4rem; }
  .nav-arrow { width: 48px; height: 48px; }
  .day-session { padding: 1rem 0.75rem; }
  .day-session .time { width: 4.2rem; min-width: 4.2rem; font-size: 1rem; }
  .day-session .badge { display: none; }
  .session-staffing-grid label,
  .modal .staffing-grid > label {
    float: none;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
  .staffing-card-header {
    display: block;
  }
  .staffing-card-header > div { padding-right: 0; margin-bottom: 0.75rem; }
  .staffing-card-header .btn-secondary,
  #staffing-save { width: 100%; }
}
