/* Lead Intelligence Platform — Dark Theme */

:root {
  --bg-primary: #0f0f1a;
  --bg-surface: #1a1a2e;
  --bg-elevated: #16213e;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --brand: #10b981;
  --brand-hover: #059669;
  --brand-muted: rgba(16, 185, 129, 0.15);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-muted: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --info: #3b82f6;
  --purple: #a855f7;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- LAYOUT ---- */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  min-height: 100vh;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 2px;
  letter-spacing: 0.5px;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  margin-top: 8px;
}

/* ---- NAVIGATION ---- */

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--brand-muted);
  color: var(--brand);
}

.nav-link .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ---- MAIN CONTENT ---- */

.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ---- CARDS ---- */

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ---- STAT CARDS ---- */

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- BUTTONS ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

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

.btn-primary:hover {
  background-color: var(--brand-hover);
  color: #fff;
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
  color: #fff;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

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

/* ---- FORM ELEMENTS ---- */

.input {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.input:focus {
  border-color: var(--brand);
  background-color: rgba(255, 255, 255, 0.07);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

textarea.input {
  resize: vertical;
  min-height: 100px;
}

.label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group {
  margin-bottom: 16px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- BADGES ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-new { background-color: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-contacted { background-color: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-qualified { background-color: rgba(168, 85, 247, 0.2); color: #c084fc; }
.badge-converted { background-color: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-rejected { background-color: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-idle { background-color: rgba(100, 116, 139, 0.2); color: #94a3b8; }
.badge-searching { background-color: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-scraping { background-color: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-processing { background-color: rgba(168, 85, 247, 0.2); color: #c084fc; }
.badge-error { background-color: rgba(239, 68, 68, 0.2); color: #f87171; }

/* ---- TABLES ---- */

.table-container {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background-color: rgba(255, 255, 255, 0.03);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.025);
}

tbody td {
  padding: 11px 14px;
  color: var(--text-primary);
  font-size: 13px;
  vertical-align: middle;
}

.td-muted {
  color: var(--text-muted);
}

/* ---- SCORE DISPLAY ---- */

.score-high { color: #34d399; font-weight: 600; }
.score-mid { color: #fbbf24; font-weight: 600; }
.score-low { color: #f87171; font-weight: 600; }

/* ---- STATUS DOT ---- */

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

.dot-idle { background-color: #64748b; }
.dot-searching { background-color: #3b82f6; }
.dot-processing { background-color: #a855f7; }
.dot-scraping { background-color: #f59e0b; }
.dot-error { background-color: #ef4444; }
.dot-active { background-color: var(--brand); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.dot-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ---- FILTER BAR ---- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0;
}

.filter-bar .input {
  width: auto;
  min-width: 160px;
}

/* ---- PAGINATION ---- */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 0 4px;
  justify-content: center;
}

.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.page-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.page-btn.current {
  background-color: var(--brand-muted);
  color: var(--brand);
  border-color: var(--brand);
}

/* ---- ALERTS / MESSAGES ---- */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.alert-error {
  background-color: var(--danger-muted);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* ---- LOG FEED ---- */

.log-feed {
  background-color: #0a0a14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 12px;
}

.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  gap: 8px;
}

.log-entry:last-child { border-bottom: none; }

.log-time { color: var(--text-muted); flex-shrink: 0; }
.log-level-info { color: #60a5fa; }
.log-level-warning { color: #fbbf24; }
.log-level-error { color: #f87171; }

/* ---- ANALYTICS BARS ---- */

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  width: 130px;
  flex-shrink: 0;
  text-transform: capitalize;
}

.bar-track {
  flex: 1;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background-color: var(--brand);
  transition: width 0.4s ease;
}

.bar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* ---- MISC ---- */

.text-brand { color: var(--brand); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  margin: 0;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-col-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

a { color: inherit; }

input[type="checkbox"] {
  accent-color: var(--brand);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
