@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800&family=Source+Sans+3:wght@400;500;600&display=swap');

/* ── Tokens base (marca Complexity) ── */
:root {
  --brand-blue: #6CAED1;
  --brand-blue-hover: #5a9fc4;
  --brand-blue-light: #8ecae6;
  --brand-black: #000000;
  --primary: 201 52% 62%;
  --success: 152 45% 48%;
  --warning: 42 70% 52%;
  --danger: 0 55% 58%;
  --radius: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --font-display: "Montserrat", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Avenir", "Avenir Next", system-ui, sans-serif;
  --header-offset: 8.75rem;
}

html.dark {
  --background: 0 0% 4%;
  --foreground: 0 0% 96%;
  --card: 0 0% 7%;
  --surface: 0 0% 9%;
  --surface-elevated: 0 0% 11%;
  --muted: 0 0% 14%;
  --muted-foreground: 0 0% 58%;
  --border: 0 0% 16%;
  --border-subtle: 0 0% 10%;
  --header-shadow-rest: 0 4px 24px -8px rgba(0, 0, 0, 0.12);
  --header-shadow-scrolled: 0 8px 40px -12px rgba(0, 0, 0, 0.2);
  --panel-shadow: 0 0 0 1px hsl(var(--border-subtle)), 0 1px 2px hsl(0 0% 0% / 0.2), 0 8px 32px hsl(0 0% 0% / 0.15);
  --grid-opacity: 0.35;
}

html.light {
  --background: 0 0% 99%;
  --foreground: 0 0% 7%;
  --card: 0 0% 100%;
  --surface: 210 25% 97%;
  --surface-elevated: 210 20% 95%;
  --muted: 210 18% 93%;
  --muted-foreground: 0 0% 42%;
  --border: 210 16% 88%;
  --border-subtle: 210 18% 92%;
  --header-shadow-rest: 0 4px 24px -8px rgba(0, 0, 0, 0.08);
  --header-shadow-scrolled: 0 8px 40px -12px rgba(0, 0, 0, 0.1);
  --panel-shadow: 0 0 0 1px hsl(var(--border-subtle)), 0 2px 8px hsl(0 0% 0% / 0.06);
  --grid-opacity: 0.18;
}

@media (min-width: 1024px) {
  :root { --header-offset: 9.25rem; }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }

.container {
  width: min(80rem, calc(100% - 2rem));
  margin: 0 auto;
}

/* ── Fondo ambiental + grid ── */
.ambient-bg {
  background-color: hsl(var(--background));
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(var(--primary) / 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, hsl(201 30% 8% / 0.5), transparent);
}
html.light .ambient-bg {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(var(--primary) / 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, hsl(210 25% 95% / 0.8), transparent);
}
.grid-subtle {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(hsl(var(--border-subtle)) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--border-subtle)) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: var(--grid-opacity);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
}

.page-content {
  position: relative;
  z-index: 1;
  padding-top: var(--header-offset);
}

/* ── Header flotante ── */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10200;
  pointer-events: none;
}

.site-header a,
.site-header button {
  pointer-events: auto;
}

.live-status-bar {
  pointer-events: auto;
  border-bottom: 1px solid hsl(var(--border) / 0.3);
  background: hsl(var(--background) / 0.9);
  backdrop-filter: blur(12px);
}

.live-status-bar__inner {
  max-width: 80rem;
  margin: 0 auto;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
}

.live-pulse {
  position: relative;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
}
.live-pulse::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: hsl(var(--success));
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  opacity: 0.4;
}
.live-pulse::after {
  content: "";
  position: relative;
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(var(--success));
}

.live-status-label {
  font-family: ui-monospace, monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: hsl(var(--primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 1024px) { .live-status-label { font-size: 10px; } }

.live-metrics {
  display: none;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}
@media (min-width: 640px) { .live-metrics { display: flex; } }
@media (min-width: 1024px) { .live-metrics { gap: 2rem; } }

.live-metric-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
}
.live-metric-value {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--foreground));
}

.header-float-wrap {
  pointer-events: none;
  display: flex;
  justify-content: center;
  padding: 0.5rem 1rem 0.75rem;
}

.header-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 64rem;
  height: 3.5rem;
  padding: 0 0.75rem;
  border-radius: 1rem;
  border: 1px solid hsl(var(--border) / 0.3);
  background: hsl(var(--background) / 0.8);
  backdrop-filter: blur(12px);
  box-shadow: var(--header-shadow-rest);
  transition: all 0.3s ease;
  gap: 8px;
}
.header-pill.is-scrolled {
  border-color: hsl(var(--border) / 0.5);
  background: hsl(var(--background) / 0.95);
  backdrop-filter: blur(24px);
  box-shadow: var(--header-shadow-scrolled);
}
@media (min-width: 1024px) {
  .header-pill { height: 3.75rem; padding: 0 1.5rem; }
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
@media (min-width: 1024px) { .header-brand { gap: 0.75rem; } }

.logo-white-bg {
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-white-bg img { height: 24px; width: auto; object-fit: contain; }

.header-product-name {
  display: none;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
@media (min-width: 640px) { .header-product-name { display: inline; } }
@media (min-width: 1024px) { .header-product-name { font-size: 12px; letter-spacing: 0.2em; } }

.live-badge {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid hsl(var(--success) / 0.3);
  background: hsl(var(--success) / 0.05);
  flex-shrink: 0;
}
@media (min-width: 768px) { .live-badge { display: inline-flex; } }

.live-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(var(--success));
  animation: pulse 2s ease-in-out infinite;
}
.live-badge-text {
  font-family: ui-monospace, monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--success));
}

.header-nav {
  display: none;
  align-items: center;
  gap: 2px;
}
@media (min-width: 1024px) { .header-nav { display: flex; } }

.header-nav a {
  padding: 8px;
  border-radius: 8px;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
}
@media (min-width: 1024px) { .header-nav a { font-size: 13px; } }
.header-nav a:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--surface) / 0.5);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
@media (min-width: 640px) { .header-actions { gap: 6px; } }

.mobile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid hsl(var(--border) / 0.4);
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
}
@media (min-width: 1024px) { .mobile-toggle { display: none; } }

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-offset);
  left: 0;
  right: 0;
  z-index: 10190;
  padding: 1rem;
  background: hsl(var(--background) / 0.98);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid hsl(var(--border));
  flex-direction: column;
  gap: 4px;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: hsl(var(--muted-foreground));
}
.mobile-nav a:hover {
  background: hsl(var(--surface));
  color: hsl(var(--foreground));
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid hsl(var(--border) / 0.4);
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.theme-toggle:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--surface) / 0.5);
}
.theme-toggle svg { width: 16px; height: 16px; }
html.dark .theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }
html.light .theme-toggle .icon-sun { display: none; }
html.light .theme-toggle .icon-moon { display: block; }

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-sm { height: 32px; padding: 0 12px; font-size: 14px; }

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}
.btn-ghost:hover {
  background: hsl(var(--surface));
  color: hsl(var(--foreground));
}

.btn-gold {
  height: 48px;
  padding: 0 32px;
  border-radius: var(--radius-xl);
  background: var(--brand-blue);
  color: var(--brand-black);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 0 20px rgba(108, 174, 209, 0.2);
}
.btn-gold.btn-sm {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
}
.btn-gold:hover {
  background: var(--brand-blue-hover);
  box-shadow: 0 0 24px rgba(108, 174, 209, 0.35);
}

.btn-outline {
  height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-xl);
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border) / 0.6);
}
.btn-outline:hover {
  border-color: hsl(var(--primary) / 0.5);
  background: hsl(var(--primary) / 0.05);
}

.btn-outline.btn-sm {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
}

.btn-ghost.hidden-md { display: none; }
@media (min-width: 768px) { .btn-ghost.hidden-md { display: inline-flex; } }

.btn-gold .sm-only { display: inline; }
.btn-gold .md-up { display: none; }
@media (min-width: 640px) {
  .btn-gold .sm-only { display: none; }
  .btn-gold .md-up { display: inline; }
}

/* Botones funcionalidad Pro — dorado premium + corona */
.btn-pro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  margin-top: 0;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(168, 120, 16, 0.55);
  background: linear-gradient(145deg, #fff0b3 0%, #f5c842 22%, #d4a017 58%, #f7e08a 100%);
  color: #2a1e05;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  box-shadow:
    0 2px 16px rgba(212, 160, 23, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-pro::before {
  content: '👑';
  font-size: 1.05em;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

.btn-pro::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.38) 50%, transparent 62%);
  pointer-events: none;
}

.btn-pro:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow:
    0 6px 24px rgba(212, 160, 23, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-pro:active {
  transform: translateY(0);
}

.btn-pro.is-pro-locked {
  opacity: 0.92;
  cursor: pointer;
}

/* Altura uniforme en acciones del laboratorio */
.lab-action-btn {
  width: 100%;
  min-height: 38px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.2;
  margin-top: 0;
  box-sizing: border-box;
}

.lab-action-btn--inline {
  width: auto;
  min-height: 38px;
}

html.dark .btn-pro {
  border-color: rgba(245, 200, 66, 0.45);
  box-shadow:
    0 2px 18px rgba(212, 160, 23, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Aliases legacy */
.btn-primary {
  height: 48px;
  padding: 0 32px;
  border-radius: var(--radius-xl);
  background: var(--brand-blue);
  color: var(--brand-black);
  font-weight: 600;
  box-shadow: 0 0 20px rgba(108, 174, 209, 0.2);
}
.btn-primary:hover {
  background: var(--brand-blue-hover);
  box-shadow: 0 0 24px rgba(108, 174, 209, 0.35);
}

/* ── Utilidades de marca ── */
.text-gradient-brand {
  background: linear-gradient(90deg, #6CAED1, #8ecae6, #5a9fc4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: hsl(var(--muted-foreground));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid hsl(var(--primary) / 0.25);
  background: hsl(var(--primary) / 0.05);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand-blue);
}

.panel-premium {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid hsl(var(--border) / 0.6);
  background: hsl(var(--card) / 0.8);
  backdrop-filter: blur(8px);
  box-shadow: var(--panel-shadow);
}
.panel-premium::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.section-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 12px;
}

.section-subtitle {
  color: hsl(var(--muted-foreground));
  font-size: 1.0625rem;
  max-width: 640px;
}

.footer-brand {
  margin-top: 4rem;
  padding: 24px 32px;
  border-top: 1px solid hsl(var(--border) / 0.4);
  background: hsl(var(--card) / 0.3);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.footer-brand p {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  margin: 0;
}

.footer-brand .logo-box {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Login — respaldo si auth.css tarda en cargar */
body.login-page main.auth-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 20px 48px;
  position: relative;
  z-index: 1;
}

.complexity-nav-panel:not(.is-session-visible) {
  display: none !important;
}
