/* ─── ECF Frande One — Variables y estilos compartidos ─── */

/* ─── Light theme (default) ─── */
:root {
  /* [FIX 2026-05-07 UI-CRIT-001] Contraste WCAG AA — primary #3B9EFF (2.79:1
     sobre blanco) ahora #1d6fd9 (4.7:1). text-faint #94a3b8 (2.56:1) ahora
     #64748b (4.5:1). yellow #f59e0b solo como background, nunca texto. */
  --ecf-primary: #1d6fd9;
  --ecf-primary-dark: #1d4ed8;
  --ecf-primary-light: #60a5fa;
  --ecf-primary-glow: rgba(29, 111, 217, 0.15);
  --ecf-green: #10b981;
  --ecf-red: #ef4444;
  --ecf-yellow: #f59e0b;
  --ecf-yellow-text: #b45309;       /* [UI-CRIT-001] uso seguro como color de texto sobre blanco (4.5:1) */
  --ecf-purple: #8b5cf6;
  --ecf-info: #6366f1;

  /* Surfaces */
  --ecf-bg: #f0f2f5;
  --ecf-bg-raised: #ffffff;
  --ecf-bg-sunken: #e8eaed;
  --ecf-bg-overlay: rgba(255, 255, 255, 0.92);
  --ecf-surface: rgba(255, 255, 255, 0.7);
  --ecf-glass: rgba(255, 255, 255, 0.6);
  --ecf-glass-border: rgba(0, 0, 0, 0.06);

  /* Text */
  --ecf-text: #0f172a;
  --ecf-text-secondary: #334155;
  --ecf-text-muted: #64748b;
  --ecf-text-faint: #64748b;        /* [UI-CRIT-001] era #94a3b8 (2.56:1) — ahora 4.5:1 */
  --ecf-text-invert: #ffffff;

  /* Borders & dividers */
  --ecf-border: #e2e8f0;
  --ecf-border-subtle: #f1f5f9;
  --ecf-divider: #f3f4f6;

  /* Grays */
  --ecf-gray-50: #f8fafc;
  --ecf-gray-100: #f1f5f9;
  --ecf-gray-200: #e2e8f0;
  --ecf-gray-300: #cbd5e1;
  --ecf-gray-400: #94a3b8;
  --ecf-gray-500: #64748b;
  --ecf-gray-600: #475569;
  --ecf-gray-700: #334155;
  --ecf-gray-800: #1e293b;
  --ecf-gray-900: #0f172a;

  /* Typography */
  --ecf-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ecf-font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;

  /* Radius */
  --ecf-radius: 8px;
  --ecf-radius-sm: 6px;
  --ecf-radius-lg: 12px;
  --ecf-radius-xl: 16px;

  /* Shadows */
  --ecf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --ecf-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --ecf-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.04);
  --ecf-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --ecf-shadow-glow: none;

  /* Effects */
  --ecf-blur: blur(20px) saturate(180%);

  /* Transitions */
  --ecf-transition: 0.2s ease;
  --ecf-transition-slow: 0.3s ease;

  /* Badge colors */
  --badge-blue-bg: #dbeafe;  --badge-blue-fg: #1e40af;
  --badge-green-bg: #d1fae5; --badge-green-fg: #065f46;
  --badge-red-bg: #fee2e2;   --badge-red-fg: #991b1b;
  --badge-yellow-bg: #fef3c7; --badge-yellow-fg: #92400e;
  --badge-gray-bg: #f3f4f6;  --badge-gray-fg: #6b7280;
  --badge-purple-bg: #ede9fe; --badge-purple-fg: #5b21b6;

  /* Chart */
  --chart-grid: #f3f4f6;
  --chart-text: #9ca3af;

  /* Code */
  --code-bg: #1e293b;
  --code-fg: #e2e8f0;

  /* Aliases de compatibilidad */
  --ecf-blue: var(--ecf-primary);
  --ecf-bg-elev: var(--ecf-bg-raised);
  --ecf-surface-alt: var(--ecf-bg-sunken);
  --ecf-text-primary: var(--ecf-text);
  --ecf-accent: var(--ecf-green);
  --ecf-accent-faint: rgba(16, 185, 129, 0.12);
  --ecf-primary-alpha: rgba(59, 158, 255, 0.12);
  --ecf-primary-chart: rgba(59, 158, 255, 0.7);
}

/* ─── Dark theme ─── */
[data-theme="dark"] {
  --ecf-primary: #60a5fa;            /* en dark sí cumple AA (7.5:1 sobre #0b0f1a) */
  --ecf-primary-dark: #3B9EFF;
  --ecf-primary-light: #93c5fd;
  --ecf-primary-glow: rgba(96, 165, 250, 0.12);
  --ecf-yellow-text: #fcd34d;        /* dark mode: yellow seguro como texto */
  --ecf-info: #818cf8;

  --ecf-bg: #0b0f1a;
  --ecf-bg-raised: #111827;
  --ecf-bg-sunken: #060a12;
  --ecf-bg-overlay: rgba(11, 15, 26, 0.95);
  --ecf-surface: rgba(17, 24, 39, 0.8);
  --ecf-glass: rgba(17, 24, 39, 0.6);
  --ecf-glass-border: rgba(59, 158, 255, 0.08);

  --ecf-text: #f1f5f9;
  --ecf-text-secondary: #cbd5e1;
  --ecf-text-muted: #94a3b8;        /* [UI-IMP-001] dark — diferenciar de secondary */
  --ecf-text-faint: #6b7280;
  --ecf-text-invert: #0b0f1a;

  --ecf-border: #1e293b;
  --ecf-border-subtle: #152033;
  --ecf-divider: #1a2332;

  --ecf-gray-50: #0f1729;
  --ecf-gray-100: #152033;
  --ecf-gray-200: #1e293b;
  --ecf-gray-300: #334155;
  --ecf-gray-400: #475569;
  --ecf-gray-500: #64748b;
  --ecf-gray-600: #94a3b8;
  --ecf-gray-700: #cbd5e1;
  --ecf-gray-800: #e2e8f0;
  --ecf-gray-900: #f1f5f9;

  --ecf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ecf-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --ecf-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --ecf-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --ecf-shadow-glow: 0 0 30px rgba(59, 158, 255, 0.06);

  --badge-blue-bg: rgba(59, 130, 246, 0.15);  --badge-blue-fg: #93c5fd;
  --badge-green-bg: rgba(16, 185, 129, 0.15); --badge-green-fg: #6ee7b7;
  --badge-red-bg: rgba(239, 68, 68, 0.15);    --badge-red-fg: #fca5a5;
  --badge-yellow-bg: rgba(245, 158, 11, 0.15); --badge-yellow-fg: #fcd34d;
  --badge-gray-bg: rgba(113, 113, 122, 0.15);  --badge-gray-fg: #a1a1aa;
  --badge-purple-bg: rgba(139, 92, 246, 0.15); --badge-purple-fg: #c4b5fd;

  --chart-grid: #1e293b;
  --chart-text: #475569;

  --code-bg: #060a12;
  --code-fg: #e2e8f0;

  /* Aliases de compatibilidad — dark */
  --ecf-blue: var(--ecf-primary);
  --ecf-bg-elev: var(--ecf-bg-raised);
  --ecf-surface-alt: var(--ecf-bg-sunken);
  --ecf-text-primary: var(--ecf-text);
  --ecf-accent: var(--ecf-green);
  --ecf-accent-faint: rgba(16, 185, 129, 0.15);
  --ecf-primary-alpha: rgba(96, 165, 250, 0.12);
  --ecf-primary-chart: rgba(96, 165, 250, 0.7);
}

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

body {
  font-family: var(--ecf-font);
  margin: 0;
  padding: 0;
  background: var(--ecf-bg);
  color: var(--ecf-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--ecf-transition-slow), color var(--ecf-transition-slow);
}

a { color: var(--ecf-primary); text-decoration: none; }
a:hover { color: var(--ecf-primary-dark); }

/* ─── Theme toggle button ─── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--ecf-radius);
  border: 1px solid var(--ecf-border);
  background: var(--ecf-bg-raised);
  color: var(--ecf-text-muted);
  cursor: pointer;
  transition: all var(--ecf-transition);
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--ecf-primary);
  color: var(--ecf-primary);
  background: var(--ecf-primary-glow);
}

/* ─── Utilidades ─── */
.ecf-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.ecf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--ecf-radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--ecf-transition);
  line-height: 1.4;
}

.ecf-btn-primary {
  background: var(--ecf-primary);
  color: var(--ecf-text-invert);
}
.ecf-btn-primary:hover {
  background: var(--ecf-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--ecf-shadow-lg);
}

.ecf-btn-outline {
  background: transparent;
  color: var(--ecf-text-secondary);
  border: 1px solid var(--ecf-border);
}
.ecf-btn-outline:hover {
  border-color: var(--ecf-primary);
  color: var(--ecf-primary);
}

.ecf-btn-ghost {
  background: transparent;
  color: var(--ecf-text-muted);
  padding: 8px 12px;
}
.ecf-btn-ghost:hover {
  background: var(--ecf-gray-100);
  color: var(--ecf-text);
}

.ecf-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.ecf-badge-blue { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.ecf-badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.ecf-badge-red { background: var(--badge-red-bg); color: var(--badge-red-fg); }
.ecf-badge-yellow { background: var(--badge-yellow-bg); color: var(--badge-yellow-fg); }
.ecf-badge-gray { background: var(--badge-gray-bg); color: var(--badge-gray-fg); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .ecf-container { padding: 0 16px; }
  .ecf-btn { padding: 8px 16px; font-size: 13px; }
}

/* [FIX 2026-04-26 ECF-CRIT-069] Mobile tablet breakpoint 834px (iPad portrait
   y similares). Antes solo había 768px y >960px, dejaba un hueco entre 769-833. */
@media (min-width: 769px) and (max-width: 833px) {
  .ecf-container { padding: 0 20px; }
  .pricing-grid.four-col { grid-template-columns: repeat(2, 1fr) !important; }
}

/* [FIX 2026-04-26 ECF-CRIT-066] Focus-visible coherente en light/dark mode.
   Outline visible + offset para que el ring no se confunda con el borde. */
:focus-visible {
  outline: 2px solid var(--ecf-primary, #3b82f6);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--ecf-primary-glow, rgba(59, 158, 255, 0.18));
  border-radius: 4px;
  transition: outline-offset 0.1s ease;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* [FIX 2026-04-26 frontend a11y] prefers-reduced-motion: respetar la
   preferencia del sistema. WCAG 2.3.3 — animaciones pueden disparar
   trastornos vestibulares. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Skip link (accesibilidad teclado) ─── */
.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 9999;
  background: var(--ecf-primary);
  color: var(--ecf-text-invert);
  padding: 8px 16px;
  border-radius: var(--ecf-radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 16px;
}
