/* SFL Marketing Hub: shared styles for the dashboard and admin panel */

:root {
  color-scheme: light;
  /* SFL Tech brand (sfltech.ai) */
  --ink: #0a2d44;          /* headings, key numbers */
  --text: #1f2937;         /* body text */
  --steel: #6b7280;        /* secondary text */
  --muted: #9ca3af;
  --canvas: #f8f9fc;
  --paper: #ffffff;
  --rule: #e5e7eb;
  --rule-strong: #d1d5db;
  --hover: #f3f4f8;
  --pink: #e94d8b;         /* primary actions */
  --pink-ink: #ffffff;
  --navy: #2b6fc2;         /* links, focus, secondary accent */
  --navy-ink: #ffffff;
  --brand-gradient: linear-gradient(90deg, #e94d8b, #9b59b6, #3498db, #00d4ff);
  --grid-line: rgb(10 45 68 / 0.04);
  --good: #15803d;
  --bad: #c0392b;
  --warn-bg: #fdf2f7;
  --warn-ink: #8a1f4f;
  --focus: #3498db;
  --radius-sm: 6px;
  --radius: 16px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #eaf1f7;
    --text: #d4dce5;
    --steel: #9aa8b6;
    --muted: #6f7f8f;
    --canvas: #0a1621;
    --paper: #102030;
    --rule: #1d3042;
    --rule-strong: #2b4257;
    --hover: #16293b;
    --pink: #f0629a;
    --navy: #6fb3f2;
    --navy-ink: #0a1621;
    --grid-line: rgb(255 255 255 / 0.035);
    --good: #4ade80;
    --bad: #f87171;
    --warn-bg: #2a1420;
    --warn-ink: #f7a8c8;
    --focus: #6fb3f2;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--canvas);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

a { color: var(--navy); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button, select, input, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem clamp(1rem, 3vw, 2rem);
  background: var(--paper);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--brand-gradient);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-right: auto;
  text-decoration: none;
  color: inherit;
}
.brand img { display: block; height: 36px; width: auto; }
.brand-sub {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  padding-left: 0.85rem;
  border-left: 1px solid var(--rule);
}
@media (prefers-color-scheme: dark) {
  .brand img { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; height: 30px; }
}

.who {
  color: var(--steel);
  font-size: 0.85rem;
}

.period {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.updated {
  color: var(--steel);
  font-size: 0.85rem;
}

/* ---------- Controls ---------- */

.select, .input, .textarea {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  min-height: 2.4rem;
}
.textarea { width: 100%; min-height: 4.5rem; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.45rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--pink); border-color: var(--pink); color: var(--pink-ink); }
.btn-primary:hover { background: var(--pink); filter: brightness(1.06); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--steel); }
.btn-quiet:hover { color: var(--ink); }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  margin-top: 0;
  overflow-x: auto;
}

.tab {
  border: 0;
  background: none;
  padding: 0.75rem 0.9rem;
  border-bottom: 3px solid transparent;
  color: var(--steel);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--pink); }
.tab .count {
  display: inline-block;
  min-width: 1.4rem;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--pink);
  color: var(--pink-ink);
  font-size: 0.75rem;
  line-height: 1.4rem;
  text-align: center;
}
.tab .count:empty, .tab .count[data-zero] { display: none; }

/* ---------- Page layout ---------- */

main {
  padding: clamp(1rem, 3vw, 2rem);
  max-width: 1280px;
  margin: 0 auto;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.6rem);
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgb(10 45 68 / 0.04), 0 8px 24px -12px rgb(10 45 68 / 0.08);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--ink); letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }

.hint { color: var(--steel); font-size: 0.875rem; margin: 0.2rem 0 0; max-width: 70ch; }

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn-ink);
  margin-bottom: 1.25rem;
  font-size: 0.925rem;
}
.notice a { color: inherit; font-weight: 700; }

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--steel);
}
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 0.35rem; }

.error-box {
  padding: 1rem;
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: var(--radius);
  background: var(--paper);
  margin-bottom: 1.25rem;
}

/* ---------- Pillar marks ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
  background: var(--c, var(--muted));
  flex: none;
}
.pill.untagged { color: var(--steel); font-style: italic; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * clamp(1rem, 2.5vw, 1.5rem)); padding: 0 clamp(1rem, 2.5vw, 1.5rem); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.65rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th {
  font-weight: 600;
  color: var(--steel);
  font-size: 0.8rem;
  white-space: nowrap;
  border-bottom-color: var(--rule-strong);
}
th button {
  border: 0; background: none; padding: 0; color: inherit; font-weight: inherit; cursor: pointer;
}
th button:hover { color: var(--ink); }
th[aria-sort="ascending"] button::after { content: " ▲"; font-size: 0.65rem; }
th[aria-sort="descending"] button::after { content: " ▼"; font-size: 0.65rem; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--hover); }
.topic { max-width: 34ch; min-width: 22ch; }
td.nowrap { white-space: nowrap; }
.topic-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { color: var(--steel); font-size: 0.8rem; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  opacity: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: calc(100vw - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }
.toast:not(.error) { background: var(--ink); color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
