/* ============================================================
   MERCATITEK · Analizador de Retención Audiovisual
   Extiende la identidad visual del sitio (css/styles.css).
   Soporta tema oscuro (default) y claro.
   ============================================================ */

/* ---------- Tema claro ---------- */
html[data-theme="light"] {
  --bg: #f6f6fb;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f2f1fb;
  --border: rgba(88, 60, 160, 0.16);
  --border-strong: rgba(88, 60, 160, 0.32);
  --text: #14142a;
  --text-muted: #4c4c6b;
  --text-dim: #7a7a99;
  --shadow: 0 16px 40px rgba(30, 20, 70, 0.1);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.14);
}

html[data-theme="light"] body.an-page {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="light"] .an-header {
  background: rgba(255, 255, 255, 0.86);
}

/* ---------- Base de página ---------- */
body.an-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.an-page main { flex: 1; }

/* ---------- Header ---------- */
.an-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.an-header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 68px;
}
.an-header-actions { display: flex; align-items: center; gap: 12px; }
.an-back {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.18s ease, background 0.18s ease;
}
.an-back:hover { color: var(--text); background: rgba(139, 92, 246, 0.1); }

.an-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.an-theme:hover { background: rgba(139, 92, 246, 0.2); transform: translateY(-1px); }
.an-theme .an-theme-moon { display: none; }
html[data-theme="light"] .an-theme .an-theme-moon { display: block; }
html[data-theme="light"] .an-theme .an-theme-sun { display: none; }

/* ---------- Hero ---------- */
.an-hero { position: relative; padding: 72px 0 40px; overflow: hidden; }
.an-hero-bg { position: absolute; inset: 0; pointer-events: none; }
.an-hero-inner { position: relative; max-width: 820px; margin-inline: auto; text-align: center; }
.an-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 18px 0 18px;
}
.an-hero-sub {
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  max-width: 660px;
  margin: 0 auto 30px;
}
.an-hero-points {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.an-hero-points li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* ---------- Secciones ---------- */
.an-section { padding: 28px 0; }
.an-narrow { max-width: 640px; margin-inline: auto; }

.an-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  box-shadow: var(--shadow);
}
.an-card-accent {
  border-color: rgba(34, 211, 238, 0.35);
  background: linear-gradient(160deg, rgba(34, 211, 238, 0.07), var(--bg-card) 45%);
}

/* ---------- Formulario ---------- */
.an-form-title { font-size: 1.5rem; margin-bottom: 6px; }
.an-form-sub { color: var(--text-muted); font-size: 0.94rem; margin-bottom: 22px; }

.an-field { display: grid; gap: 8px; margin-bottom: 18px; }
.an-field label {
  font-family: var(--font-head);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.an-field input {
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.an-field input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}
.an-field input.invalid {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}
.an-hint { font-size: 0.78rem; color: var(--text-dim); }
.an-legal { font-size: 0.76rem; color: var(--text-dim); margin-top: 14px; text-align: center; line-height: 1.5; }

.an-error {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
  font-size: 0.88rem;
}
html[data-theme="light"] .an-error { color: #b91c1c; }

/* ---------- Progreso ---------- */
.an-progress { text-align: left; }
.an-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.14);
  overflow: hidden;
  margin: 20px 0 10px;
}
.an-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.5);
  transition: width 0.6s ease;
}
.an-progress-pct { font-family: var(--font-head); font-weight: 600; color: var(--cyan); margin-bottom: 20px; }

.an-phases { display: grid; gap: 12px; }
.an-phases li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.94rem;
  color: var(--text-dim);
  transition: color 0.25s ease;
}
.an-phases li.is-active { color: var(--text); }
.an-phases li.is-done { color: var(--text-muted); }
.an-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.an-phases li.is-active .an-dot {
  background: var(--cyan);
  box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.6);
  animation: pulse-dot 1.6s infinite;
}
.an-phases li.is-done .an-dot { background: #34d399; box-shadow: 0 0 10px rgba(52, 211, 153, 0.7); }

/* ---------- Reporte ---------- */
.an-report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.an-report-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin: 10px 0 6px; }
.an-report-url { color: var(--text-dim); font-size: 0.84rem; word-break: break-all; }
.an-report-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.an-report-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.an-span-2 { grid-column: 1 / -1; }

.an-card p { color: var(--text-muted); font-size: 0.96rem; line-height: 1.65; }
.an-h3 { font-size: 1.05rem; margin-bottom: 12px; }

/* Gauge */
.an-gauge-card { text-align: center; }
.an-gauge-label {
  display: block;
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.an-gauge { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.an-gauge-track { stroke: rgba(139, 92, 246, 0.15); }
.an-gauge-fill {
  stroke: url(#none);
  stroke: var(--violet);
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 1.1s ease, stroke 0.4s ease;
}
.an-gauge-value {
  position: absolute;
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-head);
}
.an-gauge-value strong { font-size: 2.6rem; line-height: 1; }
.an-gauge-value small { font-size: 0.95rem; color: var(--text-dim); }
.an-gauge-verdict { margin-top: 14px; font-size: 0.9rem; color: var(--text-muted); }

/* Fugas de retención */
.an-leaks { display: grid; gap: 14px; }
.an-leaks li {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid #f87171;
  border-radius: 12px;
}
.an-leak-time {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--cyan);
}
.an-leak-issue { font-size: 0.94rem; color: var(--text); }
.an-leak-impact { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* Recomendaciones */
.an-recs { display: grid; gap: 14px; }
.an-recs li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: start;
}
.an-recs .an-rec-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.78rem;
}
.an-rec-title { font-family: var(--font-head); font-weight: 600; color: var(--text); margin-bottom: 4px; }
.an-rec-action { color: var(--text-muted); font-size: 0.93rem; line-height: 1.6; }

.an-empty { color: var(--text-dim); font-size: 0.9rem; font-style: italic; }

.an-report-foot {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 32px;
}

/* ---------- Footer ---------- */
.an-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 22px 0; }
.an-footer-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.84rem;
}
.an-footer a { color: var(--text-muted); }
.an-footer a:hover { color: var(--cyan); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .an-report-grid { grid-template-columns: 1fr; }
  .an-hero { padding: 48px 0 24px; }
  .an-report-head { align-items: flex-start; }
}
@media (max-width: 520px) {
  .an-card { padding: 22px 18px; }
  .an-back { display: none; }
  .an-leaks li { grid-template-columns: 1fr; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .an-bar span, .an-gauge-fill { transition: none; }
  .an-phases li.is-active .an-dot { animation: none; }
}
