/* =========================================================================
   ServiceHub — Redesign: AUFTRÄGE (Liste + Kanban)
   ──────────────────────────────────────────────────────────────────────────
   REIN OPTISCH. Additive Schicht (lädt zuletzt → gewinnt die Kaskade).
   Re-tunt NUR die Auftrags-Oberfläche der internen App nach dem warmen
   Redesign-System (theme.css / sh-detail-drawer.css):
     · page-header / .sh-header / .sh-header__left / .sh-header__actions
     · Ansicht-Umschalter  .sh-view-toggle (Liste/Kanban)
     · Filter-Toolbar      .filter-toolbar.sh-toolbar + .sh-chips/.sh-chip
     · Aktive-Filter-Facetten  .sh-facets/.sh-facet/.sh-facet__x/.sh-facet-clear-all
     · Auftrags-Tabelle    .table-wrap.sh-panel (+ Gruppen-Zeilen, Leerzustand)
     · Kanban-Board        .sh-kanban-wrap[data-orders-board] → Spalten/Karten

   KEINE Funktions-/Markup-/Logik-Änderung. Es wird NICHTS versteckt, das eine
   Funktion trägt (Buttons/Felder/Tabs/Links/Zeilen bleiben) — nur Farbe,
   Schrift, Radius, Schatten, Abstand, Rahmen.

   Scope: Kanban-Regeln hängen an [data-orders-board] (NICHT an die globalen
   .sh-kanban*, die auch CRM/Support nutzen). Liste/Toolbar/Header werden über
   den Auftrags-Header-Kontext (.page-header + folgende .sh-toolbar/.table-wrap)
   gescoped. Drawer (sh-detail-drawer.css) wird NICHT angefasst.

   Tokens (warme Palette) sind lokal auf die Auftrags-Container gescoped →
   unabhängig von der Ladereihenfolge. Light + Dark ([data-theme="dark"]).
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Figtree:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ---------- Tokens (Light) — auf die Auftrags-Container gescoped ---------- */
.page-header.sh-header,
.filter-toolbar.sh-toolbar,
.sh-facets,
.table-wrap.sh-panel,
.sh-kanban-wrap[data-orders-board],
[data-orders-board] {
  --sho-accent: #E73D25;
  --sho-accent-700: #C5331E;
  --sho-accent-soft: #FCEDE7;
  --sho-accent-line: rgba(231, 61, 37, .22);
  --sho-honey: #D99A2B;
  --sho-honey-soft: #FBF0DA;
  --sho-ok: #16A34A;
  --sho-ok-soft: #E9F8EF;
  --sho-warn: #C7791A;
  --sho-warn-soft: #FBF1E0;
  --sho-info: #2F6BD6;
  --sho-info-soft: #EAF1FC;
  --sho-violet: #7C5BD6;
  --sho-violet-soft: #F0ECFB;

  --sho-bg: #FAF6F2;
  --sho-surface: #FFFFFF;
  --sho-surf-2: #F6F1EB;
  --sho-surf-3: #EFE8E0;
  --sho-field: #F6F1EB;

  --sho-ink: #231C17;
  --sho-text: #463D35;
  --sho-text-2: #6B6157;
  --sho-muted: #9A8F84;
  --sho-border: #EEE5DC;
  --sho-border-2: #E3D9CE;

  --sho-font-head: 'Space Grotesk', 'Figtree', system-ui, sans-serif;
  --sho-font-body: 'Figtree', system-ui, sans-serif;
  --sho-font-mono: 'Space Mono', ui-monospace, monospace;

  --sho-r-sm: 9px;
  --sho-r-md: 12px;
  --sho-r-lg: 16px;
  --sho-r-pill: 999px;

  --sho-sh-sm: 0 1px 2px rgba(120, 80, 50, .06);
  --sho-sh-md: 0 6px 20px rgba(120, 80, 50, .07), 0 1px 2px rgba(120, 80, 50, .05);
  --sho-sh-accent: 0 5px 14px rgba(231, 61, 37, .28);
  --sho-tr: .16s cubic-bezier(.2, .7, .3, 1);
}

/* ---------- Tokens (Dark) ---------- */
[data-theme="dark"] .page-header.sh-header,
[data-theme="dark"] .filter-toolbar.sh-toolbar,
[data-theme="dark"] .sh-facets,
[data-theme="dark"] .table-wrap.sh-panel,
[data-theme="dark"] .sh-kanban-wrap[data-orders-board],
[data-theme="dark"] [data-orders-board] {
  --sho-accent: #F2543B;
  --sho-accent-700: #E0432B;
  --sho-accent-soft: rgba(242, 84, 59, .16);
  --sho-accent-line: rgba(242, 84, 59, .30);
  --sho-honey: #E6AE4A;
  --sho-honey-soft: rgba(230, 174, 74, .16);
  --sho-ok: #3BC07A;
  --sho-ok-soft: rgba(59, 192, 122, .15);
  --sho-warn: #E5A33C;
  --sho-warn-soft: rgba(229, 163, 60, .15);
  --sho-info: #5C8FE8;
  --sho-info-soft: rgba(92, 143, 232, .16);
  --sho-violet: #9D82E6;
  --sho-violet-soft: rgba(157, 130, 230, .16);

  --sho-bg: #15120F;
  --sho-surface: #1E1A16;
  --sho-surf-2: #241F1A;
  --sho-surf-3: #2C2620;
  --sho-field: #241F1A;

  --sho-ink: #F6F1EC;
  --sho-text: #E2D8CE;
  --sho-text-2: #B3A99E;
  --sho-muted: #8C8175;
  --sho-border: #2E2822;
  --sho-border-2: #3A332B;

  --sho-sh-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --sho-sh-md: 0 6px 20px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .4);
  --sho-sh-accent: 0 5px 14px rgba(0, 0, 0, .5);
}

/* =========================================================================
   SEITENKOPF — "Interne Auftragsliste"
   (Scope: nur der Kopf, dessen Aktionen den Auftrags-Ansicht-Umschalter tragen)
   ========================================================================= */
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) {
  font-family: var(--sho-font-body);
  align-items: flex-start;
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) .sh-header__left h1 {
  font-family: var(--sho-font-head);
  color: var(--sho-ink);
  letter-spacing: -.015em;
  font-weight: 700;
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) .sh-header__context,
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) .subtitle {
  color: var(--sho-text-2);
}

/* =========================================================================
   ANSICHT-UMSCHALTER  ☰ / ▦  (Liste / Kanban)
   ========================================================================= */
.sh-view-toggle:has([data-orders-view-mode]) {
  border: 1px solid var(--sho-border-2);
  border-radius: var(--sho-r-sm);
  background: var(--sho-surface);
  box-shadow: var(--sho-sh-sm);
  overflow: hidden;
}
.sh-view-toggle:has([data-orders-view-mode]) button {
  color: var(--sho-text-2);
  font-family: var(--sho-font-body);
  transition: var(--sho-tr);
}
.sh-view-toggle:has([data-orders-view-mode]) button + button {
  border-left: 1px solid var(--sho-border-2);
}
.sh-view-toggle:has([data-orders-view-mode]) button:hover {
  background: var(--sho-accent-soft);
  color: var(--sho-accent);
}
.sh-view-toggle:has([data-orders-view-mode]) button.active {
  background: var(--sho-accent);
  color: #fff;
}

/* =========================================================================
   FILTER-TOOLBAR  (Chips + Status-/Operativ-Selects + Gruppieren)
   Scope: die Toolbar, die direkt auf den Auftrags-Header folgt.
   ========================================================================= */
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar {
  background: var(--sho-surface);
  border: 1px solid var(--sho-border);
  border-radius: var(--sho-r-md);
  box-shadow: var(--sho-sh-sm);
  font-family: var(--sho-font-body);
}

/* Filter-Chips (Pillen) */
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .sh-chip {
  background: var(--sho-surf-2);
  border: 1px solid var(--sho-border-2);
  color: var(--sho-text);
  border-radius: var(--sho-r-pill);
  font-weight: 600;
  transition: var(--sho-tr);
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .sh-chip:hover {
  border-color: var(--sho-accent);
  color: var(--sho-accent);
  background: var(--sho-accent-soft);
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .sh-chip.active,
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .sh-chip--active {
  background: var(--sho-accent);
  border-color: var(--sho-accent);
  color: #fff;
  box-shadow: var(--sho-sh-accent);
}

/* Selects (Status / Operative Sicht / Gruppieren) */
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .select {
  background: var(--sho-field);
  border: 1px solid var(--sho-border-2);
  color: var(--sho-text);
  border-radius: var(--sho-r-sm);
  font-family: var(--sho-font-body);
  transition: var(--sho-tr);
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .select:hover {
  border-color: var(--sho-border);
}
.page-header.sh-header:has(.sh-view-toggle [data-orders-view-mode]) + .filter-toolbar.sh-toolbar .select:focus {
  outline: none;
  border-color: var(--sho-accent);
  box-shadow: 0 0 0 3px var(--sho-accent-soft);
}

/* =========================================================================
   AKTIVE-FILTER-FACETTEN  ("Aktive Filter: Status: …  ×")
   Eindeutig der Auftrags-Container: #ordersFacets.
   ========================================================================= */
#ordersFacets.sh-facets {
  font-family: var(--sho-font-body);
}
#ordersFacets.sh-facets .sh-facets__label {
  color: var(--sho-muted);
  font-weight: 600;
}
#ordersFacets.sh-facets .sh-facet {
  background: var(--sho-accent-soft);
  border: 1px solid var(--sho-accent-line);
  color: var(--sho-accent-700);
  border-radius: var(--sho-r-pill);
}
#ordersFacets.sh-facets .sh-facet__k {
  font-weight: 700;
  color: var(--sho-accent);
}
#ordersFacets.sh-facets .sh-facet__x {
  color: var(--sho-accent-700);
  transition: var(--sho-tr);
}
#ordersFacets.sh-facets .sh-facet__x:hover {
  background: var(--sho-accent);
  color: #fff;
}
#ordersFacets.sh-facets .sh-facet-clear-all {
  color: var(--sho-muted);
}
#ordersFacets.sh-facets .sh-facet-clear-all:hover {
  color: var(--sho-accent);
}

/* =========================================================================
   AUFTRAGS-TABELLE  (Listenansicht)
   Scope: die Tabelle, die im Auftrags-Render direkt auf #ordersFacets folgt.
   (Greift auch nach der Batch-Leiste — :has() prüft den Inhalt der Tabelle.)
   ========================================================================= */
.table-wrap.sh-panel:has(tr[data-row-order-id]),
.table-wrap.sh-panel:has(#selectAllOrders) {
  background: var(--sho-surface);
  border: 1px solid var(--sho-border);
  border-radius: var(--sho-r-lg);
  box-shadow: var(--sho-sh-md);
  overflow: hidden;
  font-family: var(--sho-font-body);
}

/* Kopfzeile */
.table-wrap.sh-panel:has(tr[data-row-order-id]) thead th,
.table-wrap.sh-panel:has(#selectAllOrders) thead th {
  background: var(--sho-surf-2);
  color: var(--sho-text-2);
  border-bottom: 1px solid var(--sho-border-2);
  font-family: var(--sho-font-head);
  font-weight: 600;
  letter-spacing: .01em;
}

/* Datenzeilen */
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody td {
  color: var(--sho-text);
  border-bottom: 1px solid var(--sho-border);
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody tr[data-row-order-id] {
  transition: background var(--sho-tr);
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody tr[data-row-order-id]:hover td {
  background: var(--sho-accent-soft);
}

/* Auftragsnummer monospace + Zahl-Ästhetik */
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody tr[data-row-order-id] td:nth-child(3) {
  font-family: var(--sho-font-mono);
  color: var(--sho-ink);
  font-size: .92em;
}

/* Gruppen-Zeile (Gruppieren nach Status/Kunde) */
.table-wrap.sh-panel:has(tr[data-row-order-id]) tr.sh-group-row td,
.table-wrap.sh-panel:has(#selectAllOrders) tr.sh-group-row td {
  background: var(--sho-surf-2);
  color: var(--sho-text);
  border-top: 1px solid var(--sho-border-2);
  border-bottom: 1px solid var(--sho-border-2);
  font-family: var(--sho-font-head);
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tr.sh-group-row:hover td {
  background: var(--sho-surf-3);
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tr.sh-group-row .sh-group-count {
  background: var(--sho-accent-soft);
  color: var(--sho-accent-700);
  border-radius: var(--sho-r-pill);
  padding: 1px 9px;
  font-size: .78em;
  font-weight: 700;
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tr.sh-group-row .sh-group-caret {
  color: var(--sho-muted);
}

/* "Details"-Button in der Aktionsspalte — weiches Ghost-Pillen-Design */
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody tr[data-row-order-id] td .btn-ghost {
  border: 1px solid var(--sho-border-2);
  color: var(--sho-text);
  background: var(--sho-surface);
  border-radius: var(--sho-r-pill);
  transition: var(--sho-tr);
}
.table-wrap.sh-panel:has(tr[data-row-order-id]) tbody tr[data-row-order-id] td .btn-ghost:hover {
  border-color: var(--sho-accent);
  color: var(--sho-accent);
  background: var(--sho-accent-soft);
}

/* Leerzustand */
.table-wrap.sh-panel .sh-empty-state {
  color: var(--sho-text-2);
  font-family: var(--sho-font-body);
}
.table-wrap.sh-panel .sh-empty-state strong {
  color: var(--sho-ink);
  font-family: var(--sho-font-head);
}
.table-wrap.sh-panel .sh-empty-state__icon {
  filter: saturate(.9);
}

/* =========================================================================
   KANBAN-BOARD  (Auftrags-Pipeline je internem Status)
   Scope: streng auf [data-orders-board] (NICHT die globalen .sh-kanban*,
   die CRM-Opportunities & Support-Tickets ebenfalls verwenden).
   ========================================================================= */
.sh-kanban-wrap[data-orders-board] {
  font-family: var(--sho-font-body);
}
.sh-kanban-wrap[data-orders-board] .sh-kanban {
  padding-bottom: 14px;
}

/* Spalte als weiche Karte */
.sh-kanban-wrap[data-orders-board] .sh-kanban__col {
  background: var(--sho-surf-2);
  border: 1px solid var(--sho-border);
  border-radius: var(--sho-r-lg);
  box-shadow: var(--sho-sh-sm);
}

/* Spaltenkopf mit Akzent-Oberkante */
.sh-kanban-wrap[data-orders-board] .sh-kanban__col-head {
  background: var(--sho-surface);
  border-bottom: 1px solid var(--sho-border);
  border-top: 3px solid var(--sho-muted);
  border-radius: var(--sho-r-lg) var(--sho-r-lg) 0 0;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--info    .sh-kanban__col-head { border-top-color: var(--sho-info); }
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--warning .sh-kanban__col-head { border-top-color: var(--sho-honey); }
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--success .sh-kanban__col-head { border-top-color: var(--sho-ok); }
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--danger  .sh-kanban__col-head { border-top-color: var(--sho-accent); }
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--neutral .sh-kanban__col-head { border-top-color: var(--sho-muted); }

.sh-kanban-wrap[data-orders-board] .sh-kanban__col-title {
  font-family: var(--sho-font-head);
  color: var(--sho-ink);
  font-weight: 700;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__col-meta {
  font-family: var(--sho-font-mono);
  color: var(--sho-muted);
  background: var(--sho-surf-2);
  border-radius: var(--sho-r-pill);
  padding: 1px 8px;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__col-empty {
  color: var(--sho-muted);
}

/* Karte */
.sh-kanban-wrap[data-orders-board] .sh-kanban__card {
  background: var(--sho-surface);
  border: 1px solid var(--sho-border);
  border-radius: var(--sho-r-md);
  box-shadow: var(--sho-sh-sm);
  color: var(--sho-text);
  transition: var(--sho-tr);
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card:hover {
  border-color: var(--sho-accent-line);
  box-shadow: var(--sho-sh-md);
  transform: translateY(-1px);
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card--dragging {
  box-shadow: var(--sho-sh-accent);
  border-color: var(--sho-accent);
  opacity: .92;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card-no {
  font-family: var(--sho-font-mono);
  color: var(--sho-muted);
  font-size: .82em;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card-title {
  font-family: var(--sho-font-head);
  color: var(--sho-ink);
  font-weight: 600;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card-customer {
  color: var(--sho-text-2);
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__card-date {
  color: var(--sho-muted);
  font-size: .82em;
}

/* Drop-Ziel beim Ziehen einer Karte zwischen Spalten */
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--drop {
  outline: 2px dashed var(--sho-accent);
  outline-offset: -2px;
}
.sh-kanban-wrap[data-orders-board] .sh-kanban__col--drop .sh-kanban__col-body {
  background: var(--sho-accent-soft);
}

/* =========================================================================
   FALLBACK ohne :has()  (sehr alte Browser)
   Ein paar konservative Grundtöne, damit die Auftrags-Flächen warm wirken,
   selbst wenn die :has()-Scopes oben nicht greifen. Nichts versteckt.
   ========================================================================= */
@supports not (selector(:has(*))) {
  #ordersFacets.sh-facets .sh-facet {
    background: var(--sho-accent-soft);
    border: 1px solid var(--sho-accent-line);
    color: var(--sho-accent-700);
  }
  .sh-kanban-wrap[data-orders-board] .sh-kanban__col {
    background: var(--sho-surf-2);
    border: 1px solid var(--sho-border);
    border-radius: var(--sho-r-lg);
  }
  .sh-kanban-wrap[data-orders-board] .sh-kanban__card {
    background: var(--sho-surface);
    border: 1px solid var(--sho-border);
    border-radius: var(--sho-r-md);
  }
}
