/* ═══════════════════════════════════════════════════════
   🎨 Dashboard Premium — Grupo ABC Automation
   Dark Mode + Glassmorphism + Micro-animations
   ═══════════════════════════════════════════════════════ */

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

/* ─── CSS Variables ─── */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);

  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-glow: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.15);
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --pink: #ec4899;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.1);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: bgShift 20s ease-in-out infinite;
}

@keyframes bgShift {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ─── Layout ─── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-logo span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-secondary);
  border-left: 3px solid var(--accent-primary);
}

.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  min-height: 100vh;
}

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

.page-header h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* ─── KPI Cards Grid ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-primary), var(--purple));
  opacity: 0;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.kpi-card:hover::before { opacity: 1; }

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

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-card .kpi-icon.green { background: var(--green-glow); }
.kpi-card .kpi-icon.red { background: var(--red-glow); }
.kpi-card .kpi-icon.yellow { background: var(--yellow-glow); }
.kpi-card .kpi-icon.blue { background: var(--blue-glow); }
.kpi-card .kpi-icon.purple { background: var(--accent-glow); }

.kpi-card .kpi-trend {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-card .kpi-trend.up { color: var(--green); }
.kpi-card .kpi-trend.down { color: var(--red); }

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Content Grid (2 columns) ─── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.content-grid.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.content-grid.full {
  grid-template-columns: 1fr;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-glow);
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

.card-body.no-padding { padding: 0; }

/* ─── Pipeline Visual ─── */
.pipeline {
  display: flex;
  gap: 2px;
  padding: 20px;
  overflow-x: auto;
}

.pipeline-stage {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  transition: var(--transition);
  cursor: pointer;
}

.pipeline-stage:hover {
  background: var(--accent-glow);
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.pipeline-stage .stage-count {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.pipeline-stage .stage-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pipeline-stage .stage-value {
  font-size: 11px;
  color: var(--green);
  margin-top: 4px;
  font-weight: 500;
}

.pipeline-arrow {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Activity Timeline ─── */
.timeline {
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
}

.timeline::-webkit-scrollbar { width: 4px; }
.timeline::-webkit-scrollbar-track { background: transparent; }
.timeline::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 4px; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-glass);
  transition: var(--transition-fast);
  position: relative;
}

.timeline-item:hover { background: var(--bg-glass); margin: 0 -20px; padding: 12px 20px; }
.timeline-item:last-child { border-bottom: none; }

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

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-content .desc {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-content .time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Table ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-glass);
  transition: var(--transition-fast);
}

.data-table tr:hover td {
  background: var(--bg-glass);
}

.data-table tr:last-child td { border-bottom: none; }

/* ─── Status Badges ─── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status.nuevo { background: var(--blue-glow); color: var(--blue); }
.status.contactado { background: var(--yellow-glow); color: var(--yellow); }
.status.calificado { background: var(--accent-glow); color: var(--accent-secondary); }
.status.clase_muestra { background: rgba(236, 72, 153, 0.15); color: var(--pink); }
.status.inscrito { background: var(--green-glow); color: var(--green); }
.status.perdido { background: var(--red-glow); color: var(--red); }
.status.disponible { background: var(--green-glow); color: var(--green); }
.status.en_servicio { background: var(--yellow-glow); color: var(--yellow); }
.status.ocupado { background: var(--red-glow); color: var(--red); }
.status.descanso { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.status.vencido { background: var(--red-glow); color: var(--red); }

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

/* ─── Score Bar ─── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-bar .bar {
  flex: 1;
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

.score-bar .score-value {
  font-size: 12px;
  font-weight: 700;
  min-width: 30px;
  text-align: right;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-secondary);
  transition: var(--transition);
  font-family: inherit;
}

.btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--purple));
  color: white;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-success {
  background: var(--green-glow);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.2);
}

.btn-danger {
  background: var(--red-glow);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
}

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

/* ─── Chart Container ─── */
.chart-container {
  position: relative;
  height: 280px;
  padding: 10px;
}

/* ─── Map placeholder ─── */
.map-container {
  height: 350px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  position: relative;
  overflow: hidden;
}

.map-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  z-index: 2;
}

.map-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.3;
  animation: pingDot 2s infinite;
}

@keyframes pingDot {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(2); opacity: 0; }
}

.map-dot:hover { transform: scale(1.5); z-index: 3; }

.map-dot .tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  margin-bottom: 8px;
  box-shadow: var(--shadow-md);
}

.map-dot:hover .tooltip { opacity: 1; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--red-glow); color: var(--red); }

.modal-body { padding: 24px; }

/* ─── Form Inputs ─── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m19 9-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}

/* ─── Toast Notifications ─── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s ease;
  min-width: 300px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--yellow); }

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

/* ─── Loading Spinner ─── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-glass);
  border-top: 2px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Assignment Demo Panel ─── */
.assignment-demo {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
  border: 1px dashed var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.assignment-result {
  background: var(--bg-card);
  border: 1px solid var(--green);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 16px;
  animation: resultIn 0.5s ease;
}

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

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.score-item {
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
}

.score-item .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-item .value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .content-grid { grid-template-columns: 1fr; }
  .content-grid.three-col { grid-template-columns: 1fr 1fr; }
  .score-breakdown { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline { flex-wrap: wrap; }
  .pipeline-arrow { display: none; }
  .content-grid.three-col { grid-template-columns: 1fr; }
}
