/* ============================================================
   Blackbridge Outreach Engine — Design System
   Matches institutional dark theme with gold accents
   ============================================================ */

:root {
  --bg: #080808;
  --surface: #111111;
  --surface2: #161616;
  --surface3: #1e1e1e;
  --border: #2a2a2a;
  --border2: #333333;
  --text: #d8d8d8;
  --text-dim: #888888;
  --text-muted: #555555;
  --gold: #c9a84c;
  --gold-light: #f0d060;
  --gold-dark: #8a6d2f;
  --red: #e55;
  --green: #5c8;
  --blue: #5ad;
  --orange: #e85;
  --radius: 6px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: 0.5px; }
h1 { font-size: 28px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
h2 { font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 16px; }

/* ── Navigation ─────────────────────────────────────────────── */

.top-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.nav-brand-sub { color: var(--text-dim); font-weight: 400; }

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-tab {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-tab:hover { background: var(--surface2); color: var(--text); }
.nav-tab.active { background: var(--surface3); color: var(--gold); border: 1px solid var(--border2); }

.nav-actions { display: flex; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-gold { background: linear-gradient(135deg, var(--gold-dark), var(--gold)); color: #000; }
.btn-gold:hover { background: linear-gradient(135deg, var(--gold), var(--gold-light)); }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--gold); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ── Dashboard Layout ──────────────────────────────────────── */

.dashboard-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-dark));
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 6px; }
.stat-value { font-family: 'Barlow Condensed', sans-serif; font-size: 36px; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 { margin: 0; }
.panel-link { color: var(--gold); text-decoration: none; font-size: 13px; }
.panel-link:hover { text-decoration: underline; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Data Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

.loading, .empty, .empty-cell, .loading-cell { text-align: center; color: var(--text-muted); padding: 24px; }
.loading-cell { color: var(--text-dim); }

/* Funnel */
.funnel-wrap { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-bar {
  height: 24px;
  background: var(--surface3);
  border-radius: 3px;
  min-width: 4px;
  max-width: 400px;
  flex: 1;
  position: relative;
  transition: width 0.5s ease;
}
.funnel-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 3px;
}
.funnel-bar.gold::after { background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)); }
.funnel-label { font-size: 13px; color: var(--text-dim); width: 80px; }
.funnel-count { font-family: 'Barlow Condensed', sans-serif; font-size: 14px; color: var(--gold); min-width: 30px; }

/* List Items */
.list-items { display: flex; flex-direction: column; gap: 2px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border2);
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item-left { flex: 1; min-width: 0; }
.list-item-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Quick Actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.action-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.action-card:hover { border-color: var(--gold); background: var(--surface3); }
.action-icon { font-size: 24px; margin-bottom: 8px; }
.action-title { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.action-desc { font-size: 12px; color: var(--text-dim); }

/* Badges */
.channel-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-email { background: rgba(90,170,220,0.15); color: #5ad; }
.badge-call { background: rgba(90,200,136,0.15); color: #5c8; }
.badge-text { background: rgba(230,136,85,0.15); color: #e85; }
.badge-linkedin { background: rgba(40,130,200,0.15); color: #4ab; }
.badge-shipper { background: rgba(201,168,76,0.15); color: var(--gold); }
.badge-carrier { background: rgba(90,170,220,0.15); color: #5ad; }
.badge-broker { background: rgba(180,100,220,0.15); color: #b8a; }
.badge-dispatcher { background: rgba(90,200,136,0.15); color: #5c8; }
.badge-followup { background: rgba(200,150,50,0.15); color: #ca6; }

.outcome-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.outcome-sent { background: var(--surface3); color: var(--text-dim); }
.outcome-delivered { background: rgba(90,170,220,0.1); color: #5ad; }
.outcome-opened { background: rgba(90,170,220,0.2); color: #5ad; }
.outcome-replied { background: rgba(230,136,85,0.2); color: #e85; }
.outcome-connected { background: rgba(90,200,136,0.2); color: #5c8; }
.outcome-converted { background: rgba(201,168,76,0.3); color: var(--gold); }
.outcome-no_response { background: var(--surface3); color: var(--text-muted); }
.outcome-bounced { background: rgba(229,85,85,0.2); color: #e55; }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-active { background: rgba(90,200,136,0.15); color: #5c8; }
.status-inactive { background: var(--surface3); color: var(--text-muted); }

/* Filters & Page Header */
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
.filter-select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--gold); color: var(--text); }

/* Templates */
.template-grid { display: flex; flex-direction: column; gap: 24px; }
.template-group-title { font-family: 'Barlow Condensed', sans-serif; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border2); }
.template-grid-inner { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.template-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.template-card:hover { border-color: var(--gold); background: var(--surface3); }
.template-name { font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.template-meta { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.template-subcat { font-size: 11px; color: var(--text-muted); }
.template-subject { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Entities Table */
.entity-link { color: var(--gold); text-decoration: none; }
.entity-link:hover { text-decoration: underline; }
.entity-cell-name { font-weight: 500; }
.entity-cell-sub { font-size: 11px; color: var(--text-dim); }
.subject-cell-name { font-size: 13px; }
.subject-cell-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { max-width: 700px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.5px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Barlow Condensed', sans-serif; }
.form-input, .form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: 'Barlow', sans-serif;
  width: 100%;
  transition: border-color 0.15s;
}
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--gold); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }

.token-hint { font-size: 11px; color: var(--text-muted); margin-left: 6px; font-family: 'Barlow', sans-serif; text-transform: none; font-weight: 400; letter-spacing: 0; }

/* Composer */
.composer-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.composer-form { display: flex; flex-direction: column; gap: 14px; }
.composer-textarea { min-height: 240px; font-family: 'Barlow', monospace; font-size: 13px; }
.composer-actions { display: flex; align-items: center; gap: 12px; }
.send-status { font-size: 13px; }

.token-insert-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.token-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.token-chip {
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--gold);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: 'Barlow Condensed', monospace;
  transition: background 0.1s, border-color 0.1s;
}
.token-chip:hover { background: var(--surface2); border-color: var(--gold); }

/* Preview */
.preview-box {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}
.preview-placeholder { color: var(--text-muted); font-size: 12px; text-align: center; padding: 40px 0; }
.preview-text {
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.var-grid { display: flex; flex-direction: column; gap: 8px; }
.var-row { display: flex; flex-direction: column; gap: 3px; }
.var-row label { font-size: 11px; color: var(--gold); font-family: 'Barlow Condensed', monospace; }
.var-row .form-input { font-size: 12px; padding: 5px 8px; }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-row { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Barlow Condensed', sans-serif; }
.detail-row span:last-child { font-size: 13px; color: var(--text); }
.detail-content-box { margin-top: 8px; }
.content-pre { background: var(--surface2); border: 1px solid var(--border2); padding: 12px; border-radius: var(--radius); font-size: 12px; white-space: pre-wrap; color: var(--text-dim); margin-top: 4px; }

/* FAB */
.fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #000;
  font-size: 24px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 50;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.5); }

/* Responsive */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .composer-layout { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .top-nav { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .nav-links { flex-wrap: wrap; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}