/* Komponenten: Buttons, Formulare, Karten, Pills, Chips, Meldungen, Tabellen, Menüs */

/* ---------- Icons ---------- */
.icon { width: 16px; height: 16px; stroke-width: 2; }
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 24px; height: 24px; stroke-width: 1.75; }
.icon--spin { animation: s-spin 1.1s linear infinite; }
@keyframes s-spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-space-2);
  height: 36px; padding: 0 var(--s-space-4);
  border: 1px solid var(--s-border); border-radius: var(--s-radius);
  background: var(--s-surface); color: var(--s-text);
  font-size: var(--s-text-sm); font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--s-shadow-xs);
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}
.btn:hover { background: var(--s-surface-2); border-color: var(--s-border-strong); color: var(--s-text); }
.btn:focus-visible { outline: none; border-color: var(--s-accent); box-shadow: 0 0 0 4px var(--s-ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn .icon { color: var(--s-icon); }
.btn:hover .icon { color: currentColor; }

.btn--primary {
  background: var(--s-primary-grad); border-color: var(--s-primary-border); color: var(--s-on-accent);
  box-shadow: var(--s-shadow-btn);
}
.btn--primary:hover { background: var(--s-primary-grad-hover); border-color: var(--s-primary-border-hover); color: var(--s-on-accent); }
.btn--primary .icon, .btn--primary:hover .icon { color: currentColor; }

.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--s-text-2); }
.btn--ghost:hover { background: var(--s-surface-2); border-color: transparent; color: var(--s-text); }

.btn--danger { background: var(--s-danger-bg); border-color: var(--s-danger-bg); color: var(--s-on-danger); }
.btn--danger:hover { background: var(--s-danger-bg-hover); border-color: var(--s-danger-bg-hover); color: var(--s-on-danger); }
.btn--danger .icon, .btn--danger:hover .icon { color: currentColor; }
/* Zurückhaltend: rote Schrift, erst beim Überfahren rot hinterlegt */
.btn--danger-soft { color: var(--s-danger); }
.btn--danger-soft .icon { color: currentColor; }
.btn--danger-soft:hover { background: var(--s-danger-soft); border-color: var(--s-danger-border); color: var(--s-danger); }

.btn--sm { height: 32px; padding: 0 var(--s-space-3); font-size: var(--s-text-sm); gap: var(--s-space-2); }
.btn--lg { height: 42px; padding: 0 var(--s-space-4); font-size: var(--s-text-base); font-weight: 600; border-radius: var(--s-radius-lg); }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }

/* button_to rendert ein eigenes <form> – soll sich wie ein Button im Fluss verhalten */
form.button_to { display: inline-flex; margin: 0; }

.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-space-2); }

/* ---------- Formulare ---------- */
.field { display: grid; gap: var(--s-space-2); }
.field + .field { margin-top: var(--s-space-4); }
.label { font-size: var(--s-text-sm); font-weight: 600; color: var(--s-text); }
.label .muted { font-weight: 400; }
.hint { font-size: var(--s-text-sm); color: var(--s-text-3); }

.input,
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="url"], input[type="number"], textarea, select {
  width: 100%; min-height: 36px; padding: var(--s-space-2) var(--s-space-3);
  border: 1px solid var(--s-border); border-radius: var(--s-radius);
  background: var(--s-surface); color: var(--s-text);
  font-size: var(--s-text-base); line-height: 1.4;
  box-shadow: var(--s-shadow-xs);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input:hover, input:hover, textarea:hover, select:hover { border-color: var(--s-border-strong); }
.input:focus, input:focus, textarea:focus, select:focus,
.input:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--s-accent); box-shadow: 0 0 0 4px var(--s-ring); border-radius: var(--s-radius);
}
::placeholder { color: var(--s-text-3); opacity: 1; }
.input--lg { min-height: 42px; border-radius: var(--s-radius-lg); padding: var(--s-space-3) var(--s-space-4); }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* Optisch 16 px, mit Rand 24 px Trefferfläche (WCAG 2.5.8, UX-Re-Audit M4) */
.checkbox { display: inline-flex; align-items: center; gap: var(--s-space-1); min-height: 24px; font-size: var(--s-text-sm); color: var(--s-text-2); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin: var(--s-space-1); flex: none; accent-color: var(--s-accent); }

/* Suchfeld mit Icon links */
.search-field { position: relative; flex: 1 1 280px; min-width: 0; }
.search-field__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--s-text-3); pointer-events: none; }
.search-field input { padding-left: var(--s-space-6); min-height: 40px; border-radius: var(--s-radius-lg); }
/* Hilfe-Knopf rechts im Feld (B5.4): das Feld behält auf dem Handy die volle Breite */
.search-field--with-help input { padding-right: calc(var(--s-touch) + var(--s-space-1)); }
.search-field--with-help .search-help .search-help__toggle {
  position: absolute; top: 50%; right: var(--s-space-1); transform: translateY(-50%);
  width: 36px; height: 36px; border-color: transparent; background: transparent; box-shadow: none;
}
.search-field--with-help .search-help .search-help__toggle:hover { background: var(--s-surface-2); }
/* Ring wie .btn:focus-visible – die Regel oben ist spezifischer und hat ihn sonst geschluckt */
.search-field--with-help .search-help .search-help__toggle:focus-visible { border-color: var(--s-accent); box-shadow: 0 0 0 4px var(--s-ring); }

/* Datei-Feld im Shiori-Stil statt „Choose File“ (B5.4): Label als Knopf, Dateiname daneben.
   Das echte Feld bleibt fokussierbar und für Screenreader da, nur unsichtbar. */
.file-field { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-space-2) var(--s-space-3); min-width: 0; cursor: pointer; }
.file-field__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-field__button { pointer-events: none; }
.file-field__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--s-text-2); font-size: var(--s-text-sm); }
.file-field:hover .file-field__button { background: var(--s-surface-2); border-color: var(--s-border-strong); }
.file-field:focus-within .file-field__button { border-color: var(--s-accent); box-shadow: 0 0 0 4px var(--s-ring); }
.file-field--chosen .file-field__name { color: var(--s-text); font-weight: 500; }

/* ---------- Karten ---------- */
.card {
  background: var(--s-surface); border: 1px solid var(--s-border);
  border-radius: var(--s-radius-lg); box-shadow: var(--s-shadow-xs);
}
.card--pad { padding: var(--s-space-5); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-space-3); padding: var(--s-space-4) var(--s-space-5); border-bottom: 1px solid var(--s-border); }
.card__body { padding: var(--s-space-5); }

/* ---------- Status-Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--s-space-2);
  height: 22px; padding: 0 var(--s-space-3) 0 var(--s-space-2); border-radius: var(--s-radius-pill);
  font-size: var(--s-text-xs); font-weight: 600; line-height: 1; white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--pending    { background: var(--s-surface-2); color: var(--s-text-2); border-color: var(--s-border); }
.pill--processing { background: var(--s-warning-soft); color: var(--s-warning); border-color: var(--s-warning-border); }
.pill--processing::before { animation: s-pulse 1.4s ease-in-out infinite; }
.pill--processed  { background: var(--s-success-soft); color: var(--s-success); border-color: var(--s-success-border); }
.pill--failed     { background: var(--s-danger-soft); color: var(--s-danger); border-color: var(--s-danger-border); }
.pill--quarantine { background: var(--s-danger-soft); color: var(--s-danger); border-color: var(--s-danger-border); border-style: dashed; }
@keyframes s-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- Tag-Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-space-2);
  height: 30px; padding: 0 var(--s-space-3); border-radius: var(--s-radius-pill);
  border: 1px solid var(--s-border); background: var(--s-surface);
  color: var(--s-text-2); font-size: var(--s-text-sm); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
a.chip:hover { background: var(--s-surface-2); border-color: var(--s-border-strong); color: var(--s-text); }
.chip--active, a.chip--active:hover { background: var(--s-accent-soft); border-color: var(--s-accent-border); color: var(--s-accent-text); font-weight: 600; }
.chip__count {
  min-width: 20px; height: 18px; padding: 0 var(--s-space-2); border-radius: var(--s-radius-pill);
  display: inline-grid; place-items: center;
  background: var(--s-surface-2); color: var(--s-text-3); font-size: var(--s-text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip--active .chip__count { background: var(--s-surface); color: var(--s-accent-text); }
.chip--sm { height: 22px; padding: 0 var(--s-space-2); font-size: var(--s-text-xs); gap: var(--s-space-1); background: var(--s-surface-2); border-color: transparent; }
.chip--sm .icon { width: 12px; height: 12px; color: var(--s-text-3); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--s-ring); border-color: var(--s-accent); border-radius: var(--s-radius-pill); }

/* ---------- Hinweise im Inhalt (Banner) ---------- */
.alert {
  display: flex; gap: var(--s-space-3); align-items: flex-start;
  padding: var(--s-space-3) var(--s-space-4); border-radius: var(--s-radius-lg);
  border: 1px solid var(--s-border); background: var(--s-surface-2); color: var(--s-text);
  font-size: var(--s-text-sm);
}
.alert > .icon { margin-top: 2px; }
.alert strong { font-weight: 600; }
.alert--success { background: var(--s-success-soft); border-color: var(--s-success-border); }
.alert--success > .icon { color: var(--s-success); }
.alert--danger  { background: var(--s-danger-soft); border-color: var(--s-danger-border); }
.alert--danger > .icon { color: var(--s-danger); }
.alert--warning { background: var(--s-warning-soft); border-color: var(--s-warning-border); }
.alert--warning > .icon { color: var(--s-warning); }
.alert--info    { background: var(--s-accent-soft); border-color: var(--s-accent-border); }
.alert--info > .icon { color: var(--s-accent); }
.alert__body { display: grid; gap: var(--s-space-1); min-width: 0; }

/* ---------- Toasts: dunkle Pille, Status nur über die Icon-Farbe (wie Musubi) ---------- */
.toasts {
  position: fixed; z-index: 60; right: 16px; bottom: 16px;
  display: grid; gap: var(--s-space-2); width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-space-3);
  padding: var(--s-space-3) var(--s-space-3) var(--s-space-3) var(--s-space-4); border-radius: var(--s-radius-lg);
  background: var(--s-toast-bg); color: var(--s-toast-text);
  box-shadow: var(--s-shadow-toast);
  font-size: var(--s-text-sm); line-height: 1.45;
  animation: s-toast-in .22s ease-out;
}
.toast > .icon { margin-top: 1px; }
.toast--notice > .icon { color: var(--s-toast-success); }
.toast--alert > .icon  { color: var(--s-toast-danger); }
.toast__text { flex: 1; min-width: 0; padding-top: 1px; }
.toast__close {
  display: grid; place-items: center; width: 24px; height: 24px; margin: -2px 0;
  border: 0; border-radius: var(--s-radius-sm); background: transparent; color: var(--s-toast-muted); cursor: pointer;
}
.toast__close:hover { background: var(--s-toast-hover); color: var(--s-toast-text); }
.toast__close:focus-visible { outline: 2px solid var(--s-toast-accent); outline-offset: 1px; }
.toast__text a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.toast__text a:focus-visible { outline: 2px solid var(--s-toast-accent); outline-offset: 1px; border-radius: 2px; }
.toast__list { margin: var(--s-space-2) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s-space-1); }
.toast__file { color: var(--s-toast-muted); overflow-wrap: anywhere; }
@keyframes s-toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Tabellen (luftig) ---------- */
/* position: relative hält auch visuell versteckte Kopfzellen (sr-only) im Scroll-Bereich (UX-Re-Audit M1) */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--s-border); border-radius: var(--s-radius-lg); background: var(--s-surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--s-text-sm); }
.table th {
  padding: var(--s-space-3) var(--s-space-4); text-align: left; white-space: nowrap;
  font-size: var(--s-text-sm); font-weight: 500; color: var(--s-text-3);
  border-bottom: 1px solid var(--s-border); background: var(--s-surface);
}
.table td { padding: var(--s-space-3) var(--s-space-4); height: 52px; vertical-align: middle; color: var(--s-text-2); border-bottom: 1px solid var(--s-border-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover td { background: var(--s-row-hover); }
.table td.strong, .table td strong { color: var(--s-text); font-weight: 500; }
.table--dense td { height: 44px; padding-top: var(--s-space-2); padding-bottom: var(--s-space-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }

/* ---------- Leere Zustände mit Maskottchen ---------- */
.empty {
  display: grid; justify-items: center; gap: var(--s-space-2); text-align: center;
  padding: var(--s-space-7) var(--s-space-5); border: 1px dashed var(--s-border); border-radius: var(--s-radius-xl);
}
.empty__art { width: 168px; height: 136px; margin-bottom: var(--s-space-3); }
.empty__title { font-family: var(--s-font-head); font-weight: 800; font-size: var(--s-text-xl); color: var(--s-text); }
.empty__text { color: var(--s-text-2); max-width: 46ch; }
.empty .btn-row { margin-top: var(--s-space-4); justify-content: center; }
.empty--compact { padding: var(--s-space-6) var(--s-space-5); }
.empty--compact .empty__art { width: 120px; height: 98px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-space-2); margin-top: var(--s-space-5); flex-wrap: wrap; }
.pagination a, .pagination span[aria-disabled], .pagination .pagination__item {
  display: inline-flex; align-items: center; gap: var(--s-space-2); height: 36px; padding: 0 var(--s-space-4);
  border: 1px solid var(--s-border); border-radius: var(--s-radius);
  background: var(--s-surface); color: var(--s-text); font-size: var(--s-text-sm); font-weight: 500;
  box-shadow: var(--s-shadow-xs); text-decoration: none;
}
.pagination a:hover { background: var(--s-surface-2); border-color: var(--s-border-strong); }
.pagination a:focus-visible { outline: none; border-color: var(--s-accent); box-shadow: 0 0 0 4px var(--s-ring); }
.pagination span[aria-disabled], .pagination .disabled { opacity: .5; box-shadow: none; }
.pagination .pagination__info, .pagination p { color: var(--s-text-3); font-size: var(--s-text-sm); padding: 0 var(--s-space-2); }

/* ---------- Dropdown-Menü (Disclosure) ---------- */
.menu { position: relative; }
.menu__panel {
  position: absolute; z-index: 50; min-width: 220px;
  padding: var(--s-space-2); border: 1px solid var(--s-border); border-radius: var(--s-radius-lg);
  background: var(--s-raised); box-shadow: var(--s-shadow-pop);
}
.menu__panel--up { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu__panel--down { top: calc(100% + 6px); right: 0; }
.menu__label { padding: var(--s-space-2) var(--s-space-3) var(--s-space-1); font-size: var(--s-text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--s-text-3); }
.menu__item {
  display: flex; align-items: center; gap: var(--s-space-3); width: 100%;
  padding: var(--s-space-2) var(--s-space-3); border: 0; border-radius: var(--s-radius-sm);
  background: transparent; color: var(--s-text); font-size: var(--s-text-sm); text-align: left; cursor: pointer; text-decoration: none;
}
.menu__item .icon { color: var(--s-icon); }
.menu__item:hover, .menu__item:focus-visible { background: var(--s-raised-hover); color: var(--s-text); outline: none; }
.menu__divider { height: 1px; margin: var(--s-space-2) calc(var(--s-space-2) * -1); background: var(--s-border); }
.menu form.button_to { display: block; }

/* ---------- Segment-Schalter (Theme, Ansicht) ---------- */
.segmented { display: inline-flex; padding: var(--s-space-1); gap: 2px; border-radius: var(--s-radius-lg); background: var(--s-surface-2); border: 1px solid var(--s-border); }
.segmented__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-space-2);
  height: 28px; min-width: 30px; padding: 0 var(--s-space-2); border: 0; border-radius: var(--s-radius);
  background: transparent; color: var(--s-text-3); font-size: var(--s-text-sm); font-weight: 500; cursor: pointer;
}
.segmented__btn:hover { color: var(--s-text); }
.segmented__btn[aria-pressed="true"], .segmented__btn[aria-current="page"] { background: var(--s-seg-active); color: var(--s-text); box-shadow: var(--s-shadow-sm); }
.segmented__btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--s-ring); }
.segmented--full { display: flex; }
.segmented--full .segmented__btn { flex: 1; }

/* ---------- Kleinkram ---------- */
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 var(--s-space-1); border: 1px solid var(--s-border); border-bottom-width: 2px; border-radius: var(--s-radius-sm); font-size: var(--s-text-xs); color: var(--s-text-3); background: var(--s-surface); }
.code-block {
  padding: var(--s-space-3) var(--s-space-4); border-radius: var(--s-radius); background: var(--s-surface-2);
  border: 1px solid var(--s-border); color: var(--s-text); font-size: var(--s-text-sm); line-height: 1.6; overflow-x: auto;
}
.secret-value { word-break: break-all; font-family: var(--s-font-mono); font-size: var(--s-text-sm); }

/* Buttons/Links mit hidden-Attribut (z.B. „Zu den Dokumenten“ nach dem Upload) wirklich ausblenden */
.menu__kbd { margin-left: auto; }

/* ---------- Dialog (natives <dialog>, z.B. Tastenkürzel) ---------- */
.dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--s-border); border-radius: var(--s-radius-xl);
  background: var(--s-surface); color: var(--s-text); box-shadow: var(--s-shadow-dlg);
}
.dialog::backdrop { background: var(--s-backdrop); }
.dialog[open] { animation: s-dialog-in .16s ease-out; }
.dialog__body { padding: var(--s-space-4) var(--s-space-5) var(--s-space-5); display: grid; gap: var(--s-space-4); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-space-3); }
.dialog__title { display: flex; align-items: center; gap: var(--s-space-2); font-family: var(--s-font-head); font-weight: 800; font-size: var(--s-text-lg); }
.dialog__title .icon { color: var(--s-accent); }
.dialog__note { font-size: var(--s-text-sm); color: var(--s-text-3); }
@keyframes s-dialog-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.shortcut-list { display: grid; gap: 2px; margin: 0; }
.shortcut-list > div { display: flex; align-items: center; gap: var(--s-space-3); padding: var(--s-space-2) 0; border-bottom: 1px solid var(--s-border-soft); font-size: var(--s-text-sm); }
.shortcut-list > div:last-child { border-bottom: 0; }
.shortcut-list dt { flex: 0 0 120px; display: flex; align-items: center; gap: var(--s-space-1); font-size: var(--s-text-xs); }
.shortcut-list dd { margin: 0; color: var(--s-text-2); }

/* ---------- Fortschrittsbalken ---------- */
.progress { appearance: none; display: block; width: 100%; height: 4px; border: 0; border-radius: var(--s-radius-pill); background: var(--s-surface-3); overflow: hidden; }
.progress::-webkit-progress-bar { background: var(--s-surface-3); border-radius: var(--s-radius-pill); }
.progress::-webkit-progress-value { background: var(--s-accent); border-radius: var(--s-radius-pill); transition: width .2s; }
.progress::-moz-progress-bar { background: var(--s-accent); border-radius: var(--s-radius-pill); }

/* Link mitten im Text: unterstrichen, nicht nur farbig (WCAG 1.4.1, axe link-in-text-block) */
.text-link { color: var(--s-accent-text); text-decoration: underline; text-underline-offset: 2px; }
