/* ═══════════════════════════════════════════════════════════════
   PROSPECTFLO:ENVOY — UI STYLES
   Dark, elite, cinematic outbound sales intelligence.
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --midnight: #0A0911;
  --graphite-purple: #14111C;
  --deep-surface: #1B1726;

  /* Accents */
  --signal-purple: #7B61FF;
  --electric-violet: #9A7CFF;

  /* Foreground */
  --off-white: #F5F6FA;
  --muted-gray: #A2A0AE;
  --soft-lilac: #CFC3FF;

  /* Utility */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.14);
  --glow: rgba(123, 97, 255, 0.4);
  --glow-subtle: rgba(123, 97, 255, 0.15);

  /* Typography */
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Base ───────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--midnight);
  color: var(--off-white);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a {
  color: var(--signal-purple);
  text-decoration: none;
}

a:hover {
  color: var(--electric-violet);
}

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header Bar ─────────────────────────────────────────────── */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--space-lg);
  background: var(--graphite-purple);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  height: 26px;
  width: 26px;
  object-fit: contain;
}

.header-wordmark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--off-white);
  line-height: 1;
}

.header-wordmark-light {
  font-weight: 300;
  color: var(--electric-violet);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.model-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--signal-purple);
  background: rgba(123, 97, 255, 0.1);
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ── Layout: Nav + Main ─────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar Nav ────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--graphite-purple);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) 0;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  color: var(--muted-gray);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  border-left: 2px solid transparent;
}

.nav-item:hover {
  color: var(--off-white);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  color: var(--off-white);
  background: rgba(123, 97, 255, 0.08);
  border-left-color: var(--signal-purple);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.6;
}

.nav-item.active svg {
  opacity: 1;
  color: var(--signal-purple);
}

.nav-spacer {
  flex: 1;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  position: relative;
}

.main-content::-webkit-scrollbar {
  width: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* ── Page Titles ────────────────────────────────────────────── */
.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--off-white);
  margin-bottom: var(--space-lg);
}

.page-title .count {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted-gray);
  margin-left: var(--space-sm);
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted-gray);
  margin-top: -var(--space-sm);
  margin-bottom: var(--space-xl);
}

/* ── Stat Tiles ─────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-tile {
  background: var(--graphite-purple);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
  transition: border-color 0.2s;
}

.stat-tile:hover {
  border-color: var(--border-hover);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--off-white);
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Lead Cards ─────────────────────────────────────────────── */
.lead-card {
  background: var(--graphite-purple);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lead-card:hover {
  border-color: var(--border-hover);
}

.lead-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.lead-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.lead-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--deep-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--signal-purple);
  flex-shrink: 0;
}

.lead-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--off-white);
}

.lead-location {
  font-size: 12px;
  color: var(--muted-gray);
}

.lead-source-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-gray);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: var(--space-xs);
}

.lead-score {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.lead-score.high {
  color: var(--signal-purple);
  text-shadow: 0 0 20px var(--glow);
}

.lead-score.medium {
  color: var(--electric-violet);
}

.lead-score.low {
  color: var(--muted-gray);
}

/* First line preview */
.first-line-preview {
  font-style: italic;
  color: var(--soft-lilac);
  font-size: 13px;
  line-height: 1.5;
  padding: var(--space-sm) var(--space-md);
  border-left: 2px solid var(--glow);
  margin: var(--space-md) 0;
  background: rgba(123, 97, 255, 0.04);
  border-radius: 0 4px 4px 0;
}

/* Failure tags */
.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-sm) 0;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-gray);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Action row */
.action-row {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--signal-purple);
  color: #fff;
}

.btn-primary:hover {
  background: var(--electric-violet);
  box-shadow: 0 0 24px var(--glow);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-gray);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--off-white);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.btn-danger {
  background: transparent;
  color: #FF6B6B;
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

.btn-sm {
  font-size: 11px;
  padding: 5px 12px;
}

.btn-lg {
  font-size: 14px;
  padding: 12px 24px;
}

/* ── Campaign Cards ─────────────────────────────────────────── */
.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.campaign-card {
  background: var(--graphite-purple);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
  transition: all 0.2s var(--ease-out);
}

.campaign-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.campaign-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(123, 97, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--signal-purple);
  margin-bottom: var(--space-sm);
}

.campaign-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.campaign-terms {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-gray);
  margin-bottom: var(--space-sm);
}

.campaign-stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-gray);
}

/* Status pills */
.status-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.active {
  background: rgba(123, 97, 255, 0.2);
  color: var(--signal-purple);
}

.status-pill.paused {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-gray);
}

.status-pill.new {
  background: rgba(123, 97, 255, 0.15);
  color: var(--electric-violet);
}

.status-pill.approved {
  background: rgba(80, 200, 120, 0.15);
  color: #50C878;
}

.status-pill.sent {
  background: rgba(100, 149, 237, 0.15);
  color: #6495ED;
}

.status-pill.skipped {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-gray);
}

/* ── Wizard Steps ───────────────────────────────────────────── */
.wizard {
  max-width: 640px;
}

.wizard-steps {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.wizard-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--muted-gray);
  transition: all 0.2s;
}

.wizard-step.done .wizard-step-number {
  background: var(--signal-purple);
  border-color: var(--signal-purple);
  color: #fff;
}

.wizard-step.current .wizard-step-number {
  border-color: var(--signal-purple);
  color: var(--signal-purple);
  box-shadow: 0 0 16px var(--glow);
}

.wizard-step-label {
  font-size: 12px;
  color: var(--muted-gray);
}

.wizard-step.current .wizard-step-label {
  color: var(--off-white);
}

/* ── Forms ──────────────────────────────────────────────────── */
textarea, input[type="text"], input[type="url"], input[type="password"],
input[type="number"], select {
  width: 100%;
  background: var(--deep-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--off-white);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px var(--space-md);
  transition: border-color 0.2s;
  outline: none;
}

textarea:focus, input:focus, select:focus {
  border-color: var(--signal-purple);
  box-shadow: 0 0 0 2px var(--glow-subtle);
}

textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

textarea::placeholder, input::placeholder {
  color: rgba(162, 160, 174, 0.5);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.form-group {
  margin-bottom: var(--space-lg);
}

/* ── Toggle ─────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toggle {
  width: 40px;
  height: 22px;
  background: var(--deep-surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle.on {
  background: var(--signal-purple);
  border-color: var(--signal-purple);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle.on::after {
  transform: translateX(18px);
}

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

.data-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  font-size: 13px;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--off-white);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Activity Feed ──────────────────────────────────────────── */
.activity-feed {
  margin-top: var(--space-lg);
}

.activity-item {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted-gray);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.activity-item .time {
  color: rgba(162, 160, 174, 0.5);
  margin-right: var(--space-xs);
}

/* ── Upload Zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--muted-gray);
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover {
  border-color: var(--signal-purple);
  background: rgba(123, 97, 255, 0.04);
}

.upload-zone.dragover {
  border-color: var(--signal-purple);
  background: rgba(123, 97, 255, 0.08);
}

/* ── Code Block ─────────────────────────────────────────────── */
.code-block {
  background: var(--deep-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--soft-lilac);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* ── Log Viewer ─────────────────────────────────────────────── */
.log-viewer {
  background: var(--midnight);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted-gray);
  max-height: 300px;
  overflow-y: auto;
  margin-top: var(--space-lg);
}

.log-line {
  padding: 1px 0;
}

.log-line .ts {
  color: rgba(162, 160, 174, 0.4);
}

/* ── Section Headers ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--off-white);
}

/* ── Settings Grid ──────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.settings-section {
  background: var(--graphite-purple);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
}

.settings-section-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--off-white);
}

/* ── Learning Stats ─────────────────────────────────────────── */
.learning-stat {
  background: var(--graphite-purple);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.learning-stat .value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--signal-purple);
}

.learning-stat .label {
  font-size: 12px;
  color: var(--muted-gray);
  margin-top: 4px;
}

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--deep-surface);
  border-radius: 2px;
  overflow: hidden;
  margin: var(--space-sm) 0;
}

.progress-fill {
  height: 100%;
  background: var(--signal-purple);
  border-radius: 2px;
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 12px var(--glow);
}

/* ── Status Bar ─────────────────────────────────────────────── */
.status-bar {
  height: 32px;
  background: var(--graphite-purple);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-gray);
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #50C878;
}

.status-dot.running {
  background: var(--signal-purple);
  animation: pulse 1.5s infinite;
}

.status-dot.error {
  background: #FF6B6B;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Inline Regenerate ──────────────────────────────────────── */
.regen-inline {
  background: var(--deep-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-md);
  margin-top: var(--space-sm);
}

.regen-inline .new-line {
  font-style: italic;
  color: var(--soft-lilac);
  font-size: 13px;
  margin-bottom: var(--space-sm);
}

/* ── Screens (show/hide) ────────────────────────────────────── */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--muted-gray);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--off-white);
  margin-bottom: var(--space-xs);
}

/* ── Dropdown select ────────────────────────────────────────── */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A2A0AE' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Background texture (disabled) ──────────────────────────── */
.bg-texture {
  display: none;
}

/* ── Integrations Panel ──────────────────────────────────────── */
.integrations-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-gray);
  margin-bottom: var(--space-md);
}

.integration-category {
  margin-bottom: var(--space-lg);
}

.integration-category-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-gray);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 6px;
}

.integration-row {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 6px;
}

.integration-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.integration-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--off-white);
}

.integration-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.vault-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot-green { background: #4ade80; }
.status-dot-amber  { background: #fbbf24; }
.status-dot-gray   { background: var(--muted-gray); }

.custom-key-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.custom-key-name { flex: 1; }
.custom-key-value { flex: 2; }

.vault-security-note {
  font-size: 11px;
  color: var(--muted-gray);
  margin-top: var(--space-xl);
  line-height: 1.6;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 180px;
  }
}

/* ── Approval Queue ─────────────────────────────── */
.approval-row:hover { background: var(--surface-2); }
.approval-row.focused { background: rgba(123, 97, 255, 0.08); outline: 1px solid rgba(123, 97, 255, 0.25); }

@media (max-width: 600px) {
  .sidebar {
    display: none;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }
}
