/* ========================================================================
   site.coach customer dashboard — design tokens + base styles
   --------------------------------------------------------------------------
   Brand: friendly, "unicorn with mass adoption appeal."
   Palette = prototype_4 warm base (cream/sage/orange) + vibrant unicorn
   accents (soft purple primary, sunny yellow highlight). Prototype_4
   variable names are kept as aliases so lifted markup keeps working.
   ======================================================================== */

:root {
  /* ── Backgrounds ───────────────────────────────────────────────── */
  --bg:           #FAFAF7;
  --bg-elevated: #FFFFFF;
  --bg-soft:     #F2F1EC;

  /* ── Brand: unicorn + warm ─────────────────────────────────────── */
  --primary:       #8B5CF6;   /* vibrant purple — primary CTA */
  --primary-soft:  #DDD6FE;
  --primary-text:  #5B21B6;

  --accent:        #FCD34D;   /* sunny yellow — highlight */
  --accent-soft:   #FEF3C7;

  --success:       #7DB5A0;   /* sage from prototype_4 */
  --success-soft:  #E3F0EB;
  --warning:       #F4845F;   /* warm orange from prototype_4 */
  --warning-soft:  #FDE8E0;
  --danger:        #EF4444;
  --danger-soft:   #FEE2E2;

  /* ── Text ──────────────────────────────────────────────────────── */
  --fg:        #292524;
  --fg-muted:  #78716C;
  --fg-light:  #B8B4AD;

  /* ── Border / shadows ──────────────────────────────────────────── */
  --border:      #E7E5E4;
  --border-soft: #EFEDE8;
  --radius:    12px;
  --radius-sm:  8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(41,37,36,0.05);
  --shadow-md: 0 4px 12px rgba(41,37,36,0.08);
  --shadow-lg: 0 12px 32px rgba(41,37,36,0.12);

  /* ── Layout ────────────────────────────────────────────────────── */
  --sidebar-width: 240px;
  --chat-width:    340px;
  --topnav-height:  56px;

  /* ── Aliases for lifted prototype_4 markup ─────────────────────── */
  --cream: var(--bg);
  --cream-dark: var(--bg-soft);
  --orange: var(--warning);
  --orange-light: var(--warning-soft);
  --orange-muted: #F9C4AE;
  --green: var(--success);
  --green-light: var(--success-soft);
  --yellow: var(--accent);
  --yellow-light: var(--accent-soft);
  --red: var(--danger);
  --red-light: var(--danger-soft);
  --text: var(--fg);
  --text-muted: var(--fg-muted);
  --text-light: var(--fg-light);
}

/* ── Reset / base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, .display { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; }
code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top nav ───────────────────────────────────────────────────────────── */
.topnav {
  height: var(--topnav-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  flex-shrink: 0; z-index: 10;
}
.brand {
  font-family: 'DM Serif Display', serif; font-size: 19px;
  letter-spacing: -0.3px; display: flex; align-items: center; gap: 6px;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.brand span.accent { color: var(--primary); }
.site-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; font-size: 12px;
  color: var(--fg-muted);
}
.site-badge .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.layout { display: flex; flex: 1; overflow: hidden; min-height: 0; }

.sidebar {
  width: var(--sidebar-width); background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-section {
  padding: 20px 16px 8px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-light);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13.5px; color: var(--fg-muted);
  cursor: pointer; transition: all 0.15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--bg); color: var(--fg); }
.nav-item.active {
  color: var(--primary-text); background: var(--primary-soft);
  border-left-color: var(--primary); font-weight: 500;
}
.nav-icon { font-size: 16px; width: 20px; display: inline-flex; justify-content: center; }
.nav-badge {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
}

.sidebar-footer {
  margin-top: auto; padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--fg-muted);
}

.main { flex: 1; overflow-y: auto; padding: 28px 32px; min-width: 0; }
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 24px; color: var(--fg); margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 20px; }

/* ── Cards / data ──────────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--fg); margin-bottom: 14px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 11px; color: var(--fg-muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 6px;
}
.stat-value { font-family: 'DM Serif Display', serif; font-size: 28px; line-height: 1; color: var(--fg); }
.stat-delta { font-size: 11px; margin-top: 6px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; color: var(--fg);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg); border-color: var(--fg-light); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-text); border-color: var(--primary-text); }
.btn-ghost { border-color: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; min-width: 30px; justify-content: center; }

.toggle { display: flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.toggle-btn { padding: 5px 12px; font-size: 12px; border-radius: 4px; cursor: pointer; color: var(--fg-muted); }
.toggle-btn.active { background: #fff; color: var(--fg); font-weight: 500; box-shadow: var(--shadow-sm); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); }
.data-table tr:hover td { background: var(--bg); cursor: pointer; }

.bounce-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.bounce-high { background: var(--danger-soft); color: #B91C1C; }
.bounce-med  { background: var(--accent-soft); color: #92400E; }
.bounce-low  { background: var(--success-soft); color: #166534; }

/* ── Kanban ────────────────────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 16px;
  align-items: stretch;
  min-height: 500px;
}
.kanban-col {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; min-height: 0;
}
.kanban-col-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.kanban-col-title { font-size: 12px; font-weight: 600; color: var(--fg); text-transform: uppercase; letter-spacing: 0.06em; }
.kanban-col-count { font-size: 11px; color: var(--fg-muted); background: #fff; border-radius: 999px; padding: 2px 8px; }
.kanban-list { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 80px; }
.kanban-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-sm);
  transition: transform 0.1s, box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.4; transform: rotate(1deg); }
.kanban-card.drop-target { border-color: var(--primary); border-style: dashed; }
.kanban-card-title { font-size: 13px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.kanban-card-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--fg-muted); }
.priority-pill { padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 500; }
.priority-1 { background: var(--danger-soft); color: var(--danger); }
.priority-2 { background: var(--accent-soft); color: #92400E; }
.priority-3 { background: var(--bg-soft); color: var(--fg-muted); }

/* ── Coach chat panel (bottom-right) ───────────────────────────────────── */
.chat-panel {
  position: fixed; bottom: 16px; right: 16px;
  width: var(--chat-width); max-height: 70vh;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 100; transition: all 0.25s;
}
.chat-panel.collapsed { height: 56px; }
.chat-panel.collapsed .chat-body, .chat-panel.collapsed .chat-input-row { display: none; }
.chat-header {
  height: 56px; display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.chat-header-title { font-weight: 600; flex: 1; display: flex; align-items: center; gap: 8px; }
.chat-header-title::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.chat-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; flex-direction: column; gap: 4px; }
.chat-msg.user { align-items: flex-end; }
.chat-bubble {
  max-width: 88%; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5;
}
.chat-msg.user    .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.assistant .chat-bubble { background: var(--bg-soft); color: var(--fg); border-bottom-left-radius: 3px; }
.chat-tool {
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: #92400E; cursor: pointer;
  display: inline-flex; gap: 6px; align-items: center;
  font-family: 'JetBrains Mono', monospace;
}
.chat-input-row {
  border-top: 1px solid var(--border); padding: 10px 12px; display: flex; gap: 8px;
}
.chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-family: inherit; font-size: 13px; background: #fff;
  outline: none; resize: none; max-height: 80px;
}
.chat-input:focus { border-color: var(--primary); }

/* ── Replay drawer ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,20,0.5);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 90vw; max-width: 1200px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { flex: 1; overflow: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }

.replay-stage {
  position: relative; background: #1f1d1c; min-height: 480px;
  width: 100%; overflow: hidden;
}
.replay-frame {
  position: absolute; top: 0; left: 0; border: 0;
  transform-origin: top left; pointer-events: none; background: #fff;
}
.replay-cursor {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: rgba(139,92,246,0.9); box-shadow: 0 0 12px rgba(139,92,246,0.7);
  z-index: 4; pointer-events: none; display: none;
  transform: translate(-7px, -7px); transition: left 0.08s linear, top 0.08s linear;
}
.replay-click-ring {
  position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--primary); z-index: 5; pointer-events: none;
  display: none; transform: translate(-12px,-12px);
}
@keyframes clickRing { from { opacity: 1; transform: translate(-12px,-12px) scale(0.4); }
                       to   { opacity: 0; transform: translate(-12px,-12px) scale(2.0); } }

.replay-controls { display: flex; gap: 10px; align-items: center; flex: 1; }
.replay-scrubber { flex: 1; }
.replay-time { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--fg-muted); min-width: 70px; text-align: right; }

/* ── Library / setup / settings ────────────────────────────────────────── */
.lib-section {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; overflow: hidden;
}
.lib-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; cursor: pointer;
}
.lib-section-title { font-size: 14px; font-weight: 600; }
.lib-section-meta { font-size: 12px; color: var(--fg-muted); }
.lib-section-body { padding: 0 18px 18px; display: none; }
.lib-section.open .lib-section-body { display: block; }

.connector-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; margin-bottom: 10px;
}
.connector-logo { width: 40px; height: 40px; border-radius: 8px; background: var(--bg-soft); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.connector-info { flex: 1; }
.connector-name { font-weight: 500; font-size: 14px; }
.connector-status { font-size: 12px; color: var(--fg-muted); }
.connector-status.connected { color: var(--success); }
.connector-status.error     { color: var(--danger); }

/* ── Toasts ────────────────────────────────────────────────────────────── */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px;
  box-shadow: var(--shadow-md); max-width: 320px; animation: slideIn 0.2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc utility ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.muted { color: var(--fg-muted); }
.spacer { flex: 1; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--fg-muted); }
.empty-state .display { font-size: 22px; color: var(--fg); margin-bottom: 8px; }

/* ── Scrollbars ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-light); }
