/**
 * Estilos canónicos para Conversor de Word a PDF (.docx a .pdf)
 * Fijate Tools • fijate.com
 */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema claro por defecto */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dimmed: #64748b;

  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;

  --success-color: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;

  --warning-color: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger-color: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Tema oscuro */
[data-theme="dark"], body.dark-theme {
  --bg-page: #0b0f19;
  --bg-card: #111827;
  --bg-card-subtle: #1f2937;
  --border-color: #374151;
  --border-focus: #3b82f6;

  --text-main: #f9fafb;
  --text-muted: #cbd5e1;
  --text-dimmed: #94a3b8;

  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: #1e293b;
  --accent-border: #1e3a8a;

  --success-color: #22c55e;
  --success-bg: #064e3b;
  --success-border: #047857;

  --warning-color: #fbbf24;
  --warning-bg: #451a03;
  --warning-border: #78350f;

  --danger-color: #f87171;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

.mono-font {
  font-family: var(--font-mono);
}

.small-muted {
  color: var(--text-dimmed);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Layout principal */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Tarjeta principal */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

@media (max-width: 640px) {
  .card-main {
    padding: 1.25rem;
    gap: 1.25rem;
  }
}

.tool-hero {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.badge-privacy {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--accent-light);
  color: var(--accent-color);
  border: 1px solid var(--accent-border);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  width: fit-content;
}

.tool-hero-title {
  font-size: 1.85rem;
  letter-spacing: -0.02em;
}

@media (max-width: 640px) {
  .tool-hero-title {
    font-size: 1.5rem;
  }
}

.tool-hero-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 820px;
}

/* Zona Drag and Drop */
.dropzone {
  border: 2px dashed var(--border-color);
  background-color: var(--bg-card-subtle);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-color);
  background-color: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.dropzone-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.dropzone-text h3 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Botones universales (mínimo 40px altura táctil) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-card-subtle);
  border-color: var(--text-dimmed);
}

.btn-outline {
  background-color: transparent;
  color: var(--accent-color);
  border-color: var(--accent-border);
}

.btn-outline:hover {
  background-color: var(--accent-light);
}

.btn-full {
  width: 100%;
}

@media (max-width: 640px) {
  .btn {
    width: 100%;
    min-height: 44px;
  }
}

/* Tarjeta de archivo seleccionado */
.file-info-card {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.file-info-main {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.file-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background-color: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.file-name {
  font-weight: 600;
  font-size: 1rem;
  word-break: break-all;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success-color);
  border: 1px solid var(--success-border);
}

/* Opciones de maquetación */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Selectores canónicos (regla canónica: ellipsis, explicit background/color, flecha SVG) */
.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding: 0.6rem 2.5rem 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9375rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

[data-theme="dark"] .custom-select,
body.dark-theme .custom-select {
  background-color: var(--bg-card);
  color: var(--text-main);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.custom-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.custom-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Barra de progreso */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background-color: var(--border-color);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent-color);
  border-radius: 9999px;
  transition: width 0.25s ease;
}

/* Cuadrícula de estadísticas */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-item {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-dimmed);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 1.25rem;
}

@media (max-width: 640px) {
  .actions-row {
    flex-direction: column;
  }
}

/* -------------------------------------------------------------
   SIMULADOR DE HOJA FÍSICA A4 EN PANTALLA
   ------------------------------------------------------------- */
.preview-viewport {
  margin-top: 1.5rem;
  background-color: #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .preview-viewport,
body.dark-theme .preview-viewport {
  background-color: #0f172a;
}

.a4-sheet {
  background-color: #ffffff;
  color: #1e293b;
  width: 100%;
  max-width: 794px; /* A4 vertical a 96 DPI */
  min-height: 1123px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  padding: 15mm;
  font-family: 'Inter', sans-serif;
  font-size: 10.5pt;
  line-height: 1.55;
  transition: all 0.2s ease;
  overflow: visible;
}

.a4-sheet.sheet-landscape {
  max-width: 1123px;
  min-height: 794px;
}

/* Reglas estrictas anti-corte horizontal de textos, títulos y tablas */
.a4-sheet p,
.a4-sheet h1,
.a4-sheet h2,
.a4-sheet h3,
.a4-sheet h4,
.a4-sheet h5,
.a4-sheet h6,
.a4-sheet li,
.a4-sheet blockquote,
.a4-sheet .docx-rendered-table,
.a4-sheet .docx-rendered-table tr,
.a4-sheet img,
.a4-sheet figure,
.a4-sheet .no-split-block,
.pdf-export-staging p,
.pdf-export-staging h1,
.pdf-export-staging h2,
.pdf-export-staging h3,
.pdf-export-staging h4,
.pdf-export-staging h5,
.pdf-export-staging h6,
.pdf-export-staging li,
.pdf-export-staging blockquote,
.pdf-export-staging .docx-rendered-table,
.pdf-export-staging .docx-rendered-table tr,
.pdf-export-staging img,
.pdf-export-staging figure,
.pdf-export-staging .no-split-block {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
  break-inside: avoid-page !important;
}

.a4-sheet h1,
.a4-sheet h2,
.a4-sheet h3,
.a4-sheet h4,
.a4-sheet h5,
.a4-sheet h6,
.pdf-export-staging h1,
.pdf-export-staging h2,
.pdf-export-staging h3,
.pdf-export-staging h4,
.pdf-export-staging h5,
.pdf-export-staging h6 {
  page-break-after: avoid !important;
  break-after: avoid !important;
  break-after: avoid-page !important;
}

/* Divisor visual y marcador semántico de salto de página */
.html2pdf__page-break {
  page-break-before: always !important;
  break-before: page !important;
  display: block;
  position: relative;
  width: 100%;
  margin: 2.5rem 0 2rem;
  padding: 0;
  border-top: 2px dashed #94a3b8;
  text-align: right;
  height: 0;
}

.page-divider-label {
  display: inline-block;
  background-color: var(--accent-color, #2563eb);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  position: relative;
  top: -12px;
  box-shadow: var(--shadow-sm);
}

/* Estilos de contenido renderizado desde DOCX */
.a4-sheet h1, .pdf-export-staging h1 {
  color: #0f172a;
  font-size: 1.85rem;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

.a4-sheet h2, .pdf-export-staging h2 {
  color: #1e293b;
  font-size: 1.4rem;
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.a4-sheet h3, .pdf-export-staging h3 {
  color: #334155;
  font-size: 1.15rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.a4-sheet p, .pdf-export-staging p {
  color: #334155;
  margin-bottom: 0.75rem;
  text-align: justify;
}

.a4-sheet ul, .a4-sheet ol,
.pdf-export-staging ul, .pdf-export-staging ol {
  margin-left: 1.5rem;
  margin-bottom: 0.85rem;
  color: #334155;
}

.a4-sheet li, .pdf-export-staging li {
  margin-bottom: 0.35rem;
}

/* Tablas DOCX en hoja */
.docx-rendered-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 9.5pt;
}

.docx-rendered-table td, 
.docx-rendered-table th {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.docx-rendered-table th,
.docx-rendered-table tr:first-child td {
  background-color: #f1f5f9;
  font-weight: 700;
  color: #0f172a;
}

.a4-sheet img {
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  display: block;
  border-radius: 4px;
}

/* Reglas de impresión directa (@media print) */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .dropzone,
  #section-config > .file-info-card,
  #section-config > .options-grid,
  #section-config > .stats-grid,
  .actions-row,
  .progress-container,
  .seo-guide-section,
  .modal-backdrop,
  .app-toast {
    display: none !important;
  }
  .tool-layout,
  .card-main,
  .preview-viewport {
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .a4-sheet {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    min-height: auto !important;
    padding: 0 !important;
  }
  @page {
    margin: 15mm;
  }
}

/* Modales canónicos */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 100%;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
}

.modal-btn-close {
  background: transparent;
  border: none;
  color: var(--text-dimmed);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.modal-btn-close:hover {
  color: var(--text-main);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .modal-footer .btn {
    width: 100%;
  }
}

/* Toast flotante */
.app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background-color: var(--text-main);
  color: var(--bg-card);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
  z-index: 10000;
  animation: toastSlideUp 0.2s ease-out;
}

.app-toast.show {
  display: block;
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
   SECCIÓN DIDÁCTICA SEO Y GUÍA (CANÓNICO LECCIÓN 223)
   ------------------------------------------------------------- */
.seo-guide-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 1.5rem;
}

.seo-guide-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seo-authority-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-color);
  background-color: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  width: fit-content;
}

.seo-guide-title {
  font-size: 1.65rem;
}

.seo-guide-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

.seo-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.seo-guide-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guide-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--accent-light);
  color: var(--accent-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.seo-guide-card h3 {
  font-size: 1.15rem;
}

.seo-guide-card p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

/* Tabla didáctica comparativa */
.guide-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.guide-table th {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.guide-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
}

.guide-table tr:last-child td {
  border-bottom: none;
}

/* Acordeón de preguntas frecuentes (FAQ) */
.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.seo-faq-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.seo-faq-item[open] {
  border-color: var(--accent-border);
}

.seo-faq-question {
  padding: 1.1rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
}

.seo-faq-question::-webkit-details-marker {
  display: none;
}

.seo-faq-question::after {
  content: '+';
  font-size: 1.35rem;
  color: var(--accent-color);
  font-weight: 400;
  transition: transform 0.2s ease;
}

.seo-faq-item[open] .seo-faq-question::after {
  content: '−';
}

.seo-faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
}
