/* AgentFlow Lead Dashboard */

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

:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-primary: #4263eb;
  --color-primary-light: #f0f4ff;
  --color-text: #1a1a2e;
  --color-text-muted: #868e96;
  --color-border: #e9ecef;
  --color-success: #40c057;
  --color-warning: #fab005;
  --color-error: #fa5252;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

/* Auth */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 48px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}

.auth-card h2 { margin: 8px 0 24px; font-size: 18px; color: var(--color-text-muted); }
.auth-card input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}
.auth-card input:focus { outline: none; border-color: var(--color-primary); }

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--color-text);
}
.logo span { color: var(--color-text-muted); }

.error { color: var(--color-error); font-size: 13px; margin-top: 8px; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: #3b5bdb; }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #e9ecef; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-warning { background: var(--color-warning); color: var(--color-text); }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-subtitle { font-size: 14px; color: var(--color-text-muted); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 24px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab:hover { color: var(--color-text); }

.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-input, .filter-select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--color-surface);
}
.filter-input { flex: 1; min-width: 200px; }
.filter-input:focus, .filter-select:focus { outline: none; border-color: var(--color-primary); }

/* Table */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}
.table th {
  background: #f8f9fa;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.table tbody tr { cursor: pointer; transition: background 0.1s; }
.table tbody tr:hover { background: var(--color-primary-light); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-active { background: #d3f9d8; color: #2b8a3e; }
.badge-converted { background: #d0ebff; color: #1971c2; }
.badge-unsubscribed { background: #fff3bf; color: #e67700; }
.badge-bounced { background: #ffe3e3; color: #c92a2a; }
.badge-assessment { background: #e5dbff; color: #7048e8; }
.badge-contact { background: #d0ebff; color: #1971c2; }
.badge-exit_popup { background: #fff3bf; color: #e67700; }
.badge-blog_signup { background: #d3f9d8; color: #2b8a3e; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  font-size: 13px;
  cursor: pointer;
}
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination span { font-size: 13px; color: var(--color-text-muted); }

/* Funnel */
.funnel-chart {
  max-width: 600px;
  margin: 0 auto;
}
.funnel-step {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.funnel-label {
  width: 160px;
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
}
.funnel-bar-wrap {
  flex: 1;
  background: var(--color-bg);
  border-radius: 4px;
  height: 32px;
  overflow: hidden;
}
.funnel-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-width: 32px;
  transition: width 0.5s ease;
}
.funnel-bar span { font-size: 12px; font-weight: 600; color: #fff; }

/* Email Stats Grid */
.email-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.email-stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.email-stat-card .value { font-size: 32px; font-weight: 700; }
.email-stat-card .label { font-size: 13px; color: var(--color-text-muted); margin-top: 4px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--color-text-muted);
}

/* Lead Detail */
.lead-info { margin-bottom: 24px; }
.lead-info h3 { margin-bottom: 12px; }
.lead-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.lead-info-item { font-size: 13px; }
.lead-info-item strong { color: var(--color-text-muted); }

.email-timeline { margin-top: 24px; }
.email-timeline h4 { margin-bottom: 12px; }
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-dot.sent { background: var(--color-text-muted); }
.timeline-dot.delivered { background: var(--color-primary); }
.timeline-dot.opened { background: var(--color-success); }
.timeline-dot.clicked { background: #15aabf; }
.timeline-dot.bounced { background: var(--color-error); }
.timeline-dot.unsubscribed { background: var(--color-warning); }

.lead-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}
.empty-state h3 { margin-bottom: 8px; color: var(--color-text); }

/* Responsive */
@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); padding: 16px; }
  .tab-content { padding: 16px; }
  .filters { flex-direction: column; }
  .lead-info-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 20px; width: 95%; }
  .funnel-label { width: 100px; font-size: 12px; }
}
