/* ─────────────────────────────────────────────────────────────────────────
 * PRISM — Universal Design System
 *
 * One file, every page. Every operator-facing module loads this BEFORE its
 * own page styles. Page-specific CSS only adds — it never overrides tokens.
 *
 * Architecture rules:
 *   1. All color, type, spacing comes from --tokens defined in :root
 *   2. Components are .prism-* classed; their internals follow BEM-ish naming
 *   3. Mobile-first: base styles work at 375px; media queries expand upward
 *   4. No magic numbers in components — only --tokens
 *
 * Pair with prism-shared.js (which renders the header + Herb pill globally).
 * ─────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* ── Color: surfaces ────────────────────────────────────────── */
  --bg:           #050811;            /* deepest, page background */
  --bg-1:         #0a0e1c;            /* one step up */
  --surface:      rgba(18, 22, 40, 0.85);  /* card/panel base */
  --surface-2:    rgba(28, 32, 52, 0.65);  /* nested card */
  --surface-3:    rgba(40, 44, 70, 0.45);  /* hover/active */
  --glass:        rgba(10, 14, 28, 0.72);  /* glass for headers, modals */
  --border:       rgba(255, 255, 255, 0.08);
  --border-strong:rgba(255, 255, 255, 0.16);

  /* ── Color: brand ──────────────────────────────────────────── */
  --amber:        #F59E0B;            /* primary brand */
  --amber-2:      #FCD34D;            /* lighter amber */
  --amber-d:      #B45309;            /* darker amber */
  --amber-glow:   rgba(245, 158, 11, 0.35);

  --cyan:         #00D4FF;            /* secondary accent */
  --cyan-d:       #0891B2;
  --cyan-glow:    rgba(0, 212, 255, 0.30);

  --purple:       #8B5CF6;            /* tertiary, used for emphasis */
  --magenta:      #EC4899;

  /* ── Color: semantic ───────────────────────────────────────── */
  --success:      #10B981;
  --warn:         #F59E0B;
  --danger:       #EF4444;
  --info:         #3B82F6;

  /* ── Color: text ───────────────────────────────────────────── */
  --text:         #EEF0F8;            /* primary copy */
  --text-2:       #B4B9D0;            /* secondary copy */
  --text-3:       rgba(238, 240, 248, 0.55);  /* tertiary, muted */
  --text-4:       rgba(238, 240, 248, 0.30);  /* whisper */

  /* ── Type: families ────────────────────────────────────────── */
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;

  /* ── Type: scale ───────────────────────────────────────────── */
  --t-1:          11px;   /* eyebrow / micro labels */
  --t-2:          12px;   /* small body */
  --t-3:          14px;   /* body */
  --t-4:          16px;   /* body large */
  --t-5:          20px;   /* h4 */
  --t-6:          24px;   /* h3 */
  --t-7:          32px;   /* h2 */
  --t-8:          44px;   /* h1 */
  --t-9:          60px;   /* hero */

  /* ── Spacing scale ────────────────────────────────────────── */
  --s-1:          4px;
  --s-2:          8px;
  --s-3:          12px;
  --s-4:          16px;
  --s-5:          20px;
  --s-6:          24px;
  --s-7:          32px;
  --s-8:          40px;
  --s-9:          48px;
  --s-10:         64px;
  --s-11:         80px;

  /* ── Radius ───────────────────────────────────────────────── */
  --r-sm:         6px;
  --r-md:         10px;
  --r-lg:         14px;
  --r-xl:         20px;
  --r-pill:       999px;

  /* ── Shadows ──────────────────────────────────────────────── */
  --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-2:     0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-3:     0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow-amber: 0 0 24px rgba(245, 158, 11, 0.35);
  --shadow-glow-cyan:  0 0 24px rgba(0, 212, 255, 0.30);

  /* ── Motion ───────────────────────────────────────────────── */
  --ease:         cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast:       120ms;
  --t-base:       240ms;
  --t-slow:       400ms;

  /* ── Layout ───────────────────────────────────────────────── */
  --header-h:     56px;
  --container:    1320px;
}

/* ──────────────────────────────────────────────────────────────
 * RESET (light-touch, doesn't fight existing pages)
 * ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body.prism {
  margin: 0; padding: 0;
  font-family: var(--font-body);
  font-size: var(--t-3);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
body.prism a { color: var(--cyan); text-decoration: none; transition: color var(--t-fast); }
body.prism a:hover { color: var(--amber-2); }
body.prism h1, body.prism h2, body.prism h3, body.prism h4, body.prism h5 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────
 * BACKGROUND ATMOSPHERE — subtle, sets the "alive" tone everywhere
 * ────────────────────────────────────────────────────────────── */
body.prism::before {
  content: '';
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(245,158,11,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 90%, rgba(0,212,255,0.05) 0%, transparent 60%),
    var(--bg);
  pointer-events: none;
}
body.prism::after {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  opacity: 0.6;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 0%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 0%, transparent 80%);
}

/* ──────────────────────────────────────────────────────────────
 * HEADER — used by every operator module
 * Rendered by prism-shared.js (do not duplicate in pages)
 * ────────────────────────────────────────────────────────────── */
.prism-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  padding: 0 var(--s-6);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.prism-header::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber-glow) 30%, var(--cyan-glow) 70%, transparent);
  pointer-events: none;
}

.prism-logo {
  display: flex; align-items: baseline; gap: 8px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 3px;
  color: transparent;
  background: linear-gradient(95deg, #F59E0B 0%, #FCD34D 35%, #fff 50%, #FCD34D 65%, #F59E0B 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  animation: prism-shimmer 6s linear infinite;
  flex-shrink: 0;
}
@keyframes prism-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}
.prism-logo .module-tag {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
  -webkit-text-fill-color: var(--text-3);
}

.prism-nav {
  display: flex; align-items: center; gap: 2px;
  margin-left: var(--s-7);
  flex: 1;
}
.prism-nav-link {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: var(--t-3);
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.prism-nav-link:hover { color: var(--text); background: var(--surface-3); }
.prism-nav-link.active { color: var(--amber); background: rgba(245,158,11,0.10); }

.prism-header-right {
  display: flex; align-items: center; gap: var(--s-3);
  flex-shrink: 0;
}
.prism-icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 16px;
}
.prism-icon-btn:hover { color: var(--amber); border-color: var(--amber-glow); }

.prism-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), var(--magenta));
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: 2px solid var(--border-strong);
}

/* Mobile header collapse */
@media (max-width: 720px) {
  .prism-header { padding: 0 var(--s-4); }
  .prism-nav { margin-left: var(--s-3); gap: 0; overflow-x: auto; scrollbar-width: none; }
  .prism-nav::-webkit-scrollbar { display: none; }
  .prism-nav-link { padding: 6px 10px; font-size: var(--t-2); }
}

/* ──────────────────────────────────────────────────────────────
 * PAGE container
 * ────────────────────────────────────────────────────────────── */
.prism-page {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--s-7) var(--s-6) calc(var(--s-11) + 80px);
}
@media (max-width: 720px) { .prism-page { padding: var(--s-5) var(--s-4) calc(var(--s-10) + 80px); } }

/* ──────────────────────────────────────────────────────────────
 * BUTTONS
 * ────────────────────────────────────────────────────────────── */
.prism-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--t-3);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}
.prism-btn:hover { border-color: var(--amber-glow); color: var(--amber-2); transform: translateY(-1px); }
.prism-btn--primary {
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-d) 100%);
  border-color: var(--amber);
  color: #1a0d00;
}
.prism-btn--primary:hover { color: #1a0d00; box-shadow: var(--shadow-glow-amber); transform: translateY(-1px); }
.prism-btn--ghost {
  background: transparent;
  color: var(--text-2);
}
.prism-btn--ghost:hover { background: var(--surface-3); color: var(--text); }

/* ──────────────────────────────────────────────────────────────
 * KPI CARD — used in Console hero strip
 * ────────────────────────────────────────────────────────────── */
.prism-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-7);
}
.prism-kpi {
  position: relative;
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.prism-kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, var(--amber)) 50%, transparent);
  opacity: 0.5;
}
.prism-kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.prism-kpi-label {
  font-size: var(--t-1);
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: var(--s-2);
}
.prism-kpi-value {
  font-family: var(--font-display);
  font-size: var(--t-7);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.prism-kpi-delta {
  margin-top: var(--s-2);
  font-size: var(--t-2);
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.prism-kpi-delta--up   { color: var(--success); }
.prism-kpi-delta--down { color: var(--danger); }
.prism-kpi-delta--flat { color: var(--text-3); }

/* Per-KPI accent (use --accent on the .prism-kpi to tint top-bar) */
.prism-kpi[data-accent="amber"]   { --accent: var(--amber); }
.prism-kpi[data-accent="cyan"]    { --accent: var(--cyan); }
.prism-kpi[data-accent="purple"]  { --accent: var(--purple); }
.prism-kpi[data-accent="success"] { --accent: var(--success); }
.prism-kpi[data-accent="magenta"] { --accent: var(--magenta); }

/* ──────────────────────────────────────────────────────────────
 * ACTION CARD — large clickable tiles
 * ────────────────────────────────────────────────────────────── */
.prism-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-7);
}
.prism-action {
  position: relative;
  padding: var(--s-6);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  cursor: pointer;
  transition: all var(--t-base) var(--ease);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  overflow: hidden;
}
.prism-action::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at top right, var(--accent-glow, var(--amber-glow)) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}
.prism-action:hover {
  transform: translateY(-3px);
  border-color: var(--accent, var(--amber));
  box-shadow: var(--shadow-3);
}
.prism-action:hover::before { opacity: 0.4; }

.prism-action-icon {
  width: 48px; height: 48px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px;
  position: relative; z-index: 1;
}
.prism-action[data-accent="amber"]   { --accent: var(--amber); --accent-glow: var(--amber-glow); }
.prism-action[data-accent="cyan"]    { --accent: var(--cyan);  --accent-glow: var(--cyan-glow); }
.prism-action[data-accent="purple"]  { --accent: var(--purple); --accent-glow: rgba(139,92,246,0.30); }
.prism-action[data-accent="amber"] .prism-action-icon  { background: rgba(245,158,11,0.15); color: var(--amber); }
.prism-action[data-accent="cyan"] .prism-action-icon   { background: rgba(0,212,255,0.15);  color: var(--cyan); }
.prism-action[data-accent="purple"] .prism-action-icon { background: rgba(139,92,246,0.15); color: var(--purple); }

.prism-action-title {
  font-family: var(--font-display);
  font-size: var(--t-5);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  position: relative; z-index: 1;
}
.prism-action-sub {
  font-size: var(--t-3);
  color: var(--text-2);
  line-height: 1.5;
  position: relative; z-index: 1;
}
.prism-action-arrow {
  font-size: 18px;
  color: var(--text-3);
  margin-top: auto;
  align-self: flex-end;
  transition: transform var(--t-base), color var(--t-base);
  position: relative; z-index: 1;
}
.prism-action:hover .prism-action-arrow { transform: translateX(4px); color: var(--accent, var(--amber)); }

/* ──────────────────────────────────────────────────────────────
 * SECTION HEADER (consistent across modules)
 * ────────────────────────────────────────────────────────────── */
.prism-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-4);
  gap: var(--s-4);
}
.prism-section-title {
  font-family: var(--font-display);
  font-size: var(--t-5);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: var(--s-2);
}
.prism-section-title-pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan-glow);
  animation: prism-pulse 2.4s ease-in-out infinite;
}
@keyframes prism-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.prism-section-meta {
  font-size: var(--t-2);
  color: var(--text-3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
}

/* ──────────────────────────────────────────────────────────────
 * FEED ITEM — Herb's live activity stream
 * ────────────────────────────────────────────────────────────── */
.prism-feed {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.prism-feed-item {
  display: flex; align-items: flex-start; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.prism-feed-item:last-child { border-bottom: none; }
.prism-feed-item:hover { background: var(--surface-2); }
.prism-feed-icon {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: var(--surface-3);
}
.prism-feed-item[data-channel="email"] .prism-feed-icon { background: rgba(0,212,255,0.15); color: var(--cyan); }
.prism-feed-item[data-channel="voice"] .prism-feed-icon { background: rgba(139,92,246,0.15); color: var(--purple); }
.prism-feed-item[data-channel="sms"]   .prism-feed-icon { background: rgba(16,185,129,0.15); color: var(--success); }
.prism-feed-item[data-channel="reply"] .prism-feed-icon { background: rgba(245,158,11,0.15); color: var(--amber); }
.prism-feed-body { flex: 1; min-width: 0; }
.prism-feed-line1 {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-3);
  color: var(--text);
  margin-bottom: 2px;
}
.prism-feed-line1 strong { font-weight: 600; }
.prism-feed-line1 .dot { color: var(--text-4); }
.prism-feed-line1 .who { color: var(--amber-2); font-weight: 600; }
.prism-feed-snippet {
  font-size: var(--t-2);
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prism-feed-meta {
  margin-top: var(--s-2);
  display: flex; gap: var(--s-3);
  font-size: var(--t-1);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ──────────────────────────────────────────────────────────────
 * HERB PILL — persistent on every module page
 * ────────────────────────────────────────────────────────────── */
.prism-herb-pill {
  position: fixed; right: 20px; bottom: 20px;
  z-index: 9990;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px 12px 14px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--amber-2) 0%, var(--amber) 100%);
  color: #1a0d00;
  font-family: var(--font-display);
  font-size: var(--t-3);
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(0,0,0,0.1) inset;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.prism-herb-pill:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(245,158,11,0.4); }
.prism-herb-pill:active { transform: translateY(0); }
.prism-herb-pill .icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,0.20);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.prism-herb-pill .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: prism-pulse 2.4s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────
 * UTILITIES
 * ────────────────────────────────────────────────────────────── */
.prism-mt-0  { margin-top: 0; }
.prism-mt-4  { margin-top: var(--s-4); }
.prism-mt-7  { margin-top: var(--s-7); }
.prism-text-muted { color: var(--text-3); }
.prism-text-amber { color: var(--amber-2); }
.prism-text-cyan  { color: var(--cyan); }
