/* ============================================================
   Intelligence Lab™ — Estilos Principales
   Vicente Orozco | Metodología D.A.T.A.™
   Light mode minimalista | Sin degradados
   ============================================================ */

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

/* --- Variables CSS --- */
:root {
  --azul-marino:      #1e3a8a;
  --azul-medio:       #2563eb;
  --azul-claro:       #3b82f6;
  --verde-esmeralda:  #10b981;
  --verde-claro:      #34d399;
  --gris-slate:       #6b7280;
  --naranja-vibrante: #f59e0b;
  --naranja-claro:    #fbbf24;
  --rojo-alerta:      #ef4444;

  /* Light mode */
  --bg-main:          #f4f6f9;
  --bg-card:          #ffffff;
  --bg-card-hover:    #f9fafb;
  --bg-sidebar:       #1a2e3b;
  --bg-sidebar-hover: #243d4e;
  --bg-sidebar-active:#2f4f63;
  --bg-input:         #ffffff;
  --border-subtle:    #e5e7eb;
  --border-medium:    #d1d5db;
  --text-primary:     #111827;
  --text-muted:       #6b7280;
  --text-dim:         #9ca3af;
  --text-sidebar:     #cbd5e1;
  --text-sidebar-dim: #64748b;
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card:      0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-modal:     0 20px 50px rgba(0,0,0,0.15);
  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        14px;
  --radius-xl:        20px;
  --transition:       all 0.18s ease;
  --sidebar-width:    252px;
}

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

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

a { color: var(--azul-medio); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--azul-claro); }

img { max-width: 100%; }

/* ============================================================
   LAYOUT — Sidebar + Main
   ============================================================ */

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

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo .logo-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  display: block;
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-sidebar-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 3px;
  display: block;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-sidebar-dim);
  padding: 14px 20px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  border-left: none;
}

.nav-item:hover {
  color: #ffffff;
  background: var(--bg-sidebar-hover);
}

.nav-item.active {
  color: #ffffff;
  background: var(--bg-sidebar-active);
  font-weight: 600;
}

.nav-item .nav-icon { font-size: 15px; width: 18px; text-align: center; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--naranja-vibrante);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--azul-medio);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name  { font-size: 13px; font-weight: 600; color: #ffffff; }
.user-role  { font-size: 11px; color: var(--text-sidebar-dim); }

/* --- Sidebar Collapse Toggle --- */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  cursor: pointer;
  color: var(--text-sidebar-dim);
  font-size: 11px;
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }

.sidebar-logo-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-logo-text { flex: 1; min-width: 0; }

/* Collapsed state */
.sidebar { transition: width 0.25s ease, transform 0.3s ease; overflow-x: hidden; }
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-logo { padding: 14px 8px; }
.sidebar.collapsed .sidebar-logo-inner { justify-content: center; }
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { width: 36px; height: 36px; font-size: 14px; background: rgba(255,255,255,0.08); border-radius: var(--radius-sm); }
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 4px; margin: 1px 4px; }
.sidebar.collapsed .nav-item .nav-label { display: none; }
.sidebar.collapsed .nav-item .nav-badge { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 12px 8px; }
.sidebar.collapsed .user-info { justify-content: center; gap: 0; }
.sidebar.collapsed .user-info > div:last-child { display: none; }
.sidebar.collapsed .btn-full { display: none; }
.sidebar.collapsed .divider { display: none; }

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content { margin-left: 64px; }

/* --- Top Bar --- */
.topbar {
  height: 58px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --- Business Context Badge --- */
.business-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #059669;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* --- Page Content --- */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 3px;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--border-medium);
}

.card-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon { font-size: 16px; color: var(--azul-medio); }

/* --- KPI Cards --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--border-medium);
}

/* Icono de la KPI card */
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon.blue   { background: #eff6ff; color: var(--azul-medio); }
.kpi-icon.green  { background: #ecfdf5; color: #059669; }
.kpi-icon.orange { background: #fffbeb; color: #d97706; }
.kpi-icon.gray   { background: #f3f4f6; color: #6b7280; }
.kpi-icon.red    { background: #fef2f2; color: #dc2626; }

.kpi-body { flex: 1; min-width: 0; }

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 4px;
}

.kpi-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.kpi-change {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.kpi-change.up      { color: #059669; background: #ecfdf5; }
.kpi-change.down    { color: #dc2626; background: #fef2f2; }
.kpi-change.neutral { color: var(--text-muted); background: #f3f4f6; }

.kpi-benchmark { font-size: 11px; color: var(--text-dim); }
.benchmark-indicator { font-size: 14px; margin-right: 2px; }

/* ============================================================
   FORMULARIOS
   ============================================================ */

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

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

.form-label span.required { color: var(--rojo-alerta); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder { color: var(--text-dim); }

select.form-control option {
  background: #ffffff;
  color: var(--text-primary);
}

textarea.form-control { resize: vertical; min-height: 90px; }

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

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

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--azul-marino);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}

.btn-success {
  background: var(--verde-esmeralda);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
  color: #fff;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--naranja-vibrante);
  color: #ffffff;
  font-weight: 700;
}

.btn-warning:hover { background: #d97706; color: #ffffff; }

.btn-danger {
  background: #fef2f2;
  color: var(--rojo-alerta);
  border: 1px solid #fecaca;
}

.btn-danger:hover { background: #fee2e2; }

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

.btn-ghost:hover {
  background: #f9fafb;
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon-only { padding: 8px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ============================================================
   TABLAS
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead tr {
  background: #f9fafb;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES & PILLS
   ============================================================ */

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success { background: #ecfdf5; color: #059669; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-info    { background: #eff6ff; color: #2563eb; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

/* ============================================================
   MODALES
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

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

.modal-close:hover { background: #fee2e2; color: var(--rojo-alerta); }

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ============================================================
   GAUGE / SCORE
   ============================================================ */

.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.gauge-svg { overflow: visible; }

.score-display {
  font-family: 'Montserrat', sans-serif;
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  line-height: 1;
  color: var(--text-primary);
}

.score-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.score-range {
  font-size: 12px;
  text-align: center;
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: 600;
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 9px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--azul-medio); border-bottom-color: var(--azul-medio); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   PROGRESS BARS
   ============================================================ */

.progress-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

.progress-fill.green  { background: var(--verde-esmeralda); }
.progress-fill.blue   { background: var(--azul-medio); }
.progress-fill.orange { background: var(--naranja-vibrante); }
.progress-fill.red    { background: var(--rojo-alerta); }

/* ============================================================
   GRID DE DIMENSIONES (Diagnóstico)
   ============================================================ */

.dimensions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dimension-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

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

.dimension-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.dimension-score {
  font-family: 'Montserrat', sans-serif;
  font-size: 20px;
  font-weight: 800;
}

/* ============================================================
   AI ANALYSIS BOX
   ============================================================ */

.ai-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ai-box-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--azul-medio);
}

.ai-box-header i {
  font-size: 14px;
  background: #eff6ff;
  color: var(--azul-medio);
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
}

.ai-box-content {
  padding: 22px 24px;
  font-size: 14px;
  line-height: 1.75;
  color: #374151;
}

/* Markdown renderizado dentro del ai-box */
.ai-box-content h3 {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.ai-box-content h3:first-child { margin-top: 0; }

.ai-box-content h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1e40af;
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ai-box-content p {
  margin: 0 0 12px;
  color: #374151;
}

.ai-box-content p:last-child { margin-bottom: 0; }

.ai-box-content ul {
  margin: 8px 0 14px 0;
  padding-left: 0;
  list-style: none;
}

.ai-box-content ul li {
  padding: 5px 0 5px 22px;
  position: relative;
  color: #374151;
  font-size: 13.5px;
}

.ai-box-content ul li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 13px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--azul-medio);
}

.ai-box-content strong { color: #111827; font-weight: 700; }
.ai-box-content em     { color: #4b5563; font-style: italic; }

.ai-box-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 18px 0;
}

/* ── Tablas markdown (md-table) ─────────────────────────── */
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0 16px;
  border-radius: 8px;
  overflow: hidden;
}
.md-table th {
  background: #1e3a8a;
  color: #fff;
  padding: 9px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
}
.md-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
}
.md-table tr:last-child td { border-bottom: none; }
.md-table tr:nth-child(even) td { background: #f8fafc; }

/* ── Markdown dentro de burbujas de chat (asistente) ─────── */
.chat-ai-bubble p       { margin: 0 0 10px; }
.chat-ai-bubble p:last-child { margin-bottom: 0; }
.chat-ai-bubble ul      { padding-left: 18px; margin: 6px 0 12px; }
.chat-ai-bubble ol      { padding-left: 18px; margin: 6px 0 12px; }
.chat-ai-bubble li      { margin-bottom: 4px; }
.chat-ai-bubble h3,
.chat-ai-bubble h4,
.chat-ai-bubble h5      { font-size: 13px; font-weight: 700; color: #1e3a8a; margin: 14px 0 6px; }
.chat-ai-bubble strong  { font-weight: 700; }
.chat-ai-bubble em      { font-style: italic; color: rgba(255,255,255,.8); }
.chat-ai-bubble hr      { border: none; border-top: 1px solid rgba(255,255,255,.2); margin: 12px 0; }
.chat-ai-bubble .md-table { font-size: 12px; }
.chat-ai-bubble .md-table th { font-size: 11px; padding: 7px 10px; }
.chat-ai-bubble .md-table td { padding: 6px 10px; color: #374151; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ============================================================
   ESTADOS DE MARKOV — VISUALIZACIÓN
   ============================================================ */

.markov-states {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.markov-state-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-medium);
  background: var(--bg-main);
  color: var(--text-muted);
}

.markov-matrix-table {
  font-size: 12px;
  overflow: auto;
}

.markov-matrix-table td, .markov-matrix-table th {
  padding: 8px 12px;
  text-align: center;
  border: 1px solid var(--border-subtle);
}

.markov-matrix-table th { background: #f9fafb; font-size: 11px; color: var(--text-dim); }

.matrix-cell-heat {
  border-radius: 4px;
  font-weight: 600;
}

/* ============================================================
   TOOLTIPS
   ============================================================ */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 999;
  box-shadow: var(--shadow-card);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-modal);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ============================================================
   ANIMACIONES
   ============================================================ */

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

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

.animate-fade-in  { animation: fadeIn 0.3s ease; }
.animate-slide-up { animation: slideUp 0.25s ease; }
.animate-count-up { animation: countUp 0.5s ease; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--azul-medio);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ============================================================
   UTILIDADES
   ============================================================ */

.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-between{ justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.flex-1         { flex: 1; }
.gap-4          { gap: 4px; }
.gap-6          { gap: 6px; }
.gap-8          { gap: 8px; }
.gap-10         { gap: 10px; }
.gap-12         { gap: 12px; }
.gap-16         { gap: 16px; }
.gap-20         { gap: 20px; }
.flex-wrap      { flex-wrap: wrap; }

.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; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-green  { color: #059669; }
.text-blue   { color: var(--azul-medio); }
.text-orange { color: var(--naranja-vibrante); }
.text-red    { color: var(--rojo-alerta); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 11px; }
.text-lg     { font-size: 18px; }
.text-xl     { font-size: 22px; }
.font-mono   { font-family: 'Courier New', monospace; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-28 { margin-top: 28px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-28 { margin-bottom: 28px; }
.ml-1  { margin-left: 4px; }

.p-0 { padding: 0; }

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 20px 0;
}

.separator {
  width: 100%;
  height: 1px;
  background: var(--border-subtle);
  margin: 24px 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
  .login-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   SCROLLBAR PERSONALIZADO
   ============================================================ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================================
   SIDEBAR SCROLLBAR (dark)
   ============================================================ */

.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
