/* public/style.css — Minimal-Design, mobile-first, fingertauglich
 *
 * Diktura-Brandfarben (Lead-Tenant-Default):
 *   --brand-primary:  #0F4D3A (Diktura-Dunkelgruen, fuer Body-BG/Buttons/Akzent-Linien)
 *   --brand-accent:   #5CDA9C (Diktura-Hellgruen, fuer Hover-States/Tagline/Akzent)
 *   --brand-shadow:   rgba(15,77,58,0.3) (Glow-Effekt)
 *   --brand-bg-soft:  #E8F5EE (sehr hell, fuer Login-Card-Akzent)
 *
 * KU-THERM-Brandfarben kommen weiterhin aus config/kutherm.json und werden
 * per JS (public/app.js) zur Laufzeit als CSS-Var gesetzt, damit die Pilot-
 * Subdomain doku.kutherm.glueckselig.org weiterhin ihr eigenes Gruen zeigt.
 *
 * Fuer neue Tenants ohne Config-Override gilt der Diktura-Default.
 */

:root {
  --brand-primary:  #0F4D3A;
  --brand-accent:   #5CDA9C;
  --brand-shadow:   rgba(15, 77, 58, 0.3);
  --brand-shadow-strong: rgba(15, 77, 58, 0.45);
  --brand-bg-soft:  #E8F5EE;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--brand-bg-soft); /* Diktura-Default: sehr helles Hellgruen */
  color: #1a1a1a;
  min-height: 100vh;
  min-height: 100dvh; /* Mobile: echte Viewport-Höhe trotz dynamischer URL-Bar */
}
/* Footer-Sticky: Body als Flex-Column, <main> als flex:1 schiebt den
 * legal-footer ans Viewport-Boden — auch bei kurzem Content (IDLE-Screen).
 * Login-Seite hat eigene .login-page-Regel (komplexeres Layout). */
body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: inherit;
  font-size: 16px; /* iOS: verhindert Auto-Zoom */
}

/* === Login-Seite === */
/* Layout-Garantien (kritisch):
 *  - body ist Flex-Column → <main> und <footer> stapeln sich vertikal
 *  - .login-page setzt NICHT display:flex, sondern erbt vom body
 *    (Display-Reset unten, damit kein versehentliches Row-Layout entsteht)
 *  - .login-wrap ist 100% breit + flex:1 → füllt den Raum, schiebt Footer ans Boden
 *  - .login-card ist eigenes div, NICHT <main> → kann via Flex zentriert werden
 *  - Mobile: Card oben (nicht zentriert), damit Card + Footer gleichzeitig sichtbar
 *    sind, ohne dass der Footer die Card überlagert. */
.login-page {
  /* KEIN display:flex hier — wir erben vom body. Verhindert, dass
   * versehentlich ein Row-Layout entsteht, falls body-Regel fehlt. */
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh; /* Mobile: echte Viewport-Höhe trotz dynamischer URL-Bar */
  padding: 20px;
}

.login-wrap {
  flex: 1; /* füllt den Raum zwischen Header (keiner) und Footer */
  width: 100%;
  max-width: 600px; /* identisch zur main-Regel, damit Login-Seite nicht ausufert */
  margin: 0 auto; /* horizontale Zentrierung des Wrappers selbst */
  display: flex;
  align-items: center; /* vertikale Zentrierung der Card (Desktop) */
  justify-content: center;
}

.login-card {
  background: white;
  padding: 32px 24px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-top: 4px solid var(--brand-primary); /* Diktura: dunkelgruener Akzent oben */
  width: 100%;
  max-width: 360px;
}

/* Mobile (< 480px): Card nicht mehr zentriert, sondern oben — sonst
 * rutscht sie bei großem Datenschutz-Hinweis unter den Footer-Bereich
 * und es entsteht Scroll-Spagat. */
@media (max-width: 480px) {
  .login-page {
    padding: 16px;
  }
  .login-wrap {
    align-items: flex-start; /* Card oben ausrichten */
  }
  .login-card {
    padding: 24px 20px;
    margin-top: 24px;
  }
}

.login-title {
  margin: 0 0 4px;
  font-size: 24px;
  text-align: center;
}

.login-subtitle {
  margin: 0 0 24px;
  font-size: 14px;
  color: #666;
  text-align: center;
}

#login-form label {
  display: block;
  margin-top: 16px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
}

#login-form input {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

#login-form input:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  background: var(--brand-primary);
  color: white;
  font-size: 16px;
  font-weight: 600;
  border-radius: 6px;
  transition: background 0.15s;
}

.btn-primary:active {
  background: var(--brand-accent);
}

.btn-text {
  display: block;
  margin: 12px auto 0;
  padding: 8px 16px;
  color: var(--brand-accent);
  font-size: 14px;
}

.error {
  margin: 12px 0 0;
  color: #c00;
  font-size: 14px;
  text-align: center;
  min-height: 1.2em;
}

.datenschutz-hinweis {
  margin: 24px 0 0;
  padding: 12px;
  background: #f0f7ff;
  border-radius: 6px;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

/* === Nutzungs-Anzeige (Tarif + Tag/Monat) === */
.usage-box {
  margin: 16px auto 0;
  max-width: 360px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e3e8d8;
  border-radius: 8px;
  font-size: 13px;
  color: #1a1a1a;
  text-align: left;
}
.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.usage-tarif {
  font-weight: 600;
  color: var(--brand-accent);
}
.usage-refresh {
  cursor: pointer;
  color: #888;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: none;
}
.usage-refresh:hover {
  background: var(--brand-bg-soft);
  color: var(--brand-accent);
}
.usage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.usage-label {
  width: 52px;
  flex-shrink: 0;
  font-size: 12px;
  color: #555;
}
.usage-bar {
  flex: 1;
  height: 8px;
  background: #eef2e3;
  border-radius: 4px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.usage-bar-fill.warn { background: #e8a33d; }
.usage-bar-fill.full { background: #c0392b; }
.usage-count {
  width: 84px;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: #1a1a1a;
}

/* === App-Header === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: white;
  border-bottom: 3px solid var(--brand-primary); /* Diktura: dunkelgruene Akzent-Linie (PDF-Stil) */
}

.app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 13px;
  color: #666;
}

/* === Sections === */
.section {
  display: none;
  padding: 24px 16px;
}

.section.active {
  display: block;
}

main {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  flex: 1; /* Body ist Flex-Column → Main füllt Raum, Footer bleibt am Boden */
  box-sizing: border-box;
}

/* === Record-Area === */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
  position: relative; /* Anker für .pulse-ring (position:absolute) */
}

.record-btn {
  position: relative; /* über dem Pulse-Ring im z-Stapel */
  z-index: 2;         /* Klicks dürfen nicht vom Ring abgefangen werden */
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--brand-shadow);
  transition: transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent; /* iOS: kein grauer Flash beim Tippen */
  touch-action: manipulation; /* Mobile: keine 300ms-Verzögerung */
}

.record-btn:active {
  transform: scale(0.95);
}

.record-btn.recording {
  background: #c00;
  box-shadow: 0 4px 12px rgba(204,0,0,0.3);
}

.pulse-ring {
  position: absolute;
  top: 40px;          /* entspricht padding-top von .record-area, zentriert über Button */
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(204,0,0,0.2);
  pointer-events: none; /* Klicks gehen durch zum Button darunter */
  z-index: 1;
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.timer {
  margin: 16px 0 8px;
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #c00;
}

.hint {
  margin: 8px 0 0;
  color: #666;
  font-size: 14px;
}

.hint-large {
  margin: 16px 0;
  font-size: 18px;
  font-weight: 500;
}

.audio-info {
  margin: 0 0 24px;
  font-size: 13px;
  color: #666; /* BFSG/WCAG-AA: #888 (3.5:1) → #666 (5.7:1) */
}

/* === Loading === */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* === Result === */
.result-area {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.success-banner {
  margin: 0 0 16px;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.success-banner.success {
  background: #d4edda;
  color: #155724;
}

.success-banner.warning {
  background: #fff3cd;
  color: #856404;
}

.doku-output {
  margin: 0 0 24px;
  line-height: 1.6;
  font-size: 15px;
}

.doku-output h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.doku-output h2 {
  font-size: 16px;
  margin: 20px 0 8px;
  color: var(--brand-accent);
  border-bottom: 1px solid var(--brand-bg-soft);
  padding-bottom: 4px;
}

.doku-output ul {
  margin: 8px 0;
  padding-left: 24px;
}

.doku-output li {
  margin: 4px 0;
}

.doku-output p {
  margin: 8px 0;
}

.doku-section {
  margin: 0 0 24px;
}

.doku-section h3 {
  font-size: 14px;
  margin: 12px 0 4px;
  color: #444;
  font-weight: 600;
}

.doku-mat {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 14px;
}

.doku-mat th,
.doku-mat td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
}

.doku-mat th {
  background: #f5f5f5;
  font-weight: 600;
  font-size: 13px;
}

.doku-fliesstext {
  font-style: italic;
  color: #555;
  font-size: 14px;
  line-height: 1.65;
}

.doku-empty {
  color: #666; /* BFSG/WCAG-AA: #999 (2.85:1) → #666 (5.7:1) */
  font-style: italic;
}

.doku-projekt {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 8px 0;
}

.doku-projekt dt {
  font-weight: 600;
  color: #666;
  font-size: 13px;
}

.doku-projekt dd {
  margin: 0;
  color: #000;
  font-size: 14px;
}

.error-large {
  margin: 0 0 8px;
  font-size: 18px;
  color: #c00;
  font-weight: 500;
  text-align: center;
}

/* === Legal-Footer (Impressum/Datenschutz/Barrierefreiheit) === */
.legal-footer {
  text-align: center;
  font-size: 13px;
  color: #666;
  padding: 16px;
  width: 100%; /* Body ist Flex-Column → Footer braucht explizite Volle-Breite,
                  damit Trennlinien/Linien-Effekte durchgehend wirken */
  align-self: stretch; /* Falls Body align-items:center hat (Login-Page),
                          überschreibt stretch die Zentrierung NUR für Footer */
  box-sizing: border-box;
}
.legal-footer a {
  color: var(--brand-accent);
  text-decoration: none;
}
.legal-footer a:hover,
.legal-footer a:focus {
  text-decoration: underline;
}

/* === Rechtliche Pflichtseiten (/impressum, /datenschutz, /barrierefreiheit) === */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  background: white;
  min-height: 100vh;
}
.legal-page h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.legal-page .legal-sub {
  color: #666;
  font-size: 13px;
  margin: 0 0 8px;
}
.legal-page h2 {
  font-size: 16px;
  margin: 28px 0 8px;
  color: var(--brand-accent);
}
.legal-page h3 {
  font-size: 14px;
  margin: 18px 0 6px;
  color: #444;
}
.legal-page p,
.legal-page li {
  font-size: 14px;
  line-height: 1.6;
  color: #1a1a1a;
  margin: 8px 0;
}
.legal-page ul,
.legal-page ol {
  padding-left: 24px;
  margin: 8px 0;
}
.legal-page .legal-back {
  display: inline-block;
  margin: 0 0 16px;
  color: var(--brand-accent);
  text-decoration: none;
  font-size: 14px;
}
.legal-page .legal-disclaimer {
  margin-top: 32px;
  padding: 12px 14px;
  background: #fff8e1;
  border-left: 3px solid #f0ad4e;
  border-radius: 4px;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}
