/* LeadFlow Design System — v2
   Paleta OKLCH, vocabulario consistente, sin decoración redundante.
   Todas las plantillas referencian este archivo. */

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

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  /* Superficie — dark base ligeramente tintada hacia índigo (no el azul Tailwind) */
  --bg:             oklch(0.12 0.008 265);
  --surface-1:      oklch(0.17 0.008 265);
  --surface-2:      oklch(0.21 0.008 265);
  --surface-3:      oklch(0.27 0.008 265);

  --border-subtle:  oklch(0.24 0.007 265);
  --border:         oklch(0.30 0.007 265);
  --border-strong:  oklch(0.40 0.006 265);

  /* Texto */
  --text-high:      oklch(0.96 0.003 265);
  --text-mid:       oklch(0.72 0.006 265);
  --text-low:       oklch(0.52 0.005 265);
  --text-disabled:  oklch(0.40 0.004 265);

  /* Acento primario — índigo diferenciado del #2563eb de Tailwind */
  --accent:         oklch(0.60 0.19 272);
  --accent-hover:   oklch(0.53 0.19 272);
  --accent-subtle:  oklch(0.20 0.06 272);
  --accent-text:    oklch(0.96 0.004 272);

  /* Semántico */
  --success:        oklch(0.70 0.17 145);
  --success-bg:     oklch(0.17 0.05 145);
  --success-border: oklch(0.28 0.08 145);

  --warning:        oklch(0.78 0.14 68);
  --warning-bg:     oklch(0.17 0.05 68);
  --warning-border: oklch(0.30 0.09 68);

  --danger:         oklch(0.62 0.20 25);
  --danger-bg:      oklch(0.17 0.06 25);
  --danger-border:  oklch(0.30 0.10 25);

  --frozen:         oklch(0.63 0.16 232);
  --frozen-bg:      oklch(0.17 0.05 232);
  --frozen-border:  oklch(0.28 0.08 232);

  /* Forma */
  --r-xs:  3px;
  --r-sm:  5px;
  --r-md:  7px;
  --r-lg:  10px;

  /* Curvas de easing personalizadas */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);   /* salidas rápidas, deceleran suave */
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);   /* movimiento en pantalla */

  /* Transiciones estándar — usan la curva personalizada, no el 'ease' genérico */
  --t:      150ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-md:   260ms cubic-bezier(0.22, 1, 0.36, 1);
  --t-slow: 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-mid);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Tipografía ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-high);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; font-weight: 500; }

p { color: var(--text-mid); line-height: 1.65; max-width: 68ch; }

a { color: var(--accent); text-decoration: none; transition: opacity var(--t); }
a:hover { opacity: 0.8; }

code, kbd, pre {
  font-family: 'Geist Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.875em;
}

/* Números tabulares para datos */
.tabnum, .num-display {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ─── Layout base ─────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-content {
  padding: 28px 24px;
  max-width: 1160px;
  margin: 0 auto;
}

/* ─── Header / Nav ────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-high);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.app-logo img {
  height: 26px;
  width: auto;
}

.app-logo .logo-accent { color: var(--accent); }

.app-logo-sep {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.logo-context {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-low);
  letter-spacing: 0;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-nav a {
  color: var(--text-low);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  transition: color var(--t), background var(--t);
  white-space: nowrap;
}

.app-nav a:hover {
  color: var(--text-mid);
  background: var(--surface-3);
  opacity: 1;
}

.app-nav a.active {
  color: var(--text-high);
  background: var(--surface-3);
}

/* ─── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t),
              transform var(--t), opacity var(--t);
  white-space: nowrap;
  line-height: 1;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  opacity: 1;
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-mid);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text-high);
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-low);
  border-color: var(--border-subtle);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text-mid);
  border-color: var(--border);
  opacity: 1;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  opacity: 1;
}

.btn-sm { padding: 5px 12px; font-size: 12px; gap: 5px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Formularios ─────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-high);
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-disabled);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.form-input.error { border-color: var(--danger); }
.form-hint { font-size: 11px; color: var(--text-low); }
.form-error { font-size: 12px; color: var(--danger); }

/* ─── Tarjetas ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 20px;
}

.card-sm { padding: 14px 16px; }
.card-lg { padding: 28px; }

/* ─── Badges / Pills ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-xs);
  line-height: 1.4;
  white-space: nowrap;
}

.badge-accent   { background: var(--accent-subtle);  color: var(--accent); }
.badge-success  { background: var(--success-bg);  color: var(--success); }
.badge-warning  { background: var(--warning-bg);  color: var(--warning); }
.badge-danger   { background: var(--danger-bg);   color: var(--danger); }
.badge-frozen   { background: var(--frozen-bg);   color: var(--frozen); }
.badge-neutral  { background: var(--surface-3);   color: var(--text-mid); }

/* ─── Stats / Métricas ────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--t-md), background var(--t-md);
}

.stat-card:hover {
  border-color: var(--border);
  background: var(--surface-2);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-high);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-low);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card.is-danger  .stat-value { color: var(--danger); }
.stat-card.is-warning .stat-value { color: var(--warning); }
.stat-card.is-success .stat-value { color: var(--success); }
.stat-card.is-frozen  .stat-value { color: var(--frozen); }
.stat-card.is-accent  .stat-value { color: var(--accent); }

/* ─── Tabla ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-low);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-mid);
  vertical-align: middle;
  transition: background var(--t);
}

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

.data-table tr:hover td { background: var(--surface-1); }

/* ─── Barra de progreso ───────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width var(--t-md);
}

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-info    { background: var(--accent-subtle); color: var(--accent); border: 1px solid oklch(0.30 0.08 272); }

/* ─── Separadores ─────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-low);
  font-size: 12px;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-high);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 260ms var(--ease-out);
  transform: translateY(10px);
  z-index: 999;
  max-width: 320px;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-low);
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 14px;
  opacity: 0.35;
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-low);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-disabled);
  margin-bottom: 20px;
}

/* ─── Banner de impersonation ─────────────────────────────────────────────── */
.imp-bar {
  background: var(--warning-bg);
  border-bottom: 1px solid var(--warning-border);
  padding: 9px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--warning);
  flex-wrap: wrap;
}

/* ─── Utilidades ──────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.text-high     { color: var(--text-high); }
.text-mid      { color: var(--text-mid); }
.text-low      { color: var(--text-low); }
.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-frozen   { color: var(--frozen); }

.flex           { display: flex; }
.flex-center    { display: flex; align-items: center; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.gap-4          { gap: 4px; }
.gap-8          { gap: 8px; }
.gap-12         { gap: 12px; }
.gap-16         { gap: 16px; }
.gap-20         { gap: 20px; }
.gap-24         { gap: 24px; }

.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-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.font-mono { font-family: 'Geist Mono', ui-monospace, monospace; }

/* ─── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Focus visible global ────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) { outline: none; }

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
