/* ==========================================================================
   SHARED DARK MODE for the user site-dashboard (.main-panel content).
   Applies when the user's theme is dark: body[data-background-color="dark"].
   One place that darkens every dashboard sub-page (Payments, Analytics, Blog,
   AI Docs, Product Management, …) instead of theming each file separately.

   - Flips every page's --*-bg / --*-card / --*-ink … token set to dark, so any
     token-based surface follows automatically.
   - Darkens the common hardcoded-white surfaces by their shared naming
     patterns (cards / papers / panels / modals / tables / inputs).
   - The chat lives in .vai inside .main-panel and has its OWN theme, so every
     rule excludes .vai.
   ========================================================================== */

/* ── Token sets → dark (per-page prefixes) ───────────────────────────────── */
body[data-background-color="dark"] .main-panel,
body[data-background-color="dark"] .pay-page,
body[data-background-color="dark"] .an-page,
body[data-background-color="dark"] .bm-page,
body[data-background-color="dark"] .ed-page,
body[data-background-color="dark"] .ar-page {
  --pay-bg:#000000; --pay-card:#000000; --pay-ink:#ffffff; --pay-ink-2:#e5e5e5; --pay-muted:#cfcfcf; --pay-border:#262626; --pay-divider:#1f1f1f;
  --an-bg:#000000;  --an-card:#000000;  --an-ink:#ffffff;  --an-ink-2:#e5e5e5;  --an-muted:#cfcfcf;  --an-border:#262626;  --an-divider:#1f1f1f;
  --bm-bg:#000000;  --bm-card:#000000;  --bm-ink:#ffffff;  --bm-ink-2:#e5e5e5;  --bm-muted:#cfcfcf;  --bm-border:#262626;  --bm-divider:#1f1f1f;
  --ed-bg:#000000;  --ed-card:#000000;  --ed-ink:#ffffff;  --ed-ink-2:#e5e5e5;  --ed-muted:#cfcfcf;  --ed-border:#262626;  --ed-divider:#1f1f1f;
  --ar-bg:#000000;  --ar-card:#000000;  --ar-ink:#ffffff;  --ar-muted:#cfcfcf;  --ar-border:#262626;
}

/* Shell stays black across SPA swaps (per-page <style> is removed on nav).
   Match both <html> and <body> — some navigations stamp only one. */
html[data-background-color="dark"] .main-panel,
html[data-background-color="dark"] .main-panel > .content,
html[data-background-color="dark"] .page-inner,
html[data-background-color="dark"] #vn-spa-content,
body[data-background-color="dark"] .main-panel,
body[data-background-color="dark"] .main-panel > .content,
body[data-background-color="dark"] .page-inner,
body[data-background-color="dark"] #vn-spa-content {
  background: #000000 !important;
  background-color: #000000 !important;
}

/* Product pages (Templates / Freelancer / Property / Games) — same black
   surfaces even if that page's own stylesheet has not landed yet. */
html[data-background-color="dark"] .vai-mkt,
body[data-background-color="dark"] .vai-mkt {
  --vai-mkt-bg: #000000;
  --vai-mkt-surface: #000000;
  --vai-mkt-surface-2: #000000;
  --vai-mkt-surface-3: #111111;
}
html[data-background-color="dark"] .vai-mkt,
html[data-background-color="dark"] .vai-mkt__detail,
html[data-background-color="dark"] .vai-mkt__detail-head,
html[data-background-color="dark"] .vai-mkt__detail-body,
html[data-background-color="dark"] .vai-mkt__detail-foot,
html[data-background-color="dark"] .vai-mkt__panel,
html[data-background-color="dark"] .vai-mkt-card,
html[data-background-color="dark"] .vai-mkt__chip,
html[data-background-color="dark"] .vai-mkt__search-input,
html[data-background-color="dark"] .vai-mkt__topbar,
html[data-background-color="dark"] .vai-mkt__filters,
body[data-background-color="dark"] .vai-mkt-card,
body[data-background-color="dark"] .vai-mkt__chip,
body[data-background-color="dark"] .vai-mkt__search-input,
body[data-background-color="dark"] .vai-mkt__topbar,
body[data-background-color="dark"] .vai-mkt__filters {
  background: #000000 !important;
  background-color: #000000 !important;
}
html[data-background-color="dark"] .vai-mkt-d__frame iframe,
body[data-background-color="dark"] .vai-mkt-d__frame iframe {
  background: #09090b !important;
}

/* ── Common white surfaces → pure black (skip anything inside the chat) ───── */
body[data-background-color="dark"] .main-panel :is(
  .card, .card-body, .card-header, .card-footer,
  .panel, .panel-body,
  [class*="-card"], [class*="-paper"], [class*="-panel"], [class*="-modal"],
  [class*="-empty"], [class*="-sheet"]
):not([class*="vai"]):not([class*="kb-modal"]) {
  background: #000000 !important;
  border-color: #262626 !important;
  color: #eaeaea;
}

/* Tables */
body[data-background-color="dark"] .main-panel table:not([class*="vai"]) { color: #e5e5e5; }
body[data-background-color="dark"] .main-panel thead th:not([class*="vai"]),
body[data-background-color="dark"] .main-panel [class*="-table"] thead th {
  background: #0a0a0a !important; color: #cfcfcf !important; border-color: #1f1f1f !important;
}
body[data-background-color="dark"] .main-panel tbody td:not([class*="vai"]) { border-color: #1a1a1a !important; }

/* Form controls */
body[data-background-color="dark"] .main-panel :is(input, select, textarea):not([class*="vai"]):not([class*="kb-modal"]):not([class*="pf"]):not([type="checkbox"]):not([type="radio"]) {
  background: #000000 !important; border-color: #2a2a2a !important; color: #ededed !important;
}
body[data-background-color="dark"] .main-panel :is(input, textarea)::placeholder { color: #7a7a7a !important; }

/* Headings + body text → light (leave coloured/brand text alone) */
body[data-background-color="dark"] .main-panel :is(h1, h2, h3, h4, h5):not([class*="vai"]) { color: #ffffff; }

/* Dropdowns / menus that float over dark content */
body[data-background-color="dark"] .main-panel .dropdown-menu:not([class*="vai"]) {
  background: #0a0a0a !important; border-color: #262626 !important; color: #e5e5e5;
}
body[data-background-color="dark"] .main-panel .dropdown-item:not([class*="vai"]) { color: #e5e5e5 !important; }
body[data-background-color="dark"] .main-panel .dropdown-item:hover:not([class*="vai"]) { background: rgba(255,255,255,0.06) !important; }

/* Brain "Add a source" search: do not paint the field black — let the modal
   slate show through. Loaded last in <head>, so this has to live here. */
body[data-background-color="dark"] .main-panel .kb-modal__search,
body[data-background-color="dark"] .main-panel .kb-modal__find {
  background: transparent !important;
  background-color: transparent !important;
  border-color: transparent !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  box-shadow: none !important;
}
body[data-background-color="dark"] .main-panel .kb-modal__search {
  box-shadow: inset 0 0 0 1px rgba(148,170,200,.22) !important;
}
