/* =========================================================
   REGIS - Dashboard Styles
   Paleta: Verde #00843D / Azul #0055A4 / Gris / Blanco
   ========================================================= */

:root {
  --regis-green:        #00843D;
  --regis-green-hover:  #006B31;
  --regis-green-light:  #E6F4EC;
  --regis-green-dark:   #004D24;
  --regis-blue:         #0055A4;
  --regis-blue-hover:   #004080;
  --regis-blue-light:   #E6EEF7;
  --regis-blue-dark:    #003366;
  --white:              #ffffff;
  --gray-50:            #f8fafc;
  --gray-100:           #f1f5f9;
  --gray-200:           #e2e8f0;
  --gray-300:           #cbd5e1;
  --gray-400:           #94a3b8;
  --gray-500:           #64748b;
  --gray-600:           #475569;
  --gray-700:           #334155;
  --gray-800:           #1e293b;
  --gray-900:           #0f172a;
  --red:                #dc2626;
  --red-light:          #fef2f2;
  --blue:               #0055A4;
  --blue-light:         #dbeafe;
  --yellow:             #f59e0b;
  --yellow-light:       #fef3c7;
  --purple:             #8b5cf6;
  --purple-light:       #ede9fe;
  --radius-sm:          6px;
  --radius-md:          10px;
  --radius-lg:          16px;
  --shadow-sm:          0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md:          0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg:          0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

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

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

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

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.sidebar-logo img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.sidebar-logo span {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0.25rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--gray-600);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover { background: var(--gray-50); color: var(--gray-800); }

.nav-item.active {
  background: var(--regis-green-light);
  color: var(--regis-green);
  font-weight: 600;
}

.nav-item svg { flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--regis-green);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--gray-100);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
  backdrop-filter: blur(4px);
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
}

/* ---------- TOP BAR ---------- */
.top-bar {
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-600);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

.menu-toggle:hover { background: var(--gray-100); }

.top-bar-title { flex: 1; }
.top-bar-title h1 { font-size: 1.25rem; font-weight: 700; color: var(--gray-900); }

.last-update { font-size: 0.75rem; color: var(--gray-400); }

.top-bar-actions { display: flex; gap: 0.75rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--regis-green), var(--regis-green-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(0,132,61,0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(0,132,61,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-danger { background: var(--red); color: white; }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }
.btn-xs { padding: 0.375rem 0.75rem; font-size: 0.75rem; }

/* ---------- CONTENT SECTIONS ---------- */
.content-wrapper { padding: 1.5rem; }

.content-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.content-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-header-bar h2 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }

/* ---------- STATS GRID ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s ease;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon.total { background: var(--regis-green-light); color: var(--regis-green); }
.stat-card-icon.today { background: var(--regis-blue-light); color: var(--regis-blue); }
.stat-card-icon.week { background: var(--yellow-light); color: var(--yellow); }
.stat-card-icon.month { background: var(--purple-light); color: var(--purple); }

.stat-card-value { display: block; font-size: 1.75rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-card-label { font-size: 0.8125rem; color: var(--gray-500); }

/* ---------- CHARTS ---------- */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--gray-100); }
.chart-header h3 { font-size: 1rem; font-weight: 600; color: var(--gray-900); }
.chart-subtitle { font-size: 0.8125rem; color: var(--gray-400); margin-top: 0.25rem; }
.chart-body { padding: 1.25rem 1.5rem; }

/* Conversion stats */
.conversion-stats { display: flex; flex-direction: column; gap: 1.25rem; }
.conversion-item { display: flex; flex-direction: column; gap: 0.5rem; }
.conversion-bar { height: 8px; background: var(--gray-100); border-radius: 9999px; overflow: hidden; }
.conversion-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--regis-green), var(--regis-green-dark));
  border-radius: 9999px;
  transition: width 0.6s ease;
}
.conversion-info { display: flex; justify-content: space-between; align-items: center; }
.conversion-label { font-size: 0.875rem; color: var(--gray-600); }
.conversion-value { font-size: 0.875rem; font-weight: 600; color: var(--gray-900); }

/* ---------- TABLES ---------- */
.table-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.table-header h3 { font-size: 1rem; font-weight: 600; color: var(--gray-900); }

.link-view-all { font-size: 0.875rem; color: var(--regis-green); text-decoration: none; font-weight: 500; }
.link-view-all:hover { text-decoration: underline; }

.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  text-align: left;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }

.status-badge.nuevo { background: var(--regis-green-light); color: var(--regis-green-dark); }
.status-badge.nuevo::before { background: var(--regis-green); }

.status-badge.contactado { background: var(--blue-light); color: #1e40af; }
.status-badge.contactado::before { background: var(--blue); }

.status-badge.calificado { background: var(--yellow-light); color: #92400e; }
.status-badge.calificado::before { background: var(--yellow); }

.status-badge.convertido {
  background: var(--regis-green-light);
  color: var(--regis-green-dark);
  border: 1px solid var(--regis-green);
}
.status-badge.convertido::before { background: var(--regis-green); }

.status-badge.perdido { background: var(--red-light); color: #991b1b; }
.status-badge.perdido::before { background: var(--red); }

/* Situación badges */
.situacion-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.situacion-badge.tengo_farmacia { background: var(--regis-blue-light); color: var(--regis-blue-dark); }
.situacion-badge.deseo_emprender { background: var(--regis-green-light); color: var(--regis-green-dark); }

/* Action buttons */
.action-btns { display: flex; gap: 0.375rem; }

.action-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.action-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.action-btn.view:hover { color: var(--blue); background: var(--blue-light); }
.action-btn.edit:hover { color: var(--regis-green); background: var(--regis-green-light); }
.action-btn.delete:hover { color: var(--red); background: var(--red-light); }

/* ---------- FILTERS ---------- */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group { position: relative; }

.filter-input, .filter-select {
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  outline: none;
  min-width: 200px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--regis-green);
  box-shadow: 0 0 0 3px rgba(0,132,61,0.1);
}

.filter-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.filter-group:has(.filter-icon) .filter-input { padding-right: 2.5rem; }

.date-group { display: flex; align-items: center; gap: 0.5rem; }
.date-group .filter-input { min-width: 140px; }
.date-separator { font-size: 0.875rem; color: var(--gray-400); }

/* ---------- TABLE FOOTER ---------- */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.bulk-actions { display: flex; align-items: center; gap: 0.75rem; }
.bulk-count { font-size: 0.875rem; color: var(--gray-600); font-weight: 500; }

.pagination { display: flex; gap: 0.25rem; }

.page-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-btn:hover { background: var(--gray-50); border-color: var(--gray-300); }
.page-btn.active { background: var(--regis-green); color: white; border-color: var(--regis-green); }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- ACTIVITY TIMELINE ---------- */
.activity-timeline {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
}

.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-icon.registro { background: var(--regis-green-light); color: var(--regis-green); }
.timeline-icon.cambio_estado { background: var(--blue-light); color: var(--blue); }
.timeline-icon.eliminacion { background: var(--red-light); color: var(--red); }

.timeline-content { flex: 1; }
.timeline-content p { font-size: 0.875rem; color: var(--gray-700); margin-bottom: 0.25rem; }
.timeline-content .timeline-meta { font-size: 0.75rem; color: var(--gray-400); }

/* ---------- MODAL ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.modal-header h3 { font-size: 1.125rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--gray-700); }

.modal-body { padding: 1.5rem; }

.lead-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--gray-100);
}

.lead-detail-row:last-child { border-bottom: none; }

.lead-detail-label { font-size: 0.875rem; color: var(--gray-500); }
.lead-detail-value { font-size: 0.875rem; color: var(--gray-800); font-weight: 500; text-align: right; max-width: 60%; }

/* ---------- TOAST ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.3s ease;
  max-width: 400px;
}

.toast.success { border-left: 4px solid var(--regis-green); }
.toast.error { border-left: 4px solid var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  margin-left: auto;
}

/* ---------- EMPTY STATE ---------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--gray-400);
}
.empty-state h4 { font-size: 1rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.875rem; color: var(--gray-500); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .charts-row .chart-card.wide { grid-column: 1; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-input, .filter-select { width: 100%; min-width: auto; }
  .date-group { flex-direction: column; }
  .table-footer { flex-direction: column; gap: 1rem; }
  .top-bar-actions { display: none; }
}

/* Checkbox en tabla */
.data-table input[type="checkbox"] {
  appearance: none;
  width: 1rem; height: 1rem;
  border: 2px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.data-table input[type="checkbox"]:checked {
  background: var(--regis-green);
  border-color: var(--regis-green);
}

.data-table input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 0.3rem; height: 0.55rem;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -55%) rotate(45deg);
}

/* Status select en tabla */
.status-select {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  color: var(--gray-700);
}

.status-select:focus {
  border-color: var(--regis-green);
  outline: none;
}
