/**
 * ================================================================
 * STUDY GUIDE PRINT STYLES - Modo de Impresión A4
 * ================================================================
 * CSS Responsable de ocultar la interfaz gráfica del mapa mental
 * y transformar la página web en un documento de puro texto (Guía
 * de Estudio) listo para exportación nativa a PDF (Ctrl+P).
 */

/* ─── GENERAL ─── */
:root {
  --sg-bg: #ffffff;
  --sg-text-main: #1a1a2e;
  --sg-text-muted: #475569;
  --sg-border: #e2e8f0;
  --sg-capsule-bg: #f8fafc;
  --sg-accent: #4263eb;
}

/* Oculto por defecto en la UI normal */
#study-guide-container {
  display: none;
}

/* Cuando se activa el modo previo a impresión, muestra el contenedor */
body.study-guide-print-mode #study-guide-container {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: white;
  z-index: 99999;
  padding: 40px;
  overflow: visible;
}

/* ─── MEDIA QUERY: IMPRESIÓN PANTALLA ─── */
@media print {
  /* Ocultar toda la UI normal de Anexit */
  #main-header-container,
  #canvasContainer,
  #minimap-container,
  #minimap-toggle,
  #edge-warning-overlay,
  .fab,
  .fab-trash,
  .smart-handle,
  .modal,
  .export-notification,
  .toast,
  .knowledge-panel,
  .knowledge-sheet,
  #mobileSelectAllBtn,
  #floating-zoom-level,
  .chroma-sheet,
  .capincho-widget {
    display: none !important;
  }

  body {
    background: white !important;
    color: var(--sg-text-main) !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Si está activo el print-mode de guía de estudio */
  body.study-guide-print-mode #study-guide-container {
    display: block !important;
    position: static !important;
    width: auto !important;
    padding: 0 !important;
  }

  @page {
    size: A4 portrait;
    margin: 20mm; /* Márgenes estándar A4 */
  }

  /* Control de huérfanas y viudas genérico */
  h1, h2, h3, h4 {
    page-break-after: avoid; 
    break-after: avoid;
  }
}

/* ─── ESTILOS DE LA GUÍA DE ESTUDIO (Tipografía y Componentes) ─── */
.study-guide {
  font-family: 'Inter', sans-serif;
  color: var(--sg-text-main);
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
}

/* Portada */
.sg-cover {
  text-align: center;
  padding: 2rem 0 1.5rem;
  border-bottom: 2px solid var(--sg-border);
  margin-bottom: 2rem;
}

.sg-cover__badge {
  display: inline-block;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sg-text-muted);
  border: 1px solid var(--sg-border);
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 1.5rem;
}

.sg-cover__title {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0 0 1.5rem 0;
  line-height: 1.2;
}

.sg-cover__stats {
  font-size: 1rem;
  color: var(--sg-text-muted);
  margin-bottom: 1rem;
}

.sg-cover__meta {
  font-size: 0.85rem;
  color: #94a3b8;
}

.sg-cover__dot {
  margin: 0 8px;
  opacity: 0.5;
}

/* Índice (TOC) */
.sg-toc {
  margin-bottom: 2rem;
}

.sg-toc__title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  border-bottom: 1px solid var(--sg-border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.sg-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sg-toc__item {
  padding: 6px 0;
  font-size: 1rem;
  border-bottom: 1px dashed var(--sg-border);
}

.sg-toc__item--sub {
  padding-left: 2rem;
  font-size: 0.95rem;
  color: var(--sg-text-muted);
}

.sg-toc__prefix {
  font-size: 0.8rem;
  font-style: italic;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── CÁPSULAS DE CONOCIMIENTO (Micro-Lecturas) ─── */

/* 
 * CRÍTICO: Prevenir que las tarjetas de lectura se dividan entre
 * hojas diferentes arruinando la retentiva visual 
 */
.sg-capsule {
  background: var(--sg-capsule-bg);
  border: 1px solid var(--sg-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.85rem;
  page-break-inside: avoid;
  break-inside: avoid;
}

.sg-capsule--root {
  background: white;
  border: 2px solid var(--sg-text-main);
  text-align: center;
  margin-bottom: 1.5rem;
}

.sg-capsule--branch {
  border-left-width: 4px;
  border-left-color: var(--sg-accent); /* Color overriden via inline-style if wanted */
}

.sg-capsule--deep {
  margin-left: 2rem;
  font-size: 0.95rem;
}

/* Títulos H1-H4 */
.sg-capsule h1, 
.sg-capsule h2, 
.sg-capsule h3, 
.sg-capsule h4 {
  font-family: 'Outfit', sans-serif;
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.sg-capsule h1 { font-size: 1.75rem; font-weight: 800; }
.sg-capsule h2 { font-size: 1.5rem; font-weight: 700; }
.sg-capsule h3 { font-size: 1.25rem; font-weight: 600; }
.sg-capsule h4 { font-size: 1.1rem; font-weight: 600; }

.sg-capsule--root h1 { margin-bottom: 0; }

/* Prefijo Semántico */
.sg-capsule__semantic {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sg-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  background: #f1f5f9;
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 4px;
}

.sg-capsule__semantic-icon {
  display: flex;
  align-items: center;
  opacity: 0.7;
}

/* Elementos comunes (Desc, Insight, Notes) */
.sg-capsule__desc,
.sg-capsule__insight,
.sg-capsule__notes {
  display: flex;
  gap: 12px;
  margin-bottom: 1rem;
}

.sg-capsule__desc:last-child,
.sg-capsule__insight:last-child,
.sg-capsule__notes:last-child {
  margin-bottom: 0;
}

.sg-capsule__icon {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
  color: var(--sg-text-muted);
}

.sg-capsule__desc-body p,
.sg-capsule__insight p,
.sg-capsule__notes-body p {
  margin: 0 0 0.75rem 0;
}

.sg-capsule__desc-body p:last-child,
.sg-capsule__insight p:last-child,
.sg-capsule__notes-body p:last-child {
  margin-bottom: 0;
}

/* Insight específico */
.sg-capsule__insight {
  background: #f8fafc; /* Gris MUY tenue para B/N printer-friendly */
  border: 1px solid var(--sg-border);
  padding: 0.85rem;
  border-radius: 6px;
  font-style: italic;
  font-size: 0.9em;
}

/* Handwriting Lines (Líneas para apuntes) */
.sg-capsule__lines {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sg-border);
}

.sg-capsule__lines-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sg-text-muted);
  margin-bottom: 0.5rem;
}

.sg-capsule__line {
  height: 20px;
  border-bottom: 1px dashed #cbd5e1;
  margin-bottom: 6px;
}

/* Separador de ramas */
.sg-branch-separator {
  height: 2px;
  background: var(--sg-border);
  margin: 1.5rem 10%;
  border-radius: 2px;
}

/* Footer de guía */
.sg-footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 0.85rem;
  color: #94a3b8;
  page-break-inside: avoid;
  break-inside: avoid;
}

.sg-footer__line {
  height: 1px;
  background: var(--sg-border);
  margin-bottom: 1rem;
}

.sg-footer__content {
  display: flex;
  justify-content: space-between;
}

/* Estado Vacío */
.sg-empty {
  text-align: center;
  padding: 4rem;
  color: var(--sg-text-muted);
  font-style: italic;
}
