/* ============================================================
   Weboberfläche Dokumenten-Parsing – Komponenten auf Basis der
   CDB-Design-Tokens (cdb/styles.css). Navy-Struktur, ein Orange-
   Akzent, Roboto, ruhige mechanische Bewegung.
   ============================================================ */

body.app { background: var(--surface-page); min-height: 100vh; }

/* ---- Kopfzeile (Navy-Chrome) ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-5);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-6);
  background: var(--gradient-canvas);
  color: var(--text-on-dark);
  border-bottom: 1px solid var(--border-on-dark);
}
.brand { display: flex; align-items: center; gap: var(--space-4); color: var(--text-on-dark); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; font-weight: var(--fw-bold); font-size: var(--fs-title); line-height: var(--lh-snug); }
.brand-eyebrow {
  font-size: var(--fs-xs); letter-spacing: var(--ls-eyebrow); text-transform: uppercase;
  color: var(--cdb-orange-bright); font-weight: var(--fw-bold);
}
.topnav { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; font-size: var(--fs-sm); }
.topnav a { color: var(--text-on-dark-muted); }
.topnav a:hover { color: var(--text-on-dark); text-decoration: none; }
.topnav form { margin: 0; }
.who { color: var(--text-on-dark); font-weight: var(--fw-medium); }

/* ---- Layout ---- */
.container { max-width: var(--container-max); margin: 0 auto; padding: var(--space-7) var(--space-6) var(--space-9); }
.page-head { margin-bottom: var(--space-6); }
.page-head h1 { margin: var(--space-2) 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--space-6); margin-bottom: var(--space-6); }
.stack { display: flex; flex-direction: column; gap: var(--space-5); }
.row { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: center; }
.row form { margin: 0; }
.narrow { max-width: 520px; }
.muted { color: var(--text-muted); }
.break { overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: center; color: var(--text-muted); font-size: var(--fs-sm); margin: var(--space-4) 0 0; }
.empty { color: var(--text-muted); padding: var(--space-6) 0; margin: 0; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Karten ---- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.card + .card { margin-top: var(--space-6); }
.grid-2 > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.card-head h2 { margin: 0; }
.card > p:first-of-type { margin-top: 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
  font: inherit; font-size: var(--fs-body); font-weight: var(--fw-medium);
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .tab:focus-visible, .choice input:focus-visible + .choice-body {
  outline: none; box-shadow: var(--shadow-focus);
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--text-on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface-card); color: var(--text-strong); border-color: var(--border-default); }
.btn-secondary:hover { background: var(--surface-sunken); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--cdb-danger); }
.btn-danger { background: var(--cdb-danger); color: var(--cdb-white); }
.btn-on-dark { background: rgba(255, 255, 255, 0.06); color: var(--text-on-dark); border-color: var(--border-on-dark); padding: 6px 14px; font-size: var(--fs-sm); }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.14); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }

/* ---- Formulare ---- */
.field { display: flex; flex-direction: column; gap: var(--space-3); border: 0; margin: 0; padding: 0; min-width: 0; }
.field-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-strong); padding: 0; }
.field-hint { font-size: var(--fs-sm); color: var(--text-muted); }
.input {
  font: inherit; color: var(--text-strong); background: var(--surface-card);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.input:hover { border-color: var(--border-strong); }
.input:focus-visible { border-color: var(--accent); }
.input-file { padding: 8px; }
.input-file::file-selector-button {
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); margin-right: var(--space-4);
  padding: 6px 12px; border-radius: var(--radius-xs); border: 1px solid var(--border-default);
  background: var(--surface-sunken); color: var(--text-strong); cursor: pointer;
}
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice-body {
  display: flex; flex-direction: column; gap: var(--space-1); height: 100%;
  padding: var(--space-4); border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.choice:hover .choice-body { border-color: var(--border-strong); }
.choice input:checked + .choice-body { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-title { font-weight: var(--fw-bold); color: var(--text-strong); }
.choice-meta { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---- Meldungen ---- */
.alert { padding: var(--space-4) var(--space-5); border-radius: var(--radius-sm); border: 1px solid; margin-bottom: var(--space-5); }
.alert-success { background: var(--cdb-success-tint); border-color: var(--cdb-success); color: var(--text-strong); }
.alert-danger { background: var(--cdb-danger-tint); border-color: var(--cdb-danger); color: var(--text-strong); }
.alert-info { background: var(--cdb-info-tint); border-color: var(--cdb-info); color: var(--text-strong); }

/* ---- Badges / Status ---- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
  background: var(--surface-sunken); color: var(--text-body);
}
.badge-success { background: var(--cdb-success-tint); color: var(--cdb-success); }
.badge-danger { background: var(--cdb-danger-tint); color: var(--cdb-danger); }
.badge-info { background: var(--cdb-info-tint); color: var(--cdb-info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.dot-pulse { background: var(--accent); animation: cdb-pulse 1.2s var(--ease-standard) infinite; }

/* ---- Verbrauch ---- */
.usage { margin: var(--space-5) 0; }
.usage-label { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--space-3); }
.usage-bar { appearance: none; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill); background: var(--surface-sunken); overflow: hidden; }
.usage-bar::-webkit-progress-bar { background: var(--surface-sunken); border-radius: var(--radius-pill); }
.usage-bar::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); }
.usage-bar::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-pill); }
.usage-bar.is-critical::-webkit-progress-value { background: var(--cdb-danger); }
.usage-bar.is-critical::-moz-progress-bar { background: var(--cdb-danger); }

/* ---- Tabelle ---- */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-6)); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--ls-caps);
  color: var(--text-muted); font-weight: var(--fw-bold);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle);
}
.table td { padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: var(--space-6); }
.table th:last-child, .table td:last-child { padding-right: var(--space-6); }
.table tbody tr:hover { background: var(--cdb-slate-50); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .file { font-weight: var(--fw-medium); color: var(--text-strong); max-width: 320px; overflow-wrap: anywhere; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; margin: 0; }

/* ---- Reiter + Ergebnis ---- */
.tabs-head { border-bottom: 1px solid var(--border-subtle); margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-6)) var(--space-5); padding: 0 var(--space-6) var(--space-3); }
.tabs { display: flex; gap: var(--space-5); }
.tab { color: var(--text-muted); font-weight: var(--fw-medium); padding: var(--space-3) 0; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text-strong); text-decoration: none; }
.tab.is-active { color: var(--text-strong); border-bottom-color: var(--accent); }
.result {
  margin: 0; padding: var(--space-5); max-height: 70vh; overflow: auto;
  background: var(--surface-sunken); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: var(--lh-normal);
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-strong);
}

/* ---- Anmeldung (dunkler CDB-Canvas mit Plexus) ---- */
body.login {
  min-height: 100vh; color: var(--text-on-dark);
  background: linear-gradient(180deg, rgba(0, 14, 34, 0.55), rgba(0, 14, 34, 0.92)),
    url("cdb/assets/backgrounds/cdb-plexus-hero.jpg") center / cover no-repeat, var(--cdb-navy-deep);
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); }
.login-card {
  width: 100%; max-width: 420px; padding: var(--space-7);
  background: rgba(4, 22, 43, 0.82); border: 1px solid var(--border-on-dark);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
}
.login-card .cdb-eyebrow { margin: var(--space-5) 0 var(--space-2); color: var(--cdb-orange-bright); }
.login-title {
  margin: 0; font-family: var(--font-display); font-weight: var(--fw-black); font-size: var(--fs-h3);
  letter-spacing: var(--ls-display); text-transform: uppercase; line-height: var(--lh-tight); color: var(--text-on-dark);
}
.login-lead { color: var(--text-on-dark-muted); margin: var(--space-4) 0 var(--space-6); }
.login .field-label { color: var(--text-on-dark); }
.login .input { background: rgba(255, 255, 255, 0.06); border-color: var(--border-on-dark); color: var(--text-on-dark); }
.login .input:focus-visible { border-color: var(--accent); }
.login .alert { color: var(--text-on-dark); background: rgba(255, 49, 49, 0.18); }

@media (prefers-reduced-motion: reduce) {
  .btn, .input, .choice-body { transition: none; }
  .dot-pulse { animation: none; }
}
@media (max-width: 640px) {
  .container { padding: var(--space-6) var(--space-5) var(--space-8); }
  .topbar { padding: var(--space-4) var(--space-5); }
  .card { padding: var(--space-5); }
  .table-wrap { margin: 0 calc(-1 * var(--space-5)); }
  .table th:first-child, .table td:first-child { padding-left: var(--space-5); }
}
