/*
 * theme.css — Vertan CRM design values.
 * Corporate + Swiss: small corners, hairline rules, one working colour (teal)
 * used for exactly one job — the accent. Everything else is neutral.
 */

:root {
  --canvas: #f7f7f5;
  --surface: #fbfbfb;
  --surface-2: #eef0ee;
  --border: #e1e3e0;
  --border-strong: #c6c9c5;
  --ink: #14181c;
  --muted: #66686a;

  --accent: #1d6f5c;
  --accent-hover: #175a4a;
  --accent-ink: #ffffff;
  --accent-text: #1d6f5c;
  --accent-strong: #175a4a;
  --accent-soft: #e3f1ec;
  --accent-border: #b9d9cd;

  --success: #1a8a51;
  --success-ink: #ffffff;
  --success-soft: #e2f3e7;
  --success-strong: #146b3f;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #f6ead9;
  --warning-strong: #92420b;
  --danger: #b8362c;
  --danger-ink: #ffffff;
  --danger-soft: #fbe5e3;
  --danger-strong: #94271f;

  --chart-1: #1d6f5c;
  --chart-2: #2f6f9e;
  --chart-3: #b45309;
  --chart-4: #7c3f8a;
  --chart-5: #b8362c;
  --chart-6: #66686a;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.01em;
  --eyebrow-tracking: 0.04em;

  --radius-btn: 6px;
  --radius-card: 8px;
  --radius-input: 6px;
  --border-w: 1px;
  --border-strong-w: 1px;
  --btn-weight: 600;
  --card-pad: 1.25rem;
}

html[data-theme="dark"] {
  --canvas: #12161a;
  --surface: #191e23;
  --surface-2: #1f2529;
  --border: #2a3136;
  --border-strong: #3d454b;
  --ink: #eef1f0;
  --muted: #9aa2a2;

  --accent: #2f9478;
  --accent-hover: #3aa989;
  --accent-ink: #06231c;
  --accent-text: #52c4a2;
  --accent-strong: #5fcda9;
  --accent-soft: #16352c;
  --accent-border: #2f5f4e;

  --success: #3fae74;
  --success-ink: #06231c;
  --success-soft: #173525;
  --success-strong: #74d19d;
  --warning: #d98a3d;
  --warning-ink: #241505;
  --warning-soft: #392713;
  --warning-strong: #eab06a;
  --danger: #dd6a5f;
  --danger-ink: #260907;
  --danger-soft: #391b18;
  --danger-strong: #ef958b;

  --chart-1: #4fbb9a;
  --chart-2: #6fa8d8;
  --chart-3: #eab06a;
  --chart-4: #bd8fca;
  --chart-5: #ef958b;
  --chart-6: #9aa2a2;
}

/*
 * app.css — Vertan CRM's own stylesheet. The app shell (rail, topbar, mobile
 * drawer), the data screens (table header caps, the lead-score bar, the
 * pipeline board, the activity timeline) and nothing a utility already
 * covers. Tokens only — every colour here is a var() from theme.css.
 */

/* ---- App shell ------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset-block: 0;
  left: 0;
  width: 232px;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: var(--border-w, 1px) solid var(--border);
  transition: width 150ms var(--ease);
}
html[data-rail="collapsed"] .sidebar { width: 72px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  height: 4rem;
  padding-inline: 1.25rem;
  border-bottom: var(--border-w, 1px) solid var(--border);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-brand-mark { color: var(--accent); flex-shrink: 0; }
html[data-rail="collapsed"] .sidebar-brand-name { display: none; }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 2.5rem;
  padding-inline: 0.75rem;
  border-radius: var(--radius-btn, 6px);
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-strong); border-left-color: var(--accent); font-weight: 600; }
.nav-item-label { overflow: hidden; text-overflow: ellipsis; }
html[data-rail="collapsed"] .nav-item { justify-content: center; padding-inline: 0; }
html[data-rail="collapsed"] .nav-item-label { display: none; }

.sidebar-collapse {
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  height: 2.75rem;
  margin: 0.5rem;
  border-radius: var(--radius-btn, 6px);
  color: var(--muted);
  border: var(--border-w, 1px) solid var(--border);
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-collapse svg { transition: transform 150ms var(--ease); }
html[data-rail="collapsed"] .sidebar-collapse svg { transform: rotate(180deg); }

.scrim { display: none; }

.content-pane {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 232px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 150ms var(--ease);
}
html[data-rail="collapsed"] .content-pane { margin-left: 72px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 4rem;
  padding-inline: 1.5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: var(--border-w, 1px) solid var(--border);
  flex-shrink: 0;
}
.page-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; flex: 1 1 auto; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-shrink: 0; }
.rail-burger { display: none; }

.content-main { flex: 1 1 auto; padding: 1.5rem; max-width: 100%; min-width: 0; }
@media (min-width: 768px) { .content-main { padding: 2rem; } }

@media (min-width: 1024px) {
  .sidebar-collapse { display: flex; }
}

@media (max-width: 1023.98px) {
  .sidebar { transform: translateX(-100%); transition: transform 220ms var(--ease-out); width: 232px !important; box-shadow: none; }
  html[data-rail="collapsed"] .sidebar-brand-name,
  html[data-rail="collapsed"] .nav-item-label { display: flex; }
  html[data-rail="collapsed"] .nav-item { justify-content: flex-start; padding-inline: 0.75rem; }
  .navopen:checked ~ .app-shell .sidebar { transform: translateX(0); box-shadow: var(--shadow-raised); }
  .content-pane { margin-left: 0 !important; }
  .rail-burger { display: inline-flex; }
  .scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: color-mix(in srgb, var(--ink) 45%, transparent);
  }
  .navopen:checked ~ .app-shell .scrim { display: block; }
}

/* ---- Data-table conventions -------------------------------------------- */
.crm-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.6875rem;
}
.crm-table td, .crm-table th { vertical-align: middle; }
.crm-table tbody tr.is-selected { background: var(--accent-soft); }
.contact-name-link { font-weight: 600; color: var(--ink); }
.contact-name-link:hover { color: var(--accent-text); text-decoration: none; }

/* ---- Lead score bar: ink, through teal, to ember — never stars. -------- */
.score-bar { display: flex; align-items: center; gap: 3px; width: 9rem; }
.score-seg { height: 6px; flex: 1 1 0; border-radius: 2px; background: var(--border); }
.score-seg.is-filled:nth-child(-n+3) { background: var(--muted); }
.score-seg.is-filled:nth-child(n+4):nth-child(-n+7) { background: var(--accent); }
.score-seg.is-filled:nth-child(n+8) { background: var(--warning); }

/* ---- Activity timeline -------------------------------------------------- */
.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before { content: ""; position: absolute; left: 0.5rem; top: 0.35rem; bottom: 0.35rem; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.283rem;
  top: 0.375rem;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface);
}

/* ---- Sales pipeline board ------------------------------------------------ */
.pipeline-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; }
.pipeline-col {
  flex: 0 0 19rem;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: var(--border-w, 1px) solid var(--border);
  border-radius: var(--radius-card, 8px);
  max-height: calc(100vh - 12rem);
}
.pipeline-col-head { padding: 0.875rem 1rem; border-bottom: var(--border-w, 1px) solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.pipeline-col-body { padding: 0.625rem; display: flex; flex-direction: column; gap: 0.625rem; overflow-y: auto; }
.pipeline-card { background: var(--surface); border: var(--border-w, 1px) solid var(--border); border-radius: var(--radius-card, 8px); padding: 0.875rem; }

/* ---- Chart frame --------------------------------------------------------- */
.chart { position: relative; height: 16rem; }
.chart-sm { height: 10rem; }

/* ---- Filter builder rows -------------------------------------------------- */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.625rem 0; border-bottom: var(--border-w, 1px) solid var(--border); }
.filter-row:last-child { border-bottom: none; }
.filter-row > .select, .filter-row > .input { width: auto; flex: 1 1 9rem; }

/* An input group with a leading search icon needs its own left padding. */
.search-field { position: relative; }
.search-field .icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field .input { padding-left: 2.25rem; }
