/* LeadsFlow Design System
   Light theme: leads, bookings, users
   Dark theme:  chats, agents, WhatsApp/accounts
   Usage: <html data-theme="light"> or <html data-theme="dark">
*/

/* ── Fonts ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

/* ── Design Tokens — Light ────────────────────────────────────────────────── */
[data-theme="light"] {
  /* Backgrounds */
  --bg-page:       #f4f6fa;
  --bg-surface:    #ffffff;
  --bg-sidebar:    #ffffff;
  --bg-hover:      #f0f3f8;
  --bg-selected:   #eef2ff;

  /* Borders */
  --border:        #e4e8f0;
  --border-strong: #c8d0e0;

  /* Text */
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-tertiary:  #9ca3af;
  --text-inverse:   #ffffff;

  /* Brand (indigo) */
  --accent:         #4f46e5;
  --accent-hover:   #4338ca;
  --accent-light:   #eef2ff;
  --accent-text:    #4f46e5;

  /* Status colors */
  --status-new:       #2563eb;
  --status-follow:    #d97706;
  --status-scheduled: #7c3aed;
  --status-registered:#16a34a;
  --status-failed:    #dc2626;

  /* State */
  --success:  #16a34a;
  --warning:  #d97706;
  --error:    #dc2626;
  --info:     #2563eb;

  --success-bg: #f0fdf4;
  --warning-bg: #fffbeb;
  --error-bg:   #fef2f2;
  --info-bg:    #eff6ff;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.12);
}

/* ── Design Tokens — Dark ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-sidebar:    #141720;
  --bg-hover:      #232634;
  --bg-selected:   #1e2a1e;

  --border:        #2a2d3e;
  --border-strong: #3a3f56;

  --text-primary:   #f0f2f8;
  --text-secondary: #8b90a7;
  --text-tertiary:  #5c6278;
  --text-inverse:   #111827;

  /* Brand (green for operational dark mode) */
  --accent:         #22c55e;
  --accent-hover:   #16a34a;
  --accent-light:   #052e16;
  --accent-text:    #86efac;

  --status-new:       #60a5fa;
  --status-follow:    #fbbf24;
  --status-scheduled: #a78bfa;
  --status-registered:#4ade80;
  --status-failed:    #f87171;

  --success:  #22c55e;
  --warning:  #f59e0b;
  --error:    #ef4444;
  --info:     #3b82f6;

  --success-bg: #052e16;
  --warning-bg: #1c1200;
  --error-bg:   #1c0404;
  --info-bg:    #03152e;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.5);
}

/* ── Shared tokens ────────────────────────────────────────────────────────── */
:root {
  --sidebar-w:   240px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --transition: 150ms ease;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
}

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

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: hidden;
}
.app-sidebar nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-header h1 {
  font-size: 1.5rem;
}

/* When the shared topbar is present it already shows the page title.
   Suppress the redundant h1 / subtitle inside .page-header, and hide
   the entire .page-header if nothing interactive (buttons, inputs)
   remains after the title is gone. */
#app-topbar ~ .page-header h1 { display: none; }
#app-topbar ~ .page-header > p { display: none; }
#app-topbar ~ .page-header > div:has(h1):not(:has(button, input, a.btn)) { display: none; }
#app-topbar ~ .page-header:not(:has(button, a.btn, input, select)) { display: none; }
#app-topbar ~ .page-header { padding-top: var(--space-3); padding-bottom: var(--space-3); }
/* Analytics uses .an-header — hide it entirely when topbar is present */
#app-topbar ~ .an-header { display: none; }

.page-body {
  padding: var(--space-6) var(--space-8);
  flex: 1;
}

.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ── App Topbar ────────────────────────────────────────────────────────────── */
.app-topbar {
  height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-topbar-title {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--transition), border-color var(--transition);
}
.topbar-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.topbar-feedback-wrap { position: relative; }
.topbar-feedback-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 200;
}
.topbar-feedback-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .875rem;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  min-height: 100px;
}
.topbar-feedback-textarea:focus { border-color: var(--accent); }
.topbar-feedback-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.topbar-feedback-note {
  font-size: .72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}
.topbar-feedback-capture {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 10px;
  padding: 7px 12px;
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.topbar-feedback-capture:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}
.topbar-feedback-preview {
  position: relative;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-page);
}
.topbar-feedback-preview img {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: contain;
}
.topbar-feedback-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-feedback-preview-remove:hover { background: rgba(0, 0, 0, 0.75); }

/* Split view (chats) */
.split-view {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.split-left {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg-surface);
}

.split-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
.nav-brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-2) var(--space-4) var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  user-select: none;
}
.nav-brand-logo {
  flex-shrink: 0;
  display: block;
}
.nav-brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-workspace-switcher {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 2 * var(--space-4));
  margin: 0 var(--space-4) var(--space-2);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: default;
  transition: background var(--transition), border-color var(--transition);
}
.nav-workspace-switcher.is-switchable {
  cursor: pointer;
}
.nav-workspace-switcher.is-switchable:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong, var(--border));
}
.nav-workspace-switcher:disabled {
  opacity: 1;
  cursor: default;
}
.nav-workspace-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-workspace-chevron {
  flex-shrink: 0;
  opacity: 0.5;
  display: none;
  transition: transform 0.2s;
}
.nav-workspace-switcher.is-switchable .nav-workspace-chevron {
  display: block;
}
.nav-workspace-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  min-width: 220px;
  max-width: 280px;
}

.nav-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.nav-section-label {
  padding: var(--space-1) var(--space-4) var(--space-1);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.75;
  user-select: none;
  pointer-events: none;
}
.nav-section-label[data-after-group] {
  margin-top: var(--space-3);
  padding-top: var(--space-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent-text); }

/* Collapsible Content tree */
.nav-tree { display: flex; flex-direction: column; }
.nav-tree-toggle {
  width: 100%;
  justify-content: flex-start;
  position: relative;
  padding-right: calc(var(--space-4) + 16px);
}
.nav-tree-toggle .nav-item-label { flex: 1; min-width: 0; }
.nav-tree-chevron {
  position: absolute;
  right: var(--space-4);
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.15s ease;
  transform: rotate(180deg);
}
.nav-tree.is-collapsed .nav-tree-chevron { transform: rotate(0deg); }
.nav-tree.is-collapsed .nav-tree-children { display: none; }
.nav-tree-children { display: flex; flex-direction: column; }
.nav-item.nav-sub {
  padding-left: calc(var(--space-4) + 20px);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Select Image / Select media overlays */
.si-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.45);
  display: flex; align-items: stretch; justify-content: center;
  padding: var(--space-6);
}
.si-overlay[hidden] { display: none !important; }
.si-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border);
  width: min(960px, 100%);
  max-height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
}
.si-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.si-header h2 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.si-tabs {
  display: flex; gap: 0; padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.si-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  font: inherit; font-size: .875rem; font-weight: 500;
  color: var(--text-secondary); padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.si-tab:hover { color: var(--text-primary); }
.si-tab.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }
.si-body { padding: var(--space-5) var(--space-6); overflow: auto; flex: 1; min-height: 0; }
.si-toolbar { display: flex; gap: var(--space-3); align-items: center; margin-bottom: var(--space-4); flex-wrap: wrap; }
.si-search-wrap { position: relative; flex: 1; min-width: 180px; }
.si-search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.si-search { padding-left: 36px !important; width: 100%; }
.si-ai-toggle { border-style: dashed !important; }
.si-table-wrap { overflow: auto; }
.si-name-cell { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.si-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-hover); flex-shrink: 0; }
.si-name { font-weight: 600; color: var(--text-primary); }
.si-meta { font-size: .75rem; color: var(--text-tertiary); margin-top: 2px; }
.si-select-link {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--accent-text, var(--accent)); font-weight: 600; font-size: .875rem; font-family: inherit;
}
.si-select-link:hover { text-decoration: underline; }
.si-drop {
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: var(--radius-md);
  background: var(--bg-page);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--text-primary);
}
.si-drop.drag-over { border-color: var(--accent); background: var(--bg-hover); }
.si-drop-hint { font-size: .8125rem; color: var(--text-secondary); margin: var(--space-2) 0; }
.si-status { font-size: .8125rem; color: var(--text-secondary); margin-top: var(--space-3); }
.si-url-form { max-width: 480px; }
.sm-upload-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.sm-settings-wrap { position: relative; }
.sm-settings-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 2;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-3);
  font-size: .75rem; color: var(--text-secondary); width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

/* Button nav items (Incoming Calls) — match <a.nav-item> / All Leads exactly */
button.nav-item {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: inherit;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-4);
}

/* ── Saved filters nav sub-list (shared across all pages) ──────────────────── */
.nav-saved-filters { list-style:none;margin:0 0 var(--space-1);padding:0; }
.nav-saved-filter { display:flex;align-items:center;gap:var(--space-2);padding:5px var(--space-4) 5px calc(var(--space-4) + 20px);cursor:pointer;font-size:.78rem;color:var(--text-secondary);transition:background var(--transition); }
.nav-saved-filter:hover { background:var(--bg-hover);color:var(--text-primary); }
.nav-saved-filter.active { color:var(--accent-text,var(--accent));background:var(--bg-selected); }
.nav-saved-filter .sf-label { flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
/* Badge stays anchored right-most via margin-left:auto, so the label's flex:1 still eats slack
   but the badge is positioned independent of whether the hover-only delete is present. */
.nav-saved-filter .sf-count { flex-shrink:0;margin-left:auto;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--accent-10,rgba(99,102,241,.12));color:var(--accent-text,var(--accent));font-size:.68rem;font-weight:600;display:inline-flex;align-items:center;justify-content:center;line-height:1; }
/* Delete only appears on row hover; sits immediately left of the badge. */
.nav-saved-filter .sf-delete { display:none;background:none;border:none;cursor:pointer;padding:2px;color:var(--text-tertiary);border-radius:3px;flex-shrink:0;line-height:0; }
.nav-saved-filter:hover .sf-delete { display:inline-flex;align-items:center; }
.nav-saved-filter .sf-delete:hover { color:var(--error);background:var(--bg-hover); }
/* Drag handle — hover-only grip icon between label and delete bin. Cursor is
   `grab` so the row visibly invites a drag; whole row is `draggable=true` so
   the user can grab anywhere, but the grip is the visual cue. */
.nav-saved-filter[draggable="true"] { cursor:grab; }
.nav-saved-filter[draggable="true"]:active { cursor:grabbing; }
.nav-saved-filter .sf-drag { display:none;align-items:center;justify-content:center;padding:0;color:var(--text-tertiary);flex-shrink:0;line-height:0;width:14px;height:16px; }
.nav-saved-filter:hover .sf-drag { display:inline-flex; }
.nav-saved-filter.sf-dragging { opacity:.45; }
/* Drop indicator — a single accent line above or below the hovered row. */
.nav-saved-filter.sf-drop-above { box-shadow:inset 0 2px 0 0 var(--accent); }
.nav-saved-filter.sf-drop-below { box-shadow:inset 0 -2px 0 0 var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  font-family: var(--font-body);
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-surface); }

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-sm { padding: var(--space-1) var(--space-3); font-size: 0.8rem; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 1rem; }

/* ── Labels: status-pill, badge, tag ─────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-new       { color: var(--status-new);       background: var(--info-bg); }
.pill-follow_up { color: var(--status-follow);     background: var(--warning-bg); }
.pill-trial_scheduled { color: var(--status-scheduled); background: #f5f3ff; }
.pill-registered { color: var(--status-registered); background: var(--success-bg); }
.pill-failed    { color: var(--status-failed);     background: var(--error-bg); }

/* Campaign status (traffic-light) */
.pill-draft     { color: var(--text-secondary);     background: var(--bg-hover); }
.pill-scheduled { color: var(--status-follow);      background: var(--warning-bg); }
.pill-sending   { color: var(--status-new);         background: var(--info-bg); }
.pill-sent      { color: var(--status-registered);  background: var(--success-bg); }
.pill-cancelled { color: var(--status-failed);      background: var(--error-bg); }
.pill-archived  { color: var(--text-tertiary);      background: var(--bg-page); }

.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.tag {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Status tabs ──────────────────────────────────────────────────────────── */
.status-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  overflow-x: auto;
}

.status-tab {
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.status-tab:hover { color: var(--text-primary); }
.status-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.form-textarea { resize: vertical; min-height: 120px; }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-secondary);
  gap: var(--space-3);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state-desc {
  font-size: 0.875rem;
  max-width: 320px;
}

/* ── Skeleton loading ─────────────────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.skeleton {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

/* ── Chat bubbles ─────────────────────────────────────────────────────────── */
.chat-bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble.email-bubble { max-width: 100%; width: 100%; white-space: normal; padding: var(--space-3); box-sizing: border-box; }

.bubble-lead {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.bubble-agent_ai {
  background: #052e16;
  color: #86efac;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.bubble-platform_user {
  background: #1e1b4b;
  color: #a5b4fc;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.bubble-broadcast {
  background: #451a03;
  color: #fdba74;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.bubble-flow_agent {
  background: #2e1065;
  color: #c4b5fd;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.bubble-call_agent {
  background: #0c4a6e;
  color: #7dd3fc;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
  max-width: min(360px, 100%);
  width: min(360px, 100%);
  white-space: normal;
  box-sizing: border-box;
}

.bubble-call_agent audio {
  width: 100%;
  max-width: 100%;
  display: block;
}

.chat-message-row {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-4);
  gap: var(--space-1);
}

.chat-message-row.from-lead { align-items: flex-start; }
.chat-message-row.from-agent,
.chat-message-row.from-user { align-items: flex-end; }

.chat-meta {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ── Booking slot states ──────────────────────────────────────────────────── */
.slot-available { border-left: 3px solid var(--success); }
.slot-full      { border-left: 3px solid var(--border-strong); opacity: 0.6; }
.slot-blackout  { text-decoration: line-through; opacity: 0.4; }

/* ── Responsive collapse ──────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 200;
  width: 36px;
  height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-primary);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

.nav-overlay.open { display: block; }

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .app-sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 100;
  }

  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }

  .split-left {
    width: 100%;
    position: fixed;
    z-index: 10;
  }

  .page-body { padding: var(--space-4); }
}

/* ── Sidebar footer user block (shared across all pages) ───────────────────── */
#user-info { display:flex;align-items:center;gap:var(--space-2);margin-bottom:var(--space-2); }
.user-avatar { width:32px;height:32px;border-radius:50%;background:var(--accent);color:var(--text-inverse);display:flex;align-items:center;justify-content:center;font-size:.75rem;font-weight:700;flex-shrink:0; }
.user-name { font-size:.8rem;font-weight:600;color:var(--text-primary); }
.user-role { font-size:.75rem;color:var(--text-secondary);text-transform:capitalize; }

/* ── Incoming Calls softphone (nav popover + bottom-left dock) ─────────────── */
.nav-incoming-calls { position: relative; }
.nav-incoming-calls[hidden] { display: none !important; }
.nav-incoming-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--success);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-incoming-badge[hidden] { display: none !important; }

.wa-incoming-panel {
  position: fixed;
  z-index: 320;
  width: 360px;
  max-height: 70vh;
  display: none;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.wa-incoming-panel.open { display: flex; }
.wa-incoming-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.wa-incoming-panel-icon {
  display: inline-flex;
  color: var(--success);
  flex-shrink: 0;
}
.wa-incoming-panel-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.wa-incoming-rec-note {
  padding: var(--space-2) var(--space-4);
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle, transparent);
  flex-shrink: 0;
}
.wa-incoming-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: var(--space-1) 0;
}
.wa-incoming-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}
.wa-incoming-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.wa-incoming-row:last-child { border-bottom: none; }
.wa-incoming-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  flex-shrink: 0;
}
.wa-incoming-row-meta { flex: 1; min-width: 0; }
.wa-incoming-row-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-incoming-row-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-incoming-row-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }
.wa-incoming-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.wa-incoming-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.wa-incoming-btn-reject {
  background: var(--bg-surface);
  color: var(--error);
  border-color: var(--error);
}
.wa-incoming-btn-pickup {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.wa-incoming-btn:not(:disabled):hover { opacity: 0.9; transform: scale(1.03); }
.wa-incoming-btn-connecting:disabled {
  opacity: 1;
  cursor: wait;
}
.wa-incoming-row-connecting { opacity: 0.92; }
.wa-incoming-row-sub-busy {
  color: var(--success);
  font-weight: 500;
}
@keyframes wa-incoming-spin {
  to { transform: rotate(360deg); }
}
.wa-incoming-spinner {
  display: block;
  animation: wa-incoming-spin 0.75s linear infinite;
}

.wa-active-call-dock {
  display: none;
  position: fixed;
  left: calc(var(--sidebar-w) + 16px);
  bottom: 20px;
  right: auto;
  z-index: 310;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg);
  padding: 14px 14px 12px;
  width: 280px;
  max-width: calc(100vw - var(--sidebar-w) - 32px);
}
.wa-active-call-dock.open { display: flex; }
.wa-active-call-dock-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.wa-active-call-dock-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.wa-active-call-dock-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md, 10px);
  background: var(--bg-subtle, var(--bg-hover));
}
.wa-active-call-dock-phone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
  flex-shrink: 0;
}
.wa-active-call-dock-meta { flex: 1; min-width: 0; }
.wa-active-call-dock-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-active-call-dock-phone {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-active-call-dock-phone[hidden] { display: none !important; }
.wa-active-call-dock-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wa-active-call-dock-rec {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-primary);
  flex-shrink: 0;
}
.wa-active-call-dock-rec[hidden] { display: none !important; }
.wa-active-call-dock-hold {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle, var(--bg-hover));
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 40px;
}
.wa-active-call-dock-hold:hover { filter: brightness(0.98); }
.wa-active-call-dock-hold:disabled { opacity: 0.55; cursor: wait; }
.wa-active-call-dock-hold-resume {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.wa-active-call-dock-end {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: var(--error);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 40px;
}
.wa-active-call-dock-end:hover { filter: brightness(0.95); }
/* Busy state while the terminate request + teardown are in flight. */
.wa-active-call-dock-end.is-ending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0.85;
  cursor: default;
}
.wa-active-call-dock-end:disabled { cursor: default; }

@media (max-width: 768px) {
  .wa-active-call-dock {
    left: 16px;
    max-width: calc(100vw - 32px);
  }
}

