/* =====================================================================
   TrustAge – app.css
   Modern-nüchtern, Blau-Akzent. Hell/Dunkel über CSS-Variablen.
   Theme-Steuerung: <html data-theme="light|dark">.
   Ohne data-theme greift prefers-color-scheme automatisch.
   ===================================================================== */

:root {
  /* Farbskala – Light (Default) */
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #f0f3f7;
  --border:        #d9e0ea;
  --text:          #1b2733;
  --text-muted:    #5b6b7b;
  --accent:        #1f6feb;   /* Blau */
  --accent-hover:  #1a5fd0;
  --accent-contrast:#ffffff;
  --error-bg:      #fdeced;
  --error-text:    #b3261e;
  --warn-bg:       #fff6e5;
  --warn-text:     #8a5a00;
  --code-bg:       #eef2f7;
  --code-text:     #14304f;
  --shadow:        0 1px 2px rgba(16,32,53,.06), 0 4px 16px rgba(16,32,53,.08);
  --radius:        12px;
  --radius-sm:     8px;
  --maxw:          440px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dunkel: explizit per Attribut … */
:root[data-theme="dark"] {
  --bg:            #0f141a;
  --surface:       #161d26;
  --surface-2:     #1d2632;
  --border:        #2a3744;
  --text:          #e6edf3;
  --text-muted:    #9aa7b4;
  --accent:        #4d8dff;
  --accent-hover:  #6aa0ff;
  --accent-contrast:#0f141a;
  --error-bg:      #3a1d1d;
  --error-text:    #ff8a80;
  --warn-bg:       #3a2f17;
  --warn-text:     #ffd27a;
  --code-bg:       #1f2935;
  --code-text:     #cfe2ff;
  --shadow:        0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.4);
}

/* … und automatisch, wenn kein Attribut gesetzt ist */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0f141a;
    --surface:       #161d26;
    --surface-2:     #1d2632;
    --border:        #2a3744;
    --text:          #e6edf3;
    --text-muted:    #9aa7b4;
    --accent:        #4d8dff;
    --accent-hover:  #6aa0ff;
    --accent-contrast:#0f141a;
    --error-bg:      #3a1d1d;
    --error-text:    #ff8a80;
    --warn-bg:       #3a2f17;
    --warn-text:     #ffd27a;
    --code-bg:       #1f2935;
    --code-text:     #cfe2ff;
    --shadow:        0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.ta-header {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ta-logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.ta-logo::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}

/* ---- Main ---- */
.ta-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 48px 16px;
}

/* ---- Footer ---- */
.ta-footer {
  padding: 16px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---- Card ---- */
.ta-card {
  width: 100%;
  max-width: var(--maxw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.ta-card h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.ta-card p { color: var(--text-muted); margin: 8px 0 20px; }

/* ---- Auth-Formular ---- */
.ta-auth form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.ta-auth label { display: flex; flex-direction: column; gap: 6px; }
.ta-auth label span { font-size: 0.9rem; font-weight: 600; color: var(--text); }

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

button {
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
button:hover { background: var(--accent-hover); }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---- Meldungen ---- */
.ta-error {
  background: var(--error-bg);
  color: var(--error-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin: 0 0 16px;
}
.ta-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

/* ---- TOTP-Setup ---- */
.ta-qr {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
  padding: 16px;
  background: #ffffff;           /* QR braucht hellen Grund, auch im Dark Mode */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ta-qr img, .ta-qr canvas { display: block; }

.ta-secret {
  text-align: center;
  margin: 4px 0 20px;
}
.ta-secret code {
  display: inline-block;
  padding: 8px 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  color: var(--code-text);
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* ---- Recovery-Codes ---- */
.ta-recovery {
  list-style: none;
  padding: 16px;
  margin: 8px 0 16px;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.ta-recovery li { text-align: center; }
.ta-recovery code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--code-text);
}

/* ---- Dashboard-Logout-Form ---- */
.ta-card form[action$="/logout"] { margin-top: 16px; }

/* ---- Links ---- */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---- Klein/Mobil ---- */
@media (max-width: 480px) {
  .ta-card { padding: 24px; }
  .ta-main { padding: 24px 12px; }
  .ta-recovery { grid-template-columns: 1fr; }
}

/* ===================================================================
   Provider – Code-Ausstellung
   =================================================================== */

/* Formular: zwei Felder nebeneinander */
.ta-row { display: flex; gap: 16px; }
.ta-row label { flex: 1; }

select {
  width: 100%;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Menü / Buttons */
.ta-menu { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 20px; }
.ta-btn, .ta-btn-secondary {
  display: inline-block;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ta-btn { color: var(--accent-contrast); background: var(--accent); }
.ta-btn:hover { background: var(--accent-hover); color: var(--accent-contrast); }
.ta-btn-secondary {
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border);
}
.ta-actions { display: flex; gap: 12px; margin-top: 24px; }

/* Ergebnisseite */
.ta-issued h2 { font-size: 1.05rem; margin: 0 0 4px; }
.ta-issued-block { margin: 20px 0; text-align: center; }
.ta-issued-data {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}
.ta-issued-data th, .ta-issued-data td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ta-issued-data th { color: var(--text-muted); font-weight: 600; width: 40%; }
.ta-bigcode {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  color: var(--code-text);
  background: var(--code-bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

/* Druck: nur die Ausgabe, kein Chrome */
@media print {
  .ta-header, .ta-footer, .ta-noprint, .ta-warn { display: none !important; }
  body { background: #fff; color: #000; }
  .ta-card {
    box-shadow: none; border: none; max-width: 100%;
    margin: 0; padding: 0;
  }
  .ta-qr { border: none; padding: 0; }
  .ta-bigcode { background: transparent; color: #000; }
  .ta-issued-block { page-break-inside: avoid; }
}

/* ===================================================================
   Consumer – API-Key-Verwaltung
   =================================================================== */
.ta-card h2 { font-size: 1.1rem; margin: 24px 0 12px; }

.ta-keyform { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.ta-keyform label { display: flex; flex-direction: column; gap: 6px; }
.ta-keyform label span { font-size: 0.9rem; font-weight: 600; }
.ta-hint { color: var(--text-muted); font-size: 0.82rem; margin-top: -4px; }

.ta-secret-box {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.ta-secret-box h2 { margin-top: 0; }

.ta-keys { width: 100%; border-collapse: collapse; margin: 8px 0; }
.ta-keys th, .ta-keys td {
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem; vertical-align: middle;
}
.ta-keys th { color: var(--text-muted); font-weight: 600; }
.ta-keys code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }

.ta-inline { display: flex; gap: 6px; align-items: center; margin: 0; }
.ta-inline input[type="text"] { padding: 6px 8px; font-size: 0.85rem; }

.ta-btn-small, .ta-btn-danger {
  padding: 6px 12px; font-size: 0.85rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
}
.ta-btn-small { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.ta-btn-danger { background: var(--error-bg); color: var(--error-text); }
.ta-btn-danger:hover { background: var(--error-text); color: #fff; }

.ta-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}
.ta-badge-active { background: #e3f3e8; color: #1b7a3d; }
.ta-badge-revoked { background: var(--surface-2); color: var(--text-muted); }
:root[data-theme="dark"] .ta-badge-active { background: #14331f; color: #6bd998; }

.ta-back { margin-top: 20px; }

@media (max-width: 480px) {
  .ta-keys, .ta-keys thead, .ta-keys tbody, .ta-keys tr, .ta-keys td, .ta-keys th { display: block; }
  .ta-keys thead { display: none; }
  .ta-keys td { border: none; padding: 4px 0; }
  .ta-keys tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  .ta-inline { flex-wrap: wrap; }
}

/* ===================================================================
   Breite Karte für Verwaltungsseiten (Tabellen, Formulare)
   =================================================================== */
.ta-card.ta-wide { max-width: 860px; }

/* Lange Codes immer umbrechen statt überlaufen */
.ta-bigcode { word-break: break-all; white-space: normal; }
.ta-secret-box .ta-issued-data td { word-break: break-all; }
.ta-keys code { word-break: break-all; }

/* Key-Tabelle: feste Layout-Breite, damit Spalten nicht sprengen */
.ta-keys { table-layout: fixed; }
.ta-keys th:nth-child(1), .ta-keys td:nth-child(1) { width: 34%; }
.ta-keys th:nth-child(2), .ta-keys td:nth-child(2) { width: 16%; }
.ta-keys th:nth-child(3), .ta-keys td:nth-child(3) { width: 26%; }
.ta-keys th:nth-child(4), .ta-keys td:nth-child(4) { width: 10%; }
.ta-keys th:nth-child(5), .ta-keys td:nth-child(5) { width: 14%; }

/* Inline-Bearbeitung: Feld über Button, nicht nebeneinander gequetscht */
.ta-keys .ta-inline { flex-direction: column; align-items: stretch; gap: 6px; }
.ta-keys .ta-inline input[type="text"] { width: 100%; }
.ta-keys .ta-inline button { align-self: flex-start; }

/* Revoke-Zelle sauber ausrichten */
.ta-keys td:last-child { text-align: right; }

/* ===================================================================
   Consumer – Benutzerverwaltung
   =================================================================== */
.ta-notice {
  background: #e3f3e8; color: #1b7a3d;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 0.92rem; margin: 0 0 16px;
}
:root[data-theme="dark"] .ta-notice { background: #14331f; color: #6bd998; }

.ta-self { color: var(--text-muted); font-size: 0.85rem; }

.ta-useractions { display: flex; flex-direction: column; gap: 8px; }
.ta-useractions .ta-inline { flex-wrap: wrap; }
.ta-useractions input[type="text"] { min-width: 140px; }

/* ===================================================================
   Consumer – Anfrage-Liste
   =================================================================== */
.ta-filter {
  display: flex; align-items: flex-end; gap: 16px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.ta-filter label { display: flex; flex-direction: column; gap: 6px; }
.ta-filter label span { font-size: 0.9rem; font-weight: 600; }
.ta-filter select { min-width: 160px; }

.ta-pagination {
  display: flex; align-items: center; gap: 16px;
  margin-top: 16px; justify-content: center;
}
.ta-page-info { color: var(--text-muted); font-size: 0.9rem; }

/* Requests-Tabelle: feste Spaltenbreiten, ID darf umbrechen */
.ta-requests { table-layout: fixed; width: 100%; }
.ta-requests code { word-break: break-all; font-size: 0.8rem; }
.ta-requests th:nth-child(1), .ta-requests td:nth-child(1) { width: 22%; }
.ta-requests th:nth-child(2), .ta-requests td:nth-child(2) { width: 16%; }
.ta-requests th:nth-child(3), .ta-requests td:nth-child(3) { width: 14%; }
.ta-requests th:nth-child(4), .ta-requests td:nth-child(4) { width: 16%; }
.ta-requests th:nth-child(5), .ta-requests td:nth-child(5) { width: 20%; }
.ta-requests th:nth-child(6), .ta-requests td:nth-child(6) { width: 12%; text-align: right; }

@media (max-width: 480px) {
  .ta-requests, .ta-requests thead, .ta-requests tbody, .ta-requests tr, .ta-requests td, .ta-requests th { display: block; }
  .ta-requests thead { display: none; }
  .ta-requests td { border: none; padding: 4px 0; width: auto !important; text-align: left !important; }
  .ta-requests tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
}

/* ===================================================================
   Consumer – Zahlungsart (Stripe Elements)
   =================================================================== */
.ta-payform { margin: 12px 0; }
.ta-paytype { display: flex; gap: 20px; margin-bottom: 16px; }
.ta-paytype label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
#payment-element { margin-bottom: 16px; }
#pay-submit { width: 100%; }
#pay-msg { min-height: 1.2em; margin-top: 10px; }

/* Kontaktdaten-Formular: alle Inputs einheitlich (wie das App-Standardfeld) */
.ta-keyform input[type="text"],
.ta-keyform input[type="email"],
.ta-keyform input[type="time"],
.ta-keyform input:not([type]) {
  width: 100%;
  padding: 11px 13px;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.ta-keyform input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.ta-check { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.ta-check input { width: auto !important; }
.ta-hours-row { align-items: center; gap: 10px; }
.ta-hours-row .ta-day { min-width: 28px; font-weight: 600; }
.ta-hours-row input[type="time"] { max-width: 140px; }

/* Provider-Verzeichnis */
.ta-badge-soon { background:#fff3cd; color:#8a6d00; }
:root[data-theme="dark"] .ta-badge-soon { background:#3a3000; color:#f0d040; }
.ta-dir-list { list-style:none; padding:0; margin:0; }
.ta-dir-list li { padding:12px 0; border-bottom:1px solid var(--border); }
.leaflet-popup-content { font-size:0.9rem; }

/* Verzeichnis: Detail-Zeilen */
.ta-dir-type { display:inline-block; font-size:0.85rem; padding:2px 8px; border-radius:999px; background:var(--surface-2); border:1px solid var(--border); margin-right:6px; }
.ta-dir-fee { font-size:0.85rem; color:var(--text-muted); }
.ta-dir-hours { margin-top:6px; font-size:0.85rem; }
.ta-dir-hours summary { cursor:pointer; color:var(--accent); }

/* Warnbox (Aktivierung ohne E-Mail etc.) */
.ta-warnbox { background:#fff8e1; border:1px solid #ffe082; border-radius:8px; padding:12px 14px; margin:14px 0; font-size:0.9rem; }
:root[data-theme="dark"] .ta-warnbox { background:#332b00; border-color:#5a4a00; }

/* Statische Seiten + Footer-Links + Quill */
.ta-static-content { line-height:1.6; }
.ta-static-content h2 { margin-top:1.4em; }
.ta-footer-links { display:flex; gap:16px; margin-top:6px; }
.ta-footer-links a { color:var(--text-muted); font-size:0.85rem; }
.ta-quill { min-height:200px; background:var(--surface); margin-top:6px; }
.ta-pageform { border-bottom:1px solid var(--border); padding-bottom:20px; margin-bottom:20px; }
.ta-btn-small.ta-active { background:var(--accent); color:#fff; }

/* API-Doku */
.ta-apidoc pre { background:var(--surface-2); border:1px solid var(--border); border-radius:6px; padding:12px; overflow-x:auto; font-size:0.85rem; }
.ta-apidoc code { font-family:ui-monospace,Menlo,Consolas,monospace; }
.ta-apidoc h2 { margin-top:1.6em; border-top:1px solid var(--border); padding-top:0.8em; }
.ta-apidoc table { width:100%; border-collapse:collapse; }
.ta-apidoc table th, .ta-apidoc table td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--border); font-size:0.9rem; }

/* Header-Steuerelemente (Theme, später Sprache) */
.ta-header { display:flex; align-items:center; justify-content:center; position:relative; gap:16px; padding:14px 20px; }
.ta-logo { font-weight:700; font-size:1.2rem; }
.ta-controls { position:absolute; right:20px; top:50%; transform:translateY(-50%); display:flex; align-items:center; gap:8px; }
.ta-theme-toggle { background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:6px 10px; font-size:1rem; cursor:pointer; line-height:1; }
.ta-theme-toggle:hover { border-color:var(--accent); }

/* Sprachumschalter im Header */
.ta-lang-select { background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:6px 8px; font-size:0.9rem; color:var(--text); cursor:pointer; }
.ta-lang-select:hover { border-color:var(--accent); }
