@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: hsl(220, 20%, 8%);
  --bg-card: hsla(220, 20%, 16%, 0.6);
  --bg-card-hover: hsla(220, 20%, 22%, 0.7);
  --border: hsla(220, 30%, 70%, 0.1);
  --accent: hsl(168, 70%, 48%);
  --accent-glow: hsla(168, 70%, 48%, 0.25);
  --accent-hover: hsl(168, 70%, 58%);
  --danger: hsl(4, 80%, 60%);
  --warning: hsl(38, 95%, 56%);
  --success: hsl(142, 65%, 50%);
  --info: hsl(210, 80%, 60%);
  --text: hsl(220, 15%, 92%);
  --text-muted: hsl(220, 15%, 55%);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
  --shadow: 0 8px 32px hsla(220,30%,5%,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% -5%, hsla(168,70%,48%,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, hsla(210,80%,60%,0.06) 0%, transparent 60%);
}

/* ─── HEADER ─────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), hsl(210,80%,60%));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow);
}
.logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo span { color: var(--accent); }

.header-actions { display: flex; gap: 0.75rem; align-items: center; }

/* ─── STATS BAR ─────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 2rem;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1 1 160px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.stat-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--shadow-glow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.teal   { background: hsla(168,70%,48%,0.15); }
.stat-icon.blue   { background: hsla(210,80%,60%,0.15); }
.stat-icon.yellow { background: hsla(38,95%,56%,0.15); }
.stat-icon.green  { background: hsla(142,65%,50%,0.15); }
.stat-icon.red    { background: hsla(4,80%,60%,0.15); }
.stat-info p { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.stat-info strong { font-size: 1.5rem; font-weight: 700; }

/* ─── TABLA ─────────────────────────────────── */
.table-section {
  flex: 1;
  padding: 0 2rem 2rem;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 { font-size: 1rem; font-weight: 600; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
}
.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  width: 220px;
}
.search-bar input::placeholder { color: var(--text-muted); }

.table-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
}
.leads-table th {
  padding: 0.9rem 1.2rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: hsla(220,20%,10%,0.4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.leads-table th:hover { color: var(--text); }
.leads-table th .sort-icon { margin-left: 4px; opacity: 0.4; }
.leads-table th.active .sort-icon { opacity: 1; color: var(--accent); }

.leads-table td {
  padding: 1rem 1.2rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tbody tr {
  transition: var(--transition);
}
.leads-table tbody tr:hover {
  background: hsla(220,20%,25%,0.3);
}

.company-cell { display: flex; flex-direction: column; gap: 2px; }
.company-name { font-weight: 600; }
.company-url  { font-size: 0.75rem; color: var(--text-muted); }

/* ─── CHIPS DE ESTADO ───────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.28rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.chip:hover { transform: scale(1.05); filter: brightness(1.15); }
.chip.pending    { background: hsla(38,95%,56%,0.15); color: hsl(38,95%,70%); }
.chip.contacted  { background: hsla(210,80%,60%,0.15); color: hsl(210,80%,75%); }
.chip.interested { background: hsla(168,70%,48%,0.15); color: hsl(168,70%,65%); }
.chip.closed     { background: hsla(142,65%,50%,0.15); color: hsl(142,65%,65%); }
.chip.lost       { background: hsla(4,80%,60%,0.15); color: hsl(4,80%,75%); }

/* ─── BOTONES ───────────────────────────────── */
.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn.primary {
  background: var(--accent);
  color: hsl(220,20%,8%);
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn.primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.btn.danger {
  background: hsla(4,80%,60%,0.1);
  color: hsl(4,80%,70%);
  border: 1px solid hsla(4,80%,60%,0.2);
}
.btn.danger:hover { background: hsla(4,80%,60%,0.2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── MODAL ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: hsla(220,25%,5%,0.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: hsl(220,20%,13%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 420px;
  box-shadow: var(--shadow), var(--shadow-glow);
  transform: translateY(12px) scale(0.97);
  transition: var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal h2 { margin-bottom: 1.5rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* ─── LOG DE CAMPAÑA ────────────────────────── */
.log-box {
  background: hsl(220,20%,6%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 1rem;
  display: none;
}
.log-box.visible { display: block; }

/* ─── TOAST ──────────────────────────────────── */
#toast {
  position: fixed; bottom: 2rem; right: 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.4rem;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  font-weight: 500;
  transform: translateY(10px);
  opacity: 0;
  transition: var(--transition);
  z-index: 300;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: hsla(142,65%,50%,0.4); color: hsl(142,65%,65%); }
#toast.error   { border-color: hsla(4,80%,60%,0.4);   color: hsl(4,80%,70%); }

/* ─── LOADER ─────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid hsla(220,20%,60%,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }

/* ─── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: 1rem; }
  .stats-bar, .table-section { padding: 1rem; }
  .leads-table th:nth-child(4),
  .leads-table td:nth-child(4) { display: none; }
  .search-bar input { width: 140px; }
}
