/* =============================================================
   Drum-Booking · Styles
   ----------------------------------------------------
   Bewusst minimal, ohne CSS-Framework. Mobile-first.
   ============================================================= */

:root {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #0f0f0f;
  --text-muted: #6b6b6b;
  --border: #e4e4e4;
  --accent: rgb(38, 104, 93);
  --accent-hover: rgb(28, 84, 73);
  --topbar-bg: #ffffff;
  --topbar-text: #0f0f0f;
  --success-bg: #f0fdf4;
  --success-text: #14532d;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Topbar (hell, mit Logo) ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--topbar-text);
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.brand-sub {
  display: inline-block;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hello {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { color: var(--accent-hover); }

.inline { display: inline; }

/* ---- Container ---- */
.container {
  max-width: 1240px;
  margin: 24px auto;
  padding: 0 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

h1 { margin: 0 0 10px; font-size: 1.5rem; }
h2 { margin: 0 0 10px; font-size: 1.2rem; }
h3 { margin: 18px 0 8px; font-size: 1rem; }

.subtle { color: var(--text-muted); margin: 0 0 16px; }
.empty { color: var(--text-muted); font-style: italic; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
}
.form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

/* ---- Alerts ---- */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ---- Bookings list ---- */
.bookings {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bookings li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.bookings li:last-child { border-bottom: none; }
.bookings .booking-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.bookings .time { color: var(--text-muted); }
.bookings .booking-title {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.booking-past { opacity: 0.75; }

.bookings .booking-meta {
  font-size: 0.8rem;
  margin-top: 2px;
}

.card-cancelled {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
}
.card-cancelled h1 { color: #92400e; }

.badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-lesson  { background: #f0f0f0; color: #1f1f1f; font-weight: 600; }

/* ---- Karten-Stand ---- */
.card-status { padding: 16px 24px; }
.card-info { font-size: 0.95rem; }
.card-info .card-text { margin-bottom: 8px; }
.card-progress {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.card-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}
.card-info.card-low .card-progress-bar { background: #f59e0b; }
.card-info.card-empty {
  color: var(--error-text);
  background: var(--error-bg);
  padding: 12px 14px;
  border-radius: 8px;
}

/* ---- Slot list (Multi-Select Buchung) ---- */
.section-heading {
  margin: 24px 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
}
.section-heading:first-child { margin-top: 8px; }
.section-fresh {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #065f46;
}
.fresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: white;
  transition: background 0.1s, border-color 0.1s;
}
.slot-row:hover { background: #f9fafb; }
.slot-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
}
.slot-row .slot-when { flex: 1; }
/* Datum + Uhrzeit: Uhrzeit bricht nie mittendrin um */
.slot-when .slot-date { margin-right: 8px; }
.slot-when .slot-time { white-space: nowrap; }
.slot-row:has(input:checked) {
  background: #f0f0f0;
  border-color: var(--accent);
  border-width: 1px;
}
.slot-row-fresh { border-color: #a7f3d0; background: #f0fdf4; }
.slot-row-fresh:hover { background: #ecfdf5; }
.slot-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
  text-transform: uppercase;
}

.book-bar {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.04);
}
.book-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.book-counter {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Liste der aktuell ausgewählten Termine im Buchungs-Balken */
.selected-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow-y: auto;
}
.selected-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #f0f0f0;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}
.selected-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  line-height: 1;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.selected-remove:hover {
  background: #e0e0e0;
  color: var(--text);
}
.book-form .btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Während der Submit läuft: dauerhaft sichtbar + leichter Puls,
   damit der Schüler sieht "es passiert was". */
.book-form .btn-primary.is-loading {
  opacity: 0.8;
  cursor: progress;
  animation: button-pulse 1.4s ease-in-out infinite;
}
@keyframes button-pulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* ---- Monats-Zwischenüberschrift in der "regulären" Liste ---- */
.month-heading {
  margin: 22px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.month-heading:first-of-type { margin-top: 10px; }

/* ---- Tag-Überschriften in der "regulären" Liste ---- */
.date-heading {
  margin: 14px 0 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

/* Uhrzeiten eines Tages nebeneinander statt untereinander —
   füllt so viele Spalten, wie in die Breite passen. */
.slot-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.slot-row-compact {
  gap: 8px;
  padding: 9px 10px;
  white-space: nowrap;
}
.slot-row-compact .slot-when {
  flex: 1;
  text-align: center;
}

/* "Neu eingetragen": gleiche Nebeneinander-Anordnung, aber breitere
   Zellen, weil hier das volle Datum + Badge mit reinmuss. Style der
   Zeilen (grün, Badge) bleibt unverändert. */
.slot-list-grid-fresh {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}

.slot-form { margin: 0; }

.slot-btn {
  width: 100%;
  padding: 14px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.1s;
}
.slot-btn small {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.slot-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.slot-btn:hover small { color: rgba(255, 255, 255, 0.7); }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

/* ---- Admin-Panel ---- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.admin-table th,
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.admin-table th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.admin-table tr.row-inactive td { opacity: 0.5; }
.admin-table .mono { font-family: SF Mono, ui-monospace, monospace; font-size: 0.85rem; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-active   { background: #10b981; }
.dot-inactive { background: #9ca3af; }
.dot-admin    { background: #0f0f0f; }

.badge-card-ok    { background: #d1fae5; color: #065f46; }
.badge-card-low   { background: #fef3c7; color: #92400e; }
.badge-card-empty { background: #fee2e2; color: #991b1b; }

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  margin: 10px 0;
}
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.inline-form label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.inline-form select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  box-sizing: border-box;
}

.form-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ---- Filter-Leiste (Buchungs-Übersicht) ---- */
.filter-bar { margin-bottom: 16px; }

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Zeitraum-Filter: zwei Datumsfelder nebeneinander */
.date-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.date-range input[type="date"] {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}
.date-range-sep { color: var(--text-muted); }

/* ---- Multi-Select-Dropdown (Status-Filter) ---- */
.multi-dropdown {
  position: relative;
  display: inline-block;
}
.multi-dropdown summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  white-space: nowrap;
  position: relative;
  min-width: 150px;
  box-sizing: border-box;
}
.multi-dropdown summary::-webkit-details-marker { display: none; }
.multi-dropdown summary::after {
  content: '▾';
  position: absolute;
  right: 12px;
  color: var(--text-muted);
}
.multi-dropdown[open] summary { border-color: var(--accent); }
.multi-dropdown .md-label { color: var(--text-muted); }
.multi-dropdown .md-value { font-weight: 600; }

.multi-dropdown-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.multi-dropdown-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.95rem;
}
.multi-dropdown-panel label:hover { background: #f0f0f0; }
.multi-dropdown-panel input { width: 16px; height: 16px; margin: 0; }

.text-muted { color: var(--text-muted); }

/* ---- Admin Navigation ---- */
.admin-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 auto 16px;
  max-width: 1240px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.admin-nav a {
  flex: 1;
  text-align: center;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}
.admin-nav a:hover { background: #f0f0f0; color: var(--text); }

/* ---- Notify-Panel ---- */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.checkbox-row:last-child { border-bottom: none; }
.checkbox-row:hover { background: #fafafa; }
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 0 14px 0;
}
fieldset legend { font-weight: 600; padding: 0 6px; }

textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

/* ---- Title-Edit-Tabelle (Schüler-Detail) ---- */
.title-input {
  width: 100%;
  min-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  background: #fafafa;
}
.title-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  background: white;
  border-color: var(--accent);
}
.title-edit-table td { vertical-align: middle; }

.btn-sm {
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}
.btn-sm:hover { background: #f3f4f6; }

.save-template-btn {
  margin-left: 12px;
  font-size: 0.85rem;
  vertical-align: middle;
}
.save-template-btn:hover { color: var(--accent-hover); }

.bulk-toggle {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.student-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr;
  gap: 10px;
  align-items: center;
}
.student-row .student-name { font-weight: 500; }
.student-row .student-email {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: ui-monospace, SF Mono, monospace;
}
.student-row.no-email {
  opacity: 0.45;
  cursor: not-allowed;
}
.student-row.no-email .student-email { font-style: italic; }

.preview-card { border-left: 4px solid var(--accent); }
.email-preview {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  font-family: ui-monospace, SF Mono, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* =============================================================
   Mobile / responsive
   ============================================================= */

/* ---- Tablet & große Smartphones ---- */
@media (max-width: 768px) {
  .container { padding: 0 12px; }

  /* Breite Tabellen: horizontal scrollbar statt über den Rand quellen */
  .admin-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Admin-Navigation: bei Platzmangel horizontal scrollbar */
  .admin-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-nav a { flex: 0 0 auto; white-space: nowrap; }

  /* Filter-Leiste: Felder untereinander, volle Breite */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar label { width: 100%; }
  .filter-bar select { width: 100%; }
  .filter-bar .date-range { width: 100%; }
  .date-range input[type="date"] { flex: 1; min-width: 0; }

  /* Kopfzeile mit Titel + Button: untereinander */
  .admin-header { flex-direction: column; align-items: stretch; gap: 10px; }
}

/* ---- Smartphone ---- */
@media (max-width: 520px) {
  .topbar { padding: 10px 14px; }
  .brand-logo { height: 24px; }
  .brand-sub { display: none; }          /* zu eng — nur Logo zeigen */
  .container { padding: 0 10px; margin: 14px auto; }
  .card { padding: 16px; }

  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }

  /* Inputs/Selects: 16px verhindert iOS-Auto-Zoom beim Fokus */
  input, select, textarea { font-size: 16px; }

  /* Größere Touch-Targets bei der Slot-Auswahl */
  .slot-row { padding: 14px 12px; }
  .slot-row input[type="checkbox"] { width: 22px; height: 22px; }
  .checkbox-row { padding: 12px 6px; }

  /* Datum und Uhrzeit untereinander — Uhrzeit als ganze, eigene Zeile */
  .slot-when { display: flex; flex-direction: column; gap: 2px; }
  .slot-when .slot-date { margin-right: 0; }

  /* Uhrzeit-Raster: am Smartphone genau 2 nebeneinander */
  .slot-list-grid { grid-template-columns: repeat(2, 1fr); }
  .slot-row-compact .slot-when { flex-direction: row; }

  /* Buttons gut tippbar, volle Breite wo sinnvoll */
  .btn { padding: 12px 18px; }
  .form-row { flex-direction: column-reverse; }
  .form-row .btn { width: 100%; }

  /* Sticky Buchungs-Balken: gestapelt */
  .book-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .book-bar .btn { width: 100%; }
  .book-counter { text-align: center; }

  /* Stammdaten-Liste untereinander */
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; font-weight: 600; }
  .kv dd { margin-bottom: 4px; }

  /* Account-Aktionen: Buttons volle Breite */
  .action-row { flex-direction: column; }
  .action-row form,
  .action-row .btn { width: 100%; }
  .action-row form .btn { width: 100%; }

  .slot-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
