/* ==========================================================================
   Hygiene-Audit Fotoerfassung – mobile-first Stylesheet
   Alloheim-Farben: Primär #4b2e83 (Kopf/Buttons), Akzent #1a3a6b (Rahmen/Links)
   ========================================================================== */

:root {
  --color-primary: #4b2e83;
  --color-primary-dark: #382062;
  --color-accent: #1a3a6b;
  --color-bg: #f4f4f6;
  --color-card: #ffffff;
  --color-text: #222222;
  --color-muted: #666666;
  --color-success: #1e7e34;
  --color-warn: #b9770e;
  --color-danger: #b02a2a;
  --radius: 10px;
  --touch: 48px;
}

* { box-sizing: border-box; }

/* Globales Sicherheitsnetz: [hidden] muss IMMER greifen, egal welche
   spätere Regel mit gleicher oder höherer Spezifität display setzt.
   Verhindert die "Endlos-Spinner"-Klasse von Bugs (01.09.2026). */
[hidden] { display: none !important; }

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px 0; }
h2 { font-size: 1.3rem; color: var(--color-primary); }
p { margin: 0 0 12px 0; }

/* ---------- Header / Footer ---------- */
.app-header {
  background: #ffffff;
  border-bottom: 3px solid var(--color-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-logo { height: 32px; width: auto; display: block; }
.app-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0;
}

.app-footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.78rem;
  padding: 20px 16px 32px;
}

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---------- Screens / Cards ---------- */
/* WICHTIG: [hidden] muss IMMER gewinnen, auch gegen spätere .screen-Regeln
   mit gleicher Spezifität (Browser-Standardregel [hidden]{display:none}
   wird sonst von Autoren-CSS gleicher Spezifität überschrieben – Bug vom
   01.09.2026, siehe claude/foto_upload_webapp.md). Deshalb hier :not([hidden]). */
.screen:not([hidden]) { display: block; }
.screen[hidden] { display: none !important; }
.screen-narrow { max-width: 420px; margin: 0 auto; }

.confirm-card, #screen-detail, #screen-finish, #screen-categories {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.confirm-card { margin-top: 16px; }
.confirm-label { color: var(--color-muted); margin-bottom: 4px; font-size: 0.9rem; }
.confirm-name { font-size: 1.15rem; font-weight: 600; color: var(--color-accent); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password] {
  width: 100%;
  font-size: 1.2rem;
  padding: 12px 14px;
  border: 2px solid #d5d5db;
  border-radius: var(--radius);
  margin-bottom: 14px;
  min-height: var(--touch);
}
input:focus { outline: none; border-color: var(--color-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  min-height: var(--touch);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:disabled { background: #b7abcf; cursor: not-allowed; }
.btn-secondary { background: #ffffff; color: var(--color-accent); border: 2px solid var(--color-accent); }
.btn-link { background: none; border: none; color: var(--color-accent); font-weight: 600; width: auto; padding: 8px 0; text-decoration: underline; }
.back-link { margin-bottom: 8px; }

.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.btn-row-stack { margin-top: 20px; }

.error-text { color: var(--color-danger); font-weight: 600; margin-top: 10px; }
.warn-text { color: var(--color-warn); font-weight: 600; }

/* ---------- Site bar (Schritt 2 Kopf) ---------- */
.site-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.site-bar-pcnr { font-weight: 700; color: var(--color-primary); margin: 0; }
.site-bar-name { color: var(--color-muted); margin: 0; font-size: 0.92rem; }

/* ---------- Fortschritt ---------- */
.progress-wrap { margin-bottom: 18px; }
.progress-bar {
  background: #e3e1e9;
  border-radius: 20px;
  height: 14px;
  overflow: hidden;
}
.progress-fill {
  background: var(--color-primary);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}
.progress-text { font-size: 0.85rem; color: var(--color-muted); margin-top: 6px; margin-bottom: 0; }

/* ---------- Kategorie-Liste ---------- */
.category-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--color-card);
  border: 2px solid #e3e1e9;
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  min-height: var(--touch);
}
.category-item:active { background: #f0edf7; }
.category-item.is-done { border-color: var(--color-success); }
.category-item.is-skipped { border-color: #cfcfcf; opacity: 0.75; }
.category-name { font-weight: 600; flex: 1; }
.category-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-open { background: #eeeeee; color: #555; }
.badge-done { background: #e1f3e6; color: var(--color-success); }
.badge-skipped { background: #eeeeee; color: #888; }

/* ---------- Foto-Grid ---------- */
.detail-hint { color: var(--color-muted); font-size: 0.9rem; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.photo-slot {
  aspect-ratio: 1 / 1;
  border: 2px dashed #c9c5d6;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #faf9fc;
  min-height: 120px;
}
.photo-slot.has-photo { border-style: solid; border-color: var(--color-success); }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot-label {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.85rem;
  padding: 8px;
}
.photo-slot input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.photo-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
}

/* ---------- Abschluss ---------- */
.finish-summary { list-style: none; padding: 0; margin: 16px 0; }
.finish-summary li { padding: 6px 0; border-bottom: 1px solid #eee; }

/* ---------- Toast / Spinner ---------- */
.toast {
  position: fixed;
  left: 16px; right: 16px; bottom: 20px;
  background: var(--color-accent);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-align: center;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.toast.is-error { background: var(--color-danger); }

.spinner-overlay:not([hidden]) {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  z-index: 200;
}
.spinner-overlay[hidden] { display: none !important; }
.spinner {
  width: 44px; height: 44px;
  border: 5px solid #ddd;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Tablet / Desktop – ab hier Erweiterungen, mobile-first Basis bleibt aktiv
   ========================================================================== */
@media (min-width: 600px) {
  .app-main { padding: 28px 24px 48px; }
  .btn { width: auto; }
  .btn-row { flex-direction: row; }
  .btn-row .btn { flex: 1; }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .app-logo { height: 40px; }
  .app-title { font-size: 1.1rem; }
}

@media (min-width: 1024px) {
  .app-main { max-width: 860px; }
  h2 { font-size: 1.5rem; }
}
