/* LeadCRM — custom styles */

:root {
  --sidebar-bg: #0f172a;
  --sidebar-width: 240px;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
body {
  background: #f1f5f9;
  font-family: 'Segoe UI', sans-serif;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar .brand {
  padding: 1.5rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
  display: block;
}

.sidebar .brand span { color: var(--accent); }

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.65);
  padding: 0.65rem 1.25rem;
  border-radius: 0.5rem;
  margin: 0.1rem 0.5rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.15s;
  text-decoration: none;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  color: white;
  background: rgba(99, 102, 241, 0.2);
}

.sidebar .nav-link.active {
  border-left: 3px solid var(--accent);
}

.sidebar .nav-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0;
}

/* ── Main content ─────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.5rem;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

/* ── Stat cards ───────────────────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--accent);
  height: 100%;
}

.stat-card.green  { border-color: #10b981; }
.stat-card.yellow { border-color: #f59e0b; }
.stat-card.red    { border-color: #ef4444; }
.stat-card.purple { border-color: #8b5cf6; }
.stat-card.blue   { border-color: #3b82f6; }

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.35rem;
}

/* ── Status badges ────────────────────────────────────────────────────── */
.lead-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

.badge-nuevo         { background: #dbeafe; color: #1d4ed8; }
.badge-contactado    { background: #fef3c7; color: #92400e; }
.badge-interesado    { background: #d1fae5; color: #065f46; }
.badge-no_interesado { background: #fee2e2; color: #991b1b; }
.badge-cliente       { background: #ede9fe; color: #5b21b6; }
.badge-descartado    { background: #f1f5f9; color: #475569; }
.badge-duplicado     { background: #ffedd5; color: #9a3412; }

/* ── Job estado badges ────────────────────────────────────────────────── */
.badge-pendiente  { background: #f1f5f9; color: #475569; }
.badge-corriendo  { background: #dbeafe; color: #1d4ed8; }
.badge-completado { background: #d1fae5; color: #065f46; }
.badge-error      { background: #fee2e2; color: #991b1b; }

/* ── Card panels ──────────────────────────────────────────────────────── */
.card-panel {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.card-panel .panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 600;
  color: #1e293b;
  font-size: 0.9rem;
}

.card-panel .panel-body {
  padding: 1.25rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-accent {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-block;
}

.btn-accent:hover {
  background: var(--accent-hover);
  color: white;
}

/* ── WhatsApp button ──────────────────────────────────────────────────── */
.wa-btn {
  color: #25d366;
  font-size: 1.1rem;
  text-decoration: none;
}

.wa-btn:hover { color: #128c7e; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-card {
  max-width: 380px;
  margin: 0 auto;
  margin-top: 10vh;
}

/* ── Activity log ─────────────────────────────────────────────────────── */
.activity-item {
  border-left: 2px solid #e2e8f0;
  padding-left: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

.activity-item::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  position: absolute;
  left: -5px;
  top: 4px;
}

.activity-item .time {
  font-size: 0.75rem;
  color: #94a3b8;
}

.activity-item .act-desc {
  font-size: 0.875rem;
  color: #334155;
}

/* ── Scraper job log ──────────────────────────────────────────────────── */
.job-log {
  background: #0f172a;
  color: #94a3b8;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-panel {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.table-panel .table {
  margin-bottom: 0;
}

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart-container {
  position: relative;
  padding: 1rem;
}

/* ── Duplicate warning ────────────────────────────────────────────────── */
.dup-banner {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  color: #9a3412;
  font-size: 0.875rem;
}

/* ── Lead info grid ───────────────────────────────────────────────────── */
.lead-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
}

.lead-info-item label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  display: block;
  margin-bottom: 0.15rem;
}

.lead-info-item .value {
  font-size: 0.9rem;
  color: #1e293b;
  word-break: break-word;
}

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination .page-link {
  color: var(--accent);
  border-radius: 0.4rem;
  margin: 0 1px;
}

.pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Admin nav section ────────────────────────────────────────────────── */
.nav-admin {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 0.5rem 0;
}

.nav-section-label {
  padding: 0.4rem 1.25rem 0.2rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
}

/* ── Kanban ───────────────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 1rem;
  min-height: calc(100vh - 180px);
}

.kanban-col {
  min-width: 220px;
  max-width: 260px;
  flex-shrink: 0;
  background: #f8fafc;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 0.75rem 0.75rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-cards {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60px;
  flex: 1;
}

.kanban-card {
  background: white;
  border-radius: 0.5rem;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: grab;
  border-left: 3px solid #e2e8f0;
  transition: box-shadow 0.15s;
}

.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.kanban-card.dragging { opacity: 0.5; }

.kanban-col.drag-over .kanban-cards {
  background: rgba(99,102,241,0.06);
  border-radius: 0 0 0.75rem 0.75rem;
}

.kanban-card .card-nombre {
  font-weight: 600;
  font-size: 0.875rem;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.kanban-card .card-contact {
  font-size: 0.75rem;
  color: #64748b;
}

/* ── Tags ─────────────────────────────────────────────────────────────── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.tag-pill .remove-tag {
  cursor: pointer;
  opacity: 0.7;
}

.tag-pill .remove-tag:hover { opacity: 1; }

/* ── Bulk action bar ──────────────────────────────────────────────────── */
.bulk-bar {
  background: #1e293b;
  color: white;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  display: none;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bulk-bar.visible { display: flex; }

/* ── Project color dot ────────────────────────────────────────────────── */
.proj-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Sidebar project selector ────────────────────────────────────────── */
.proj-selector {
  padding: 0.5rem 1rem;
  margin: 0.5rem;
  background: rgba(255,255,255,0.06);
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  font-size: 0.82rem;
}

.proj-selector:hover { background: rgba(255,255,255,0.1); }

.proj-dropdown {
  display: none;
  position: fixed;
  left: 250px;
  background: #1e293b;
  border-radius: 0.5rem;
  min-width: 200px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 200;
  overflow: hidden;
}

.proj-dropdown.show { display: block; }

.proj-dropdown a:hover { background: rgba(255,255,255,0.08); }

/* ── Hamburger button ─────────────────────────────────────────────────── */
.hamburger-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #475569;
  padding: 0.25rem 0.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 0.375rem;
}
.hamburger-btn:hover { background: #e2e8f0; }

/* ── Overlay mobile ───────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* Sidebar oculto por defecto, desliza al abrirse */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  /* Contenido ocupa todo el ancho */
  .main-content { margin-left: 0; }

  /* Topbar más compacto */
  .topbar { padding: 0.6rem 0.875rem; }
  .page-title { font-size: 1rem; }

  /* Cards y paneles sin padding excesivo */
  .card-panel, .table-panel { border-radius: 0.5rem; }
  .panel-body { padding: 0.875rem; }

  /* Stats en 2 columnas */
  .stat-card { padding: 0.875rem; }
  .stat-number { font-size: 1.6rem; }

  /* Ocultar columnas no esenciales en tabla de leads */
  .col-hide-mobile { display: none !important; }

  /* Formularios más cómodos */
  .form-control, .form-select { font-size: 1rem; }

  /* Botones más fáciles de tocar */
  .btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

  /* Grids de info de lead en 1 columna */
  .lead-info-grid { grid-template-columns: 1fr; }

  /* Proyecto dropdown */
  .proj-dropdown { left: 0; right: 0; top: auto; position: absolute; }

  /* Filtros apilados */
  .filter-bar .row { --bs-gutter-x: 0.5rem; }
}

@media (max-width: 480px) {
  .page-title { font-size: 0.95rem; }
  .stat-number { font-size: 1.4rem; }
  .panel-body { padding: 0.75rem; }
}
