/* Admin-UI – Gebetsanwesenheit (übernommen aus der Gebetsanzeige)
   Mobile-first, helles UI, Akzent Smaragdgrün #0E5B4C, keine externen Ressourcen. */

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('../../assets/fonts/ibmplexsans-var.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --accent: #0E5B4C;
  --accent-dark: #0A463B;
  --accent-soft: #E6F1ED;
  --bg: #F4F5F8;
  --card: #FFFFFF;
  --text: #23252B;
  --muted: #6B7080;
  --line: #E3E5EB;
  --ok: #1C7C3A;
  --ok-bg: #E7F6EC;
  --ok-line: #BFE4CB;
  --err: #B3261E;
  --err-bg: #FDECEC;
  --err-line: #F0C4C1;
  --warn: #8A5B00;
  --warn-bg: #FFF3D6;
  --warn-line: #EED9A4;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Kopfzeile & Navigation ---------- */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
}

.brand {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  padding: 8px 0;
}

/* Umbrechen statt seitlich scrollen: mit F5 sind es bis zu zehn Punkte, alle sollen sichtbar sein. */
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  max-width: 100%;
}

.nav a,
.nav .nav-logout {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  background: none;
  border: 0;
  cursor: pointer;
}

.nav a:hover,
.nav .nav-logout:hover { background: var(--bg); }

.nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav .nav-logout { color: var(--err); }

.logout-form { display: inline-flex; margin: 0; }

/* ---------- Inhalt ---------- */

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }

.muted { color: var(--muted); }
.mt { margin-top: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

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

.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- Flash-Meldungen ---------- */

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid;
  margin: 0 0 12px;
}

.flash-success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.flash-error   { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

/* ---------- Formulare ---------- */

label {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin: 14px 0 4px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}

textarea { min-height: 120px; resize: vertical; }

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="color"] {
  width: 56px;
  height: 44px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  flex: none;
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
  margin: 0;
  flex: none;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="text"] { flex: 1; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: 1fr; }

@media (min-width: 560px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: var(--card); color: var(--err); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-bg); }

.btn-sm { padding: 8px 12px; font-size: 15px; }
.btn-block { width: 100%; }

.inline-form { display: inline-flex; margin: 0; vertical-align: middle; }

/* ---------- Tabellen (mobil horizontal scrollbar) ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 16px;
}

table { border-collapse: collapse; width: 100%; min-width: 720px; }

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}

th {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #FAFBFC;
}

tbody tr:last-child td { border-bottom: none; }

tr.row-active td { background: var(--accent-soft); }

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

/* ---------- Badges, Toggle, Statistik ---------- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge-ok   { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--accent-soft); color: var(--accent); }

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 84px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toggle-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; }

.toggle-on  { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.toggle-off { background: #F1F2F5; color: var(--muted); }

.stat { font-size: 16px; margin: 4px 0 12px; }
.stat-num { font-size: 32px; font-weight: 700; color: var(--accent); margin-right: 4px; }

/* ---------- Dashboard ---------- */

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }

@media (min-width: 760px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.times-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .times-grid { grid-template-columns: repeat(3, 1fr); }
}

.time-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}

.time-tile .t-name { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.time-tile .t-val  { display: block; font-size: 22px; font-weight: 700; }

.time-tile.jumma { border-color: var(--accent); background: var(--accent-soft); }
.time-tile.jumma .t-name { color: var(--accent); }

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

.quick-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 10px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  background: var(--card);
}

.quick-link:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Bilder / Vorschau-Thumbnails ---------- */

.thumb {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 4px 0 8px;
}

/* ---------- Live-Vorschau (preview.php) ---------- */

.preview-wrap { max-width: 480px; margin: 0 auto; }

.preview-bezel {
  background: #191B22;
  border-radius: 28px;
  padding: 12px;
  box-shadow: 0 14px 34px rgba(20, 22, 30, 0.3);
}

.preview-scale {
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  margin: 0 auto;
}

.preview-scale iframe {
  width: 1080px;
  height: 1920px;
  border: 0;
  display: block;
  background: #000;
  transform-origin: 0 0;
}

/* ---------- Meldung an National (bericht.php) ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.bericht-steuerung {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.monat-wahl, .bericht-aktionen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.monat-wahl input[type="month"] { width: auto; min-height: 40px; }

.bericht-titel { font-size: 20px; }
.bericht-hinweis { margin: 0 0 12px; font-size: 14px; }

table.raster { min-width: 520px; font-variant-numeric: tabular-nums; }
.raster th, .raster td { padding: 6px 12px; }
.raster thead th { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }
.raster tbody th { font-weight: 600; color: var(--text); background: transparent; text-transform: none; letter-spacing: 0; font-size: 15px; }
.raster td { min-width: 72px; }
.raster .wochentag { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.raster tr.freitag th, .raster tr.freitag td { background: var(--accent-soft); }
.raster tbody tr:last-child th, .raster tbody tr:last-child td { border-bottom: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .bericht-steuerung, .flash, .content > h1 { display: none; }
  .content { max-width: none; padding: 0; }
  .card.bericht { border: 0; box-shadow: none; padding: 0; margin: 0; }
  .table-wrap { border: 0; overflow: visible; }
  .bericht-titel { font-size: 15pt; margin-bottom: 2mm; }
  .bericht-hinweis { font-size: 8.5pt; margin-bottom: 3mm; }
  table.raster { min-width: 0; }
  /* 31 Tage plus Kopf müssen auf eine A4-Seite: etwa 6 mm je Zeile. */
  .raster th, .raster td { padding: 0.8mm 3mm; font-size: 10pt; line-height: 1.25; border-bottom: 0.2mm solid #bbb; }
  .raster tbody tr:last-child th, .raster tbody tr:last-child td { border-bottom: 0.2mm solid #bbb; }
  .raster tr.freitag th, .raster tr.freitag td { background: #eef3f1; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Übersicht, Protokoll, Konten, Geräte (F5) ---------- */

.uebersicht td, .uebersicht th { text-align: right; }
.uebersicht th[scope="row"], .uebersicht thead th:first-child { text-align: left; }
.uebersicht .summe { font-weight: 700; color: var(--accent); }
.uebersicht tfoot th, .uebersicht tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: #FAFBFC; }
.uebersicht th a { color: inherit; }

table.protokoll { min-width: 760px; }
.protokoll td { font-size: 15px; }
.protokoll td.umbruch { white-space: normal; max-width: 280px; }

.konto h2, .geraet h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.konto-aus { opacity: 0.7; }
.konto-aktionen { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.konto-aktionen .inline-form { flex-wrap: wrap; gap: 6px; }
.konto-aktionen select,
.konto-aktionen input[type="text"],
.konto-aktionen input[type="password"] { width: auto; min-width: 180px; margin: 0; }

.geraet-neu { border-color: var(--accent); }
.geraet-qr { width: min(280px, 80vw); margin: 12px 0; }
.geraet-qr svg { display: block; width: 100%; height: auto; }
.geraet-neu input[readonly] { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
