/* ─────────────────────────────────────────────────────────────────
   domains-page-v2.css — Domains page Vercel-style chrome (Section 1).
   INBOX-179 Strangler Fig migration · 2026-05-01
   Mockup: design-mockups/domains-v2.html

   This file scopes V2 chrome ONLY for the page header + action row of
   /domains. It uses page-prefixed class names (`.dom-*`) so it cannot
   collide with the legacy `.list-filters` / `.page-header` styles in
   the inline <style> block. The legacy block still loads — but every
   element migrated here uses dom-* selectors and inherits no legacy
   chrome.

   Section 1 scope (this file):
     - Page header (title + subtitle)
     - Action row (search + sort + count + Add Domain CTA)
   Out of scope (Section 2+):
     - Domain list rows (.domain-card)
     - Sidebar plan card (INBOX-180)
     - Contextual upgrade nudges (INBOX-181)

   Design tokens reused from existing :root in domains.html — the live
   page already declares --bg, --surface, --border, --text, --accent.
   We add a couple of Vercel-flavour neutrals via CSS variables here.
   ───────────────────────────────────────────────────────────────── */

/* Vercel-leaning neutrals layered on top of the page's existing :root.
   We don't re-declare --bg etc. — the live page owns those. We DO add
   stronger fg tokens that better match Vercel's text hierarchy. */
:root {
  --dom-fg-1: #171717;
  --dom-fg-2: #404040;
  --dom-fg-3: #666666;
  --dom-fg-4: #888888;
  --dom-border-strong: #d4d4d8;
}

/* ─── Page header (title + subtitle) ─── */
.dom-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.dom-page-header-left {
  min-width: 0;
  flex: 1;
}

.dom-page-title {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.1;
  color: var(--text);
  margin: 0 0 6px;
}

.dom-page-subtitle {
  font-size: 15px;
  color: var(--dom-fg-3);
  font-weight: 400;
  letter-spacing: -0.005em;
  margin: 0;
}

/* ─── Action row (search + sort + count + Add Domain) ────────────────
   Replaces the old `.list-filters` div. Search and sort sit on the left
   with the count immediately after them; Add Domain CTA pinned to the
   right. Wraps under the search on narrow screens.

   Critical: the entire action row sits ON THE SAME LINE — Vinoop's
   feedback was that splitting search+sort onto one row and the CTA
   onto another felt fragmented. ─────────────────────────────────── */
.dom-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.dom-action-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.dom-action-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search input — Vercel pill. Uses the existing #domain-search ID
   so applyDomainFilters() keeps reading it the same way. */
.dom-search-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--dom-border-strong);
  border-radius: 8px;
  flex: 1;
  max-width: 360px;
  min-width: 240px;
  transition: border-color 100ms ease;
}
.dom-search-input:focus-within {
  border-color: var(--text);
}
.dom-search-input svg {
  color: var(--dom-fg-3);
  flex-shrink: 0;
}
.dom-search-input input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  letter-spacing: -0.005em;
}
.dom-search-input input::placeholder {
  color: var(--dom-fg-4);
}

/* Sort select — real <select> styled to match Vercel pill button.
   Keeps id="domain-sort" so the existing onchange handler binds. */
.dom-sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 36px;
  padding: 0 32px 0 12px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 10px center;
  border: 1px solid var(--dom-border-strong);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.005em;
  transition: border-color 100ms ease;
}
.dom-sort-select:hover { border-color: var(--text); }
.dom-sort-select:focus { outline: none; border-color: var(--text); }

/* Result count — sits right after search/sort on the left side. */
.dom-row-count {
  font-size: 13px;
  color: var(--dom-fg-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dom-row-count .filter-clear {
  margin-left: 8px;
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.dom-row-count .filter-clear:hover { text-decoration: underline; }

/* Add Domain CTA — black Vercel primary button, pinned to right edge. */
.dom-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 8px;
  color: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, transform 50ms ease;
  font-family: inherit;
  letter-spacing: -0.005em;
}
.dom-add-btn:hover {
  background: var(--dom-fg-1);
  border-color: var(--dom-fg-1);
}
.dom-add-btn:active { transform: scale(0.98); }
.dom-add-btn svg { color: var(--surface); }

/* ──────────────────────────────────────────────────────────────────
   SECTION 2 — Domain list (connected strip + pills + scores)
   INBOX-179 §2 · 2026-05-01

   Pattern: one outer card with internal dividers — reads as a single
   object instead of N independent cards (the legacy `.domain-card`
   pattern). Each row is hover-liftable and click-through to /domains/X.
   ────────────────────────────────────────────────────────────────── */

.dom-domains-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

/* Row — flex layout: icon | info | status-cell | score | remove */
.dom-domain-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 100ms ease;
  cursor: pointer;
}
.dom-domain-row:last-child { border-bottom: none; }
.dom-domain-row:hover { background: var(--surface-2); }

.dom-domain-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--dom-fg-3);
}

.dom-domain-info { flex: 1; min-width: 0; }
.dom-domain-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dom-domain-meta {
  font-size: 12px;
  color: var(--dom-fg-3);
  font-variant-numeric: tabular-nums;
}

/* Status-cell wrapper — fixed 110px so all pills line up at the same
   left edge regardless of pill text length. Without this, "Healthy"
   (72px) and "Scanning…" (100px) start at different x positions. */
.dom-domain-status-cell {
  width: 110px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* Status pill vocabulary:
     default (no modifier) → green Healthy
     .warn                 → amber Warnings
     .danger               → red Critical
     .pending              → zinc Scanning…  (animated dot)
     .failed               → zinc Scan failed (steady dot, deferred)
   Empty-state colour rule: null/pending → muted zinc, NEVER red. */
.dom-domain-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  flex-shrink: 0;
}
.dom-domain-status .dom-ind {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.dom-domain-status.warn { background: var(--yellow-bg); color: var(--yellow); }
.dom-domain-status.warn .dom-ind { background: var(--yellow); }
.dom-domain-status.danger { background: var(--red-bg); color: var(--red); }
.dom-domain-status.danger .dom-ind { background: var(--red); }

/* Pending / Failed — muted zinc, no semantic colour */
.dom-domain-status.pending,
.dom-domain-status.failed {
  background: var(--surface-2);
  color: var(--dom-fg-3);
}
.dom-domain-status.pending .dom-ind {
  background: var(--dom-fg-4);
  animation: dom-pulse-dot 1.4s ease-in-out infinite;
}
.dom-domain-status.failed .dom-ind { background: var(--dom-fg-4); }
@keyframes dom-pulse-dot {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

/* Score — right-aligned, tabular numerals so 88 / 100 / — all align. */
.dom-domain-score {
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
  font-family: 'Geist Mono', monospace;
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dom-domain-score.warn { color: var(--yellow); }
.dom-domain-score.danger { color: var(--red); }
.dom-domain-score.muted { color: var(--dom-fg-4); font-weight: 500; }

/* Remove button — appears only on row hover. Much less aggressive
   than the legacy always-red Remove button on every row. */
.dom-domain-action {
  background: transparent;
  border: none;
  color: var(--dom-fg-3);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  transition: color 100ms ease, background 100ms ease, opacity 100ms ease;
  flex-shrink: 0;
  opacity: 0;
}
.dom-domain-row:hover .dom-domain-action { opacity: 1; }
.dom-domain-action:hover { color: var(--red); background: var(--red-bg); }

/* Empty state — dashed border card when 0 domains. */
.dom-empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
}
.dom-empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.015em;
}
.dom-empty-state-sub {
  font-size: 13px;
  color: var(--dom-fg-2);
  margin-bottom: 18px;
}

/* Mobile responsive (≤640px): collapse status-cell, push remove to row corner */
@media (max-width: 640px) {
  .dom-domain-row {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .dom-domain-info { flex: 1 1 100%; }
  .dom-domain-status-cell { width: auto; }
  .dom-domain-action { opacity: 1; }  /* always visible on touch */
}

/* ──────────────────────────────────────────────────────────────────
   SECTION 3 — Sidebar shell + page header actions
   INBOX-179 §3 · 2026-05-01

   Removes the legacy topnav. Brand moves into the sidebar top. User
   name + Log Out + mobile toggle move into the page-header right.
   Sidebar nav uses SVG icons (was emoji) and a grey active state
   (was purple-soft + purple border-left).

   Sidebar markup uses `.dom-sidebar` (no legacy `.sidebar` class) so
   the inline `.sidebar { background: ... }` rules in the <style> block
   no longer apply. JS toggleSidebar() updated to use the new class.

   Plan-badge bottom-left is kept for now — replaced by the sidebar
   plan card in INBOX-180 (with backend wiring + Free/Pro variants).
   ────────────────────────────────────────────────────────────────── */

/* Override legacy .main height: was calc(100vh - 53px) accounting for
   the now-removed 53px topnav. Without this override, content cuts off
   53px early. Source-order win — this file loads after inline <style>. */
.main {
  max-height: 100vh;
}

/* INBOX-219: .dom-sidebar / .dom-sidebar-brand / .dom-nav-item /
   .dom-sidebar-footer rules removed — Domains markup migrated to
   canonical .sidebar / .brand / .sidebar-nav. Rules now live in
   static/css/app-chrome.css and apply to all 8 pages. */

/* Page header actions — right side of the page header. Holds the
   user name, Log Out button, and on mobile the sidebar toggle. */
.dom-page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.dom-user-name {
  font-size: 13px;
  color: var(--dom-fg-2);
}
.dom-logout-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--dom-fg-2);
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 100ms ease, color 100ms ease, background 100ms ease;
}
.dom-logout-btn:hover {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-2);
}
.dom-mobile-toggle {
  display: none;             /* hidden on desktop */
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--dom-fg-2);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
  align-items: center;
  justify-content: center;
}
.dom-mobile-toggle:hover { color: var(--text); border-color: var(--text); }

/* Theme toggle button — sun/moon icon, swaps on data-theme attribute. */
.dom-theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--dom-fg-2);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}
.dom-theme-toggle:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--surface-2);
}
/* Default (light): show moon, hide sun.
   Dark: hide moon, show sun.
   Avoid `:not([data-theme="dark"])` — it matches every ancestor that
   isn't the html element, so moon stays visible even in dark mode. */
.dom-theme-toggle .icon-moon { display: block; }
.dom-theme-toggle .icon-sun  { display: none; }
html[data-theme="dark"] .dom-theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .dom-theme-toggle .icon-sun  { display: block; }

/* ──────────────────────────────────────────────────────────────────
   DARK MODE — token overrides for /domains page.
   INBOX-179 §3 polish · 2026-05-01

   Override the legacy :root tokens when data-theme="dark" is set on
   the <html> element (the early-hydrate script in <head> sets it
   there before body parses, killing FOUC).

   Specificity gotcha: legacy inline <style> has `:root { ... }` which
   loads AFTER our V2 <link>. Plain `:root` and `[data-theme="dark"]`
   both have specificity (0,0,1,0) — equal — so the legacy wins by
   source order. We use `html[data-theme="dark"]` (specificity 0,0,1,1)
   to guarantee our overrides beat the legacy `:root` regardless of
   load order.
   ────────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #000000;
  --surface: #0f0f0f;
  --surface-2: #1a1a1a;
  --surface-3: #262626;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --text-muted: #a1a1a1;
  --text-subtle: #888888;

  /* Status soft backgrounds — low-alpha for dark surface legibility */
  --green: #4ade80;
  --green-bg: rgba(38, 217, 120, 0.12);
  --yellow: #f5b342;
  --yellow-bg: rgba(245, 166, 35, 0.12);
  --orange: #f5a623;
  --orange-bg: rgba(245, 166, 35, 0.10);
  --red: #f87171;
  --red-bg: rgba(229, 72, 77, 0.12);

  --accent: #3291ff;
  --accent-hover: #59a7ff;
  --accent-soft: rgba(50, 145, 255, 0.10);
  --accent-glow: rgba(50, 145, 255, 0.18);

  /* Override the page-prefixed neutrals declared at top of this file */
  --dom-fg-1: #ededed;
  --dom-fg-2: #a1a1a1;
  --dom-fg-3: #888888;
  --dom-fg-4: #666666;
  --dom-border-strong: rgba(255, 255, 255, 0.16);
}

/* Smooth theme transitions on body so flipping doesn't jolt */
body { transition: background 200ms ease, color 200ms ease; }

/* ─── Mobile responsive (≤768px) ─── */
@media (max-width: 768px) {
  .dom-page-header { flex-direction: column; gap: 12px; }
  .dom-page-title { font-size: 26px; }
  .dom-action-row { gap: 10px; }
  .dom-action-row-left { width: 100%; }
  .dom-action-row-right { width: 100%; }
  .dom-add-btn { width: 100%; justify-content: center; }
  .dom-search-input { max-width: none; }

  /* Show mobile toggle, drawer behaviour for sidebar */
  .dom-mobile-toggle { display: inline-flex; }
  .dom-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 20;
    transition: left 0.3s;
    width: 260px;
  }
  .dom-sidebar.open { left: 0; }
}
