/* Client portal theme — mirrors Warmbly's dashboard chrome and components.
   Tokens, densities and component shapes are taken from Warmbly's web app
   (web/src/global.css, components/layout, components/ui) so the portal reads
   as the same product. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/static/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --radius: 0.5rem;
  --background: #ffffff;
  --foreground: oklch(0.15 0.01 260);
  --muted: oklch(0.97 0.003 260);
  --muted-foreground: oklch(0.55 0.01 260);
  --border: oklch(0.92 0.005 260);
  --chrome: #f5f6f8;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-900: #0f172a;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  --chart-1: oklch(0.55 0.15 250);
  --chart-2: oklch(0.60 0.12 160);
  --chart-3: oklch(0.50 0.14 300);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--chrome);
  color: var(--foreground);
  font-family: "Inter Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted-foreground); margin: 0; }

/* --- sky chrome ------------------------------------------------------------ */

.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--chrome);
}
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50% 50% 18% 18%;
  filter: blur(60px);
}
.cloud.c1 { top: -80px; left: -60px; width: 520px; height: 240px; opacity: 0.7; }
.cloud.c2 { top: 10%; right: 8%; width: 380px; height: 180px; opacity: 0.55; }
.cloud.c3 { top: 32%; left: 26%; width: 300px; height: 140px; opacity: 0.45; }

/* --- shell ----------------------------------------------------------------- */

.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-zone {
  width: 256px;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.logo { width: 22px; height: 22px; color: var(--slate-900); }
.logo-name { font-weight: 650; font-size: 14.5px; letter-spacing: -0.01em; color: var(--slate-900); }
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--slate-600);
  font-size: 13px;
}
.crumb-sep { width: 14px; height: 14px; color: var(--slate-400); flex-shrink: 0; }
.crumb-section { color: var(--slate-900); font-weight: 500; }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 18px;
}
.user-email { color: var(--slate-500); font-size: 12px; }

.shell-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* --- sidebar --------------------------------------------------------------- */

.sidebar {
  width: 256px;
  flex-shrink: 0;
  padding: 4px 0 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.nav-section { padding: 0 0 2px; }
.nav-section + .nav-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(226, 232, 240, 0.5); }
.nav-label {
  margin: 0 12px 4px;
  padding: 0 9px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate-400);
}
.nav-row {
  margin: 0 12px;
  height: 32px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 12.5px;
  color: var(--slate-600);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-row:hover { background: rgba(226, 232, 240, 0.4); color: var(--slate-900); }
.nav-row.active { background: rgba(226, 232, 240, 0.7); color: var(--slate-900); font-weight: 500; }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* --- content panel --------------------------------------------------------- */

.panel {
  flex: 1;
  min-width: 0;
  background: #ffffff;
  border-top: 1px solid rgba(226, 232, 240, 0.7);
  border-left: 1px solid rgba(226, 232, 240, 0.7);
  border-top-left-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel-scroll { flex: 1; overflow-y: auto; }

/* --- page topbar ----------------------------------------------------------- */

.page-topbar {
  min-height: 48px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate-400);
  font-weight: 500;
  white-space: nowrap;
}
.topbar-divider { width: 1px; height: 16px; background: #e2e8f0; }
.subtitle { font-size: 12.5px; color: var(--slate-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* --- stat strip ------------------------------------------------------------ */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .stat-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.stat {
  padding: 12px 16px 14px;
  border-right: 1px solid #e2e8f0;
}
.stat:last-child, .stat:nth-child(2n) { border-right: none; }
@media (min-width: 768px) {
  .stat:nth-child(2n) { border-right: 1px solid #e2e8f0; }
  .stat:last-child { border-right: none; }
}
.stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate-400);
  font-weight: 500;
}
.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 300;
  color: var(--slate-900);
  line-height: 1;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  display: block;
  font-size: 10px;
  color: var(--slate-400);
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

/* --- buttons and inputs ---------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  height: 36px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-default { background: #18181b; color: #ffffff; }
.btn-default:hover { background: #27272a; }
.btn-outline { background: #ffffff; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: rgba(244, 245, 247, 0.6); }
.btn-sky { background: var(--sky-600); color: #ffffff; }
.btn-sky:hover { background: var(--sky-700); }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: rgba(226, 232, 240, 0.5); color: var(--slate-900); }

.input {
  height: 36px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--foreground);
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible { outline: none; border-color: var(--slate-400); box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.25); }
.input-sm { height: 28px; font-size: 12px; padding: 0 9px; border-radius: 6px; }
.filters input[type="text"] { width: 170px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--slate-500); font-size: 12px; white-space: nowrap; }

/* --- tables ---------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; caption-side: bottom; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted-foreground);
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: #fbfbfc;
  white-space: nowrap;
}
.table td { padding: 11px 20px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(244, 245, 247, 0.6); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--muted-foreground); padding: 28px; }

/* --- badges ---------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--muted);
  color: var(--muted-foreground);
  white-space: nowrap;
}
.pill-active { background: #e0f2fe; color: #075985; }
.pill-draft { background: #f1f5f9; color: #475569; }
.pill-paused, .pill-paused_no_accounts, .pill-paused_trial_expired { background: #fef3c7; color: #92400e; }
.pill-completed { background: #e0e7ff; color: #3730a3; }

/* --- inbox list ------------------------------------------------------------ */

.list { display: flex; flex-direction: column; }
.thread-row {
  display: flex;
  gap: 10px;
  padding: 12px 20px 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
  transition: background-color 0.12s ease;
}
.thread-row:last-child { border-bottom: none; }
.thread-row:hover { background: rgba(244, 245, 247, 0.6); }
.dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; background: transparent; flex: 0 0 7px; }
.thread-row.unread .dot { background: var(--sky-600); }
.thread-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.thread-top { display: flex; justify-content: space-between; gap: 12px; }
.thread-from { font-size: 13.5px; color: var(--slate-900); }
.thread-row.unread .thread-from, .thread-row.unread .thread-subject { font-weight: 600; }
.thread-date, .thread-meta { color: var(--muted-foreground); font-size: 12px; white-space: nowrap; }
.thread-subject { color: var(--slate-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-snippet { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.pager { padding: 14px 20px; }

/* --- thread ---------------------------------------------------------------- */

.thread { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.message { border: 1px solid var(--border); border-radius: var(--radius); background: #ffffff; padding: 16px; }
.message-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.message-head strong { font-weight: 600; color: var(--slate-900); }
.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--slate-700);
}
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--slate-500); font-size: 12px; }
.back-link:hover { color: var(--slate-900); }

/* --- campaigns ------------------------------------------------------------- */

.panel-body { padding: 0 0 40px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 8px;
}
.section-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--slate-400);
}
.count { color: var(--muted-foreground); font-size: 12px; }
.folder-block + .folder-block { margin-top: 8px; }

/* --- campaign detail ------------------------------------------------------- */

.card { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); }
.chart-card { margin: 16px 20px; padding: 16px; }
.chart-card h2 { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.chart-card canvas { width: 100% !important; max-height: 280px; }
.engagement { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; padding: 0 20px 20px; }
.engagement .card { padding: 14px; }
.engagement h2 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* --- banners and empty states ---------------------------------------------- */

.banner { margin: 14px 20px; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; }
.banner-warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.banner-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.empty { padding: 28px 20px; color: var(--muted-foreground); text-align: center; }
.empty.big { padding: 48px 20px; }
.empty p { margin: 0 0 14px; }

/* --- login ----------------------------------------------------------------- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  position: relative;
  width: 100%;
  max-width: 384px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -12px rgba(16, 24, 40, 0.12);
  padding: 28px;
  margin: 20px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-card h1 { font-size: 17px; font-weight: 600; }
.login-card > .muted { margin: 4px 0 18px; font-size: 13px; }
.login-card .banner { margin: 0 0 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--slate-600); }
.login-form .btn { margin-top: 6px; width: 100%; }

/* --- responsive ------------------------------------------------------------ */

@media (max-width: 767px) {
  .logo-zone { width: auto; padding: 0 14px; }
  .crumb-org, .crumb-sep { display: none; }
  .user-email { display: none; }
  .sidebar {
    width: auto;
    flex-direction: row;
    padding: 6px 8px;
    gap: 4px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
  }
  .shell-body { flex-direction: column; }
  .nav-section { padding: 0; }
  .nav-section + .nav-section { margin: 0; padding: 0; border: none; }
  .nav-label { display: none; }
  .nav-row { margin: 0; height: 34px; }
  .panel { border-left: none; border-top-left-radius: 0; }
  .page-topbar { padding: 8px 14px; min-height: 48px; }
  .filters input[type="text"] { width: 100%; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-right: 1px solid #e2e8f0; }
  .stat:nth-child(2n) { border-right: none; }
}
