/* Shared design layer for the server-rendered internal admin panel
   (admin_dashboard/errors/security/messages/support-requests/outreach*.html).
   Loaded AFTER tokens.css on a page - tokens.css only carries the light-mode
   color variables + a couple of shared button/banner components with no
   font-family/body reset at all, which is why every admin page (not just
   Outreach) was rendering in the browser's bare default serif. This file
   adds: a real font stack, the color tokens tokens.css is missing (info/
   good/warning/critical), a manually-toggleable dark mode (same
   :root[data-theme]/prefers-color-scheme mechanism and localStorage key
   ("deskio_theme") the CRM's own frontend/src/hooks/useTheme.js uses - a
   toggle here and one in the CRM read/write the same key, same-origin, so
   the choice is consistent across both), and reusable card/badge/table/
   form-control components so individual admin pages don't have to hand-roll
   their own each time.

   Only linked from pages that opt in (currently every admin_*.html except
   admin_login.html's pre-auth screen, which still gets it too) - safe,
   doesn't touch tokens.css itself, which marketing/auth/legal pages also
   load and were never designed with this dark-mode block. */

:root {
  --info: #3b6ea5;
  --good: #0ca30c;
  --warning: #fab219;
  --warning-ink: #b3760b;
  --critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1b1e1b;
    --plane: #101210;
    --card: #1b1e1b;
    --ink: #f3f2ec;
    --ink-2: #cfccc0;
    --ink-muted: #8f8c7f;
    --border: rgba(255, 255, 255, 0.1);
    --grid: #2a2d29;
    --brand: #2fb887;
    --brand-2: #4fd3a3;
    --accent: #2fb887;
    --info: #5b93cc;
    --danger: #e2735a;
    --good: #3fca55;
    --warning: #e0a53a;
    --warning-ink: #e0a53a;
    --critical: #e2735a;
  }
}

/* Explicit toggle wins over the OS preference in both directions. */
:root[data-theme="dark"] {
  --surface: #1b1e1b;
  --plane: #101210;
  --card: #1b1e1b;
  --ink: #f3f2ec;
  --ink-2: #cfccc0;
  --ink-muted: #8f8c7f;
  --border: rgba(255, 255, 255, 0.1);
  --grid: #2a2d29;
  --brand: #2fb887;
  --brand-2: #4fd3a3;
  --accent: #2fb887;
  --info: #5b93cc;
  --danger: #e2735a;
  --good: #3fca55;
  --warning: #e0a53a;
  --warning-ink: #e0a53a;
  --critical: #e2735a;
}
:root[data-theme="light"] {
  --surface: #ffffff;
  --plane: #f6f5f2;
  --card: #ffffff;
  --ink: #14140f;
  --ink-2: #4a493f;
  --ink-muted: #85836f;
  --border: rgba(20, 20, 15, 0.11);
  --grid: #e6e4da;
  --brand: #0d3d34;
  --brand-2: #14524a;
  --accent: #1a8f6b;
  --info: #3b6ea5;
  --danger: #b8452f;
  --good: #0ca30c;
  --warning: #fab219;
  --warning-ink: #b3760b;
  --critical: #d03b3b;
}

* { box-sizing: border-box; }

body {
  padding: 32px 32px 60px;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--plane);
  color: var(--ink);
}

input, select, textarea, button { font-family: inherit; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 143, 107, 0.35);
}

h1 { font-size: 22px; margin: 0 0 4px; color: var(--ink); }
h2 { font-size: 16px; margin: 28px 0 10px; color: var(--ink); }
.subtitle { color: var(--ink-muted); font-size: 13.5px; margin-bottom: 20px; }

/* ---- Nav: brand mark + wordmark on the left (same logo the marketing site
   uses, so the admin panel doesn't look like an unrelated internal tool),
   underline-on-active link style, logout pinned to the far right. ---- */
nav.admin-nav {
  display: flex; gap: 20px; align-items: center; margin-bottom: 28px;
  border-bottom: 1px solid var(--border); padding-bottom: 14px; flex-wrap: wrap;
}
.admin-nav-brand {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
  color: var(--ink); text-decoration: none; margin-right: 4px;
}
.admin-nav-brand img { width: 24px; height: 24px; display: block; }
nav.admin-nav a:not(.admin-nav-brand) {
  font-size: 13.5px; text-decoration: none; color: var(--ink-muted);
  padding: 4px 0; border-bottom: 2px solid transparent; transition: color 0.15s ease, border-color 0.15s ease;
}
nav.admin-nav a:not(.admin-nav-brand):hover { color: var(--ink); }
nav.admin-nav a.active { color: var(--accent) !important; font-weight: 600; border-bottom-color: var(--accent); }
form.logout-form { margin-left: auto; }
form.logout-form button {
  background: none; border: none; color: var(--ink-muted); font-size: 13.5px;
  cursor: pointer; text-decoration: underline; padding: 0;
}
form.logout-form button:hover { color: var(--ink); }

.theme-toggle-btn {
  margin-left: auto; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer; padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle-btn:hover { border-color: var(--ink-muted); color: var(--ink); }
.theme-toggle-btn + form.logout-form { margin-left: 12px; }

.empty { padding: 30px 0; color: var(--ink-muted); font-size: 13.5px; }

/* ---- Form controls: shared select/text/email input + button look, used by
   every filter/source/send form on the admin pages instead of bare browser
   defaults. ---- */
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease;
}
.form-control:hover { border-color: var(--ink-muted); }
select.form-control { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; border: none; cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--brand-2); }
.btn-accent:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--ink-muted); }
.btn-outline:hover { background: var(--plane); border-color: var(--brand-2); color: var(--brand-2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: rgba(184, 69, 47, 0.08); }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

/* ---- Stat cards: bigger, color-coded, icon-carrying variant of the plain
   number tiles admin_outreach.html used to hand-roll. ---- */
.stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.stat-card {
  flex: 1; min-width: 140px;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
}
.stat-card-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-card-sent .stat-card-icon { background: rgba(12, 163, 12, 0.12); color: var(--good); }
.stat-card-dry .stat-card-icon { background: rgba(143, 140, 127, 0.14); color: var(--ink-muted); }
.stat-card-failed .stat-card-icon { background: rgba(216, 59, 47, 0.12); color: var(--danger); }
.stat-card-num { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--ink); }
.stat-card-label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Status pills - one shared component instead of each page inventing
   its own badge/status-badge variant. ---- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill-info { background: rgba(59, 110, 165, 0.12); color: var(--info); }
.pill-good { background: rgba(12, 163, 12, 0.12); color: var(--good); }
.pill-danger { background: rgba(216, 59, 47, 0.12); color: var(--danger); }
.pill-muted { background: rgba(143, 140, 127, 0.16); color: var(--ink-muted); }
.pill-warning { background: rgba(250, 178, 25, 0.16); color: var(--warning-ink); }

/* ---- Tables: horizontal-scroll wrapper (.table-scroll) so a wide table
   never breaks the page layout on a narrow viewport, plus a truncation
   utility for long free-text columns like a scraped business name. ---- */
.table-scroll { overflow-x: auto; margin-bottom: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--ink-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
tbody tr:hover { background: var(--plane); }
td.truncate {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
td.nowrap { white-space: nowrap; }

/* ---- Pagination: numbered page links (not just Previous/Next), same
   pattern search engines use - a page window around the current one plus
   the first/last, with an ellipsis for the gap. ---- */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; font-size: 13px; flex-wrap: wrap; }
.pagination a, .pagination span.disabled, .pagination span.page-num, .pagination span.page-ellipsis {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink);
}
.pagination a { border: 1px solid var(--border); }
.pagination a:hover { border-color: var(--ink-muted); }
.pagination span.disabled { border: 1px solid var(--border); color: var(--ink-muted); cursor: default; }
.pagination .page-num.active { background: var(--accent); color: #fff; font-weight: 600; }
.pagination .page-ellipsis { color: var(--ink-muted); padding: 6px 2px; }
