/* ==========================================================================
   Analizador de Papers Médicos — estilos propios + respaldo sin CDN
   Tailwind cubre la mayoría del diseño; aquí hay marca, detalles y un
   respaldo estructural mínimo si el CDN no está disponible.
   ========================================================================== */

:root {
  --azul-900: #0f2a43;
  --azul-700: #154c6f;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-50: #f0fdfa;
  --slate-50: #f8fafc;
  --slate-200: #e2e8f0;
  --slate-600: #475569;
  --rojo-600: #dc2626;
  --ambar-500: #f59e0b;
  --verde-600: #16a34a;
}

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--slate-50);
  color: #1e293b;
}

/* ---------- Marca ---------- */
.brand-badge {
  background: linear-gradient(135deg, var(--teal-600), var(--azul-700));
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 1.25rem;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.dropzone.dragover {
  border-color: var(--teal-600);
  background: var(--teal-50);
  transform: scale(1.01);
}

/* ---------- Etapas de procesamiento ---------- */
.stage-item .stage-icon { transition: all .25s ease; }
.stage-pulse {
  animation: stagePulse 1.2s ease-in-out infinite;
}
@keyframes stagePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.progress-track {
  background: var(--slate-200);
  border-radius: 9999px;
  overflow: hidden;
  height: 10px;
}
.progress-fill {
  background: linear-gradient(90deg, var(--teal-600), var(--azul-700));
  height: 100%;
  border-radius: 9999px;
  transition: width .5s ease;
}

/* ---------- Badges de nivel de evidencia ---------- */
.badge-demostrado { background:#dcfce7; color:#166534; border:1px solid #86efac; }
.badge-sugerido   { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
.badge-no-concluyente { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; }
.badge-calculado  { background:#e0f2fe; color:#075985; border:1px solid #7dd3fc; }

/* Semáforo de riesgo de sesgo */
.risk-bajo { background:#dcfce7; color:#166534; }
.risk-moderado { background:#fef3c7; color:#92400e; }
.risk-alto { background:#fee2e2; color:#991b1b; }
.risk-desconocido { background:#f1f5f9; color:#475569; }

/* ---------- Cifras destacadas ---------- */
.stat-number {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--azul-700);
}

.citation-ref {
  color: var(--teal-700);
  font-size: .8em;
  cursor: pointer;
  white-space: nowrap;
}
.citation-ref:hover { text-decoration: underline; }

/* ---------- Chatbot ---------- */
.chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  height: 100dvh;
  width: 100%;
  max-width: 420px;
  background: white;
  box-shadow: -8px 0 30px rgba(15, 42, 67, .18);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform .28s ease;
}
.chat-panel.open { transform: translateX(0); }

.chat-bubble {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 59;
  width: 60px;
  height: 60px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--teal-600), var(--azul-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(13, 148, 136, .4);
  cursor: pointer;
  border: none;
}
.chat-bubble:hover { transform: scale(1.06); }
.chat-bubble { transition: transform .15s ease; }

.chat-msg-user, .chat-msg-bot {
  max-width: 85%;
  padding: .6rem .9rem;
  border-radius: 1rem;
  font-size: .9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.chat-msg-user { background: var(--teal-600); color: white; align-self: flex-end; border-bottom-right-radius: .25rem; }
.chat-msg-bot { background: var(--slate-50); border: 1px solid var(--slate-200); align-self: flex-start; border-bottom-left-radius: .25rem; }

.typing-dot {
  width: 7px; height: 7px; background: var(--teal-600); border-radius: 50%;
  display: inline-block; animation: typing 1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%,100%{opacity:.25} 50%{opacity:1} }

/* ---------- Resaltado de cifras en texto ---------- */
.highlight-stat { font-weight: 600; color: var(--azul-700); background: #eff6ff; padding: 0 3px; border-radius: 4px; }

/* ---------- Navegación de secciones ---------- */
.section-nav a.active { color: var(--teal-700); font-weight: 600; border-bottom-color: var(--teal-600); }

/* ---------- Utilidades de respaldo sin CDN ---------- */
.hidden { display: none !important; }
.center-text { text-align: center; }

/* Barra de desplazamiento discreta en el chat */
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ==========================================================================
   Exportación a PDF / impresión del análisis completo
   ========================================================================== */

.print-only { display: none; }

@media print {
  @page { size: A4; margin: 14mm 12mm; }

  html, body { background: #ffffff !important; }

  /* Ocultar todo lo que no es contenido del reporte. */
  header,
  .section-nav,
  .chat-bubble,
  .chat-panel,
  #chat-unavailable-note,
  #loading-view {
    display: none !important;
  }

  .print-only { display: block !important; }

  #report-container {
    max-width: 100% !important;
    padding: 0 !important;
  }
  #report-container.hidden { display: block !important; }

  /* La tarjeta ejecutiva (gradiente oscuro en pantalla) se imprime en blanco. */
  #sec-ejecutivo {
    background: #ffffff !important;
    background-image: none !important;
    color: #0f2a43 !important;
    border: 1px solid #cbd5e1 !important;
  }
  #sec-ejecutivo h2,
  #sec-ejecutivo [data-slot="body"],
  #sec-ejecutivo [data-slot="body"] p {
    color: #1e293b !important;
  }

  /* Tarjetas limpias, sin sombras ni fondos de color intensos. */
  section, .shadow-card {
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .bg-white { background: #ffffff !important; }

  /* Las cifras resaltadas imprimen con fondo gris claro. */
  .highlight-stat {
    background: #e2e8f0 !important;
    color: #0f2a43 !important;
    padding: 0 2px;
  }

  /* Evitar cortes feos dentro de elementos individuales. */
  li, tr, .chat-msg-bot { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  table { break-inside: auto; }

  a { color: inherit !important; text-decoration: none !important; }

  /* Puntos clave en dos columnas también en papel. */
  #key-points-list { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  #key-points-list li { padding: 8px !important; }
}
