/* SciStay Mikroskop – Station. Branding über die Variablen anpassen. */
:root {
  --brand: #1d5fbf;
  --brand-dark: #154a96;
  --accent: #ff8a1f;
  --accent-dark: #e06f00;
  --danger: #d93a3a;
  --ok: #1f9d55;
  --bg: #eef3fa;
  --card: #ffffff;
  --text: #14213d;
  --muted: #55627a;
  --stage: #0b1220;
  --radius: 18px;
  --tap: 64px;
  --gap: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(16px, 1.25vw, 22px);
  user-select: none;
  -webkit-user-select: none;
}

input { user-select: text; -webkit-user-select: text; }
img { -webkit-user-drag: none; }
[hidden] { display: none !important; }

body:not(.ready) main,
body:not(.ready) .lang-switch { visibility: hidden; }

body {
  display: grid;
  grid-template-rows: auto 1fr;
}

/* --- Kopfzeile ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px var(--gap);
  background: var(--card);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.06);
  z-index: 2;
}

.logo { height: 48px; }

.lang-switch { display: flex; gap: 8px; }

.lang-switch button {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 3px solid var(--brand);
  border-radius: 14px;
  background: var(--card);
  color: var(--brand);
  font: 700 1.1rem var(--font);
  cursor: pointer;
}

.lang-switch button.active { background: var(--brand); color: #fff; }

main { min-height: 0; position: relative; }

.screen { height: 100%; min-height: 0; }

/* --- Knöpfe --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 28px;
  border: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--brand);
  font: 700 1.15rem var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn .icon { font-size: 1.3em; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger.armed { background: var(--danger); color: #fff; }
.btn-small { min-height: 48px; padding: 0 16px; font-size: 1rem; }

.icon-btn {
  width: 52px;
  height: 52px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.15);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.actions { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }

:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

/* --- Kamera-Ansicht ------------------------------------------------------- */
.screen-camera {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  position: relative;
}

.stage {
  position: relative;
  min-height: 0;
  background: var(--stage);
  overflow: hidden;
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.on { animation: flash 0.35s ease-out; }

@keyframes flash {
  from { opacity: 0.9; }
  to { opacity: 0; }
}

.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
}

.shutter {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(120px, 11vw, 168px);
  aspect-ratio: 1;
  border: 6px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font: 800 1.3rem var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.4);
  transition: transform 0.08s, background 0.15s;
}

.shutter .icon { font-size: 2.6rem; line-height: 1; }
.shutter:hover:not(:disabled) { background: var(--accent-dark); }
.shutter:active:not(:disabled) { transform: translateY(-50%) scale(0.94); }
.shutter:disabled { background: #6b7280; opacity: 0.7; cursor: not-allowed; }

.labelbar {
  position: absolute;
  left: 16px;
  right: calc(clamp(120px, 11vw, 168px) + 56px);
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 20px;
  border-radius: var(--radius);
  background: rgb(11 18 32 / 0.82);
  color: #fff;
}

.labelbar-q { font-weight: 700; white-space: nowrap; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chip {
  min-height: var(--tap);
  padding: 0 18px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: 600 1.05rem var(--font);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.active { background: #fff; color: var(--text); }

.chips-light .chip { border-color: var(--brand); color: var(--brand); }
.chips-light .chip.active { background: var(--brand); color: #fff; }

.filmstrip {
  display: flex;
  gap: var(--gap);
  align-items: center;
  padding: 12px var(--gap);
  background: var(--card);
}

.strip {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
}

.thumb {
  flex: 0 1 140px;
  min-width: 0;
  aspect-ratio: 16 / 9;
  position: relative;
  padding: 0;
  border: 3px solid var(--brand);
  border-radius: 10px;
  background: var(--stage);
  overflow: hidden;
  cursor: pointer;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1px 4px;
  background: rgb(11 18 32 / 0.7);
  color: #fff;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb.empty { border: 3px dashed #c3cede; background: transparent; cursor: default; }

.strip-side { display: flex; align-items: center; gap: var(--gap); flex: none; }

.counter { font-size: 1.5rem; font-weight: 800; color: var(--brand); white-space: nowrap; }

.max-hint,
.station-warning {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 12px 24px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-align: center;
  max-width: 80%;
}

.station-warning { background: var(--danger); top: auto; bottom: 140px; }

/* --- Karten & Formulare --------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 4px 20px rgb(20 33 61 / 0.08);
}

h1 { margin: 0 0 16px; font-size: 1.9rem; }
h2 { margin: 0 0 12px; font-size: 1.3rem; }

.muted { color: var(--muted); }
.big-text { font-size: 1.35rem; font-weight: 600; }
.big-emoji { font-size: 4rem; }

.field-label { display: block; font-weight: 700; margin: 0 0 8px; }

input[type="email"],
input:not([type]),
input[type="password"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 18px;
  border: 3px solid #b9c6da;
  border-radius: 14px;
  font: 600 1.25rem var(--font);
  color: var(--text);
  background: #fff;
}

input:focus { border-color: var(--brand); outline: none; }

/* --- Senden --------------------------------------------------------------- */
.screen-review {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.review-images { min-height: 0; display: flex; flex-direction: column; }

.review-grid {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  overflow-y: auto;
  align-content: start;
}

.review-grid li { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.review-grid img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--stage); }
.review-grid span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.review-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
}

.review-form .field-label { margin: 0; }

.email-invalid { margin: 0; color: var(--danger); font-weight: 700; }

.email-echo {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--bg);
}

.email-echo strong {
  display: block;
  font-size: 1.6rem;
  word-break: break-all;
  color: var(--brand);
}

.consent {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  font-weight: 600;
  cursor: pointer;
}

.consent input {
  width: 32px;
  height: 32px;
  flex: none;
  margin: 0;
  accent-color: var(--brand);
}

.consent:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }

.privacy-note { margin: 0; color: var(--muted); font-size: 0.85rem; }

.review-form .actions { margin-top: auto; justify-content: space-between; }
.review-form .actions .btn { flex: 1; }

/* --- Hochladen & Fertig --------------------------------------------------- */
.screen-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.center-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  width: 100%;
}

.center-card .actions { justify-content: center; }

.progress {
  width: 100%;
  height: 28px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.2s;
}

#upload-progress-box { width: 100%; }

.done-card h1 { margin: 0; }

.qr { width: min(34vh, 340px); aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; display: block; }

.email-sent { margin: 0; font-weight: 700; color: var(--ok); word-break: break-all; }

/* --- Overlays ------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(11 18 32 / 0.75);
}

.dialog { width: min(640px, 100%); display: flex; flex-direction: column; gap: 18px; }

.viewer {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 30%);
  gap: 24px;
  width: 100%;
  height: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
}

.viewer img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: var(--stage);
  border-radius: 12px;
}

.viewer-side { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow-y: auto; }
.viewer-label { margin: 0; font-size: 1.6rem; font-weight: 800; word-break: break-word; }
.viewer-side .chips { flex: none; }
.viewer-side .actions { margin-top: auto; }
.viewer-side .actions .btn { flex: 1; }

/* --- Einrichtung ---------------------------------------------------------- */
.screen-setup { padding: 24px; overflow-y: auto; user-select: text; }
.setup-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; align-items: start; }
.setup-grid form { display: flex; flex-direction: column; gap: 12px; }
.setup-cameras { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.setup-camera { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setup-camera-name { flex: 1; font-weight: 600; min-width: 200px; }
.badge { padding: 6px 12px; border-radius: 999px; background: var(--ok); color: #fff; font-weight: 700; }
.setup-video { width: 100%; aspect-ratio: 16 / 9; background: var(--stage); border-radius: 12px; margin-top: 12px; }
.setup-url { display: block; padding: 10px; background: var(--bg); border-radius: 8px; word-break: break-all; }

/* --- Kleine Bildschirme (1366 × 768) ------------------------------------- */
@media (max-height: 800px) {
  .logo { height: 40px; }
  .topbar { padding-block: 6px; }
  .center-card { gap: 8px; }
  .done-card .big-text { margin: 0; }
  .card { padding: 20px; }
  h1 { font-size: 1.6rem; }
  .email-echo strong { font-size: 1.35rem; }
}
