/*
 * Comparador Semántico de Documentos · AGazzo Tools
 * Estilos específicos de la herramienta.
 * La identidad visual general (tipografía, paleta, header, tarjetas y acciones)
 * se hereda de /AGazzoTools/assets/tools.css, igual que la portada de AGazzo Tools.
 */

* { box-sizing: border-box; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.comparator-page .tools-inner { width: min(1240px, calc(100% - 32px)); }
.comparator-intro {
  width: 100%;
  max-width: none;
}
.comparator-intro > p:last-of-type { margin-bottom: 0; }
.comparator-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.comparator-title-row h1 { margin-bottom: 0; }

/* Mismo tratamiento discreto de privacidad usado en la portada de Tools. */
.comparator-privacy {
  margin: 18px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(127, 127, 127, 0.18);
  background: rgba(255, 255, 255, 0.025);
  font-size: .92rem;
  line-height: 1.5;
}

.comparator-notice {
  width: 100%;
  max-width: none;
  margin: 18px 0 24px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(127, 127, 127, 0.18);
  background: rgba(255, 255, 255, 0.025);
  line-height: 1.5;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
/*
 * tools.css aplica separación vertical entre .tool-card consecutivas.
 * Dentro de esta grilla A/B deben comportarse como espejos, por lo que
 * neutralizamos explícitamente cualquier margen heredado del segundo panel.
 */
.upload-grid > .upload-card,
.upload-grid > .tool-card + .tool-card {
  min-width: 0;
  margin: 0 !important;
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}
.upload-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  min-height: 52px;
}
.upload-card__head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.upload-card__head p { margin: 0; opacity: .72; font-size: .9rem; }
.doc-letter {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid rgba(127,127,127,.25);
  background: rgba(255,255,255,.05);
  font-weight: 800;
  font-size: 1.15rem;
}

/*
 * Decisión visual deliberada: las zonas de ingreso SIEMPRE son claras,
 * independientemente del tema general de AGazzo Tools.
 */
.source-zone {
  min-height: 325px;
  height: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 2px dashed #bcc6cf;
  border-radius: 12px;
  background: #fff;
  color: #1d2730;
  box-shadow: 0 5px 18px rgba(0,0,0,.08);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.source-zone.dragging {
  border-color: #5f6f7d;
  box-shadow: 0 0 0 4px rgba(80,95,110,.12), 0 8px 22px rgba(0,0,0,.12);
  transform: translateY(-1px);
}
.source-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 1px 1px 12px;
}
.source-toolbar > div { display: grid; gap: 2px; }
.source-toolbar strong { color: #1d2730; }
.source-toolbar span { color: #6b7680; font-size: .86rem; }
.source-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 10px;
  color: #74808a;
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.source-divider::before,
.source-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e1e5e8;
}
.paste-box {
  width: 100%;
  height: 180px;
  min-height: 180px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid #cbd2d8;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: #1d2730;
  line-height: 1.5;
}
.paste-box::placeholder { color: #8b959e; }
.paste-box:focus {
  border-color: #788997;
  box-shadow: 0 0 0 3px rgba(80,95,110,.10);
}
.source-help {
  margin: 9px 2px 0;
  min-height: 2.8em;
  color: #69747e;
  font-size: .78rem;
  line-height: 1.4;
}
.file-meta {
  min-height: 22px;
  margin-top: 11px;
  flex: 0 0 auto;
  overflow-wrap: anywhere;
  opacity: .76;
  font-size: .88rem;
  line-height: 1.4;
}
.file-meta strong { opacity: 1; }

.actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 22px 0;
}
.comparator-primary {
  min-width: 230px;
  border: 0;
}

.comparator-print {
  white-space: nowrap;
  border: 0;
}
.comparator-secondary,
.comparator-ghost {
  padding: 10px 15px;
  border-radius: 9px;
  border: 1px solid rgba(127,127,127,.28);
  font-weight: 700;
}
.comparator-secondary {
  background: rgba(255,255,255,.055);
  color: inherit;
}
.source-zone .comparator-secondary {
  background: #f5f6f7;
  color: #25313a;
  border-color: #c9d0d6;
}
.comparator-secondary:hover,
.comparator-ghost:hover { background: rgba(127,127,127,.11); }
.source-zone .comparator-secondary:hover { background: #eceff1; }
.comparator-ghost { background: transparent; color: inherit; }

.status-panel,
.error-panel {
  margin: 18px 0;
  padding: 15px 17px;
  border-radius: 12px;
}
.status-panel { margin-left: 0; margin-right: 0; }
.error-panel {
  border: 1px solid rgba(180,80,80,.45);
  background: rgba(180,80,80,.09);
}
.status-row { display: flex; justify-content: space-between; gap: 18px; }
.status-panel p { margin: 8px 0 0; opacity: .72; }
.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(127,127,127,.16);
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  opacity: .62;
  transition: width .18s ease;
}

.results { margin-top: 28px; }
.results-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}
.results-head h2 { margin: 0; }
.results-head .tools-kicker { margin-bottom: 5px; }
.muted { opacity: .7; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric-card {
  min-width: 0;
  margin: 0;
  padding: 17px;
}
.metric-label { display: block; opacity: .74; font-size: .88rem; font-weight: 700; }
.metric-card strong { display: block; margin: 5px 0; font-size: 2rem; line-height: 1; }
.metric-card p { margin: 0; opacity: .7; font-size: .86rem; line-height: 1.4; }

.result-section,
.methodology {
  margin: 0 0 18px;
  padding: 20px;
}
.result-section.compact { margin: 0; }
.result-section h3,
.methodology h3 { margin: 0 0 8px; }
.section-head p,
.result-section > p { margin: 0 0 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th, td {
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(127,127,127,.20);
}
th {
  background: rgba(127,127,127,.07);
  font-weight: 750;
}
td:nth-child(3), th:nth-child(3) { width: 90px; white-space: nowrap; }
td:nth-child(4), th:nth-child(4) { width: 105px; white-space: nowrap; }
td:nth-child(5), th:nth-child(5) { width: 170px; white-space: nowrap; }
.block-heading { display: block; margin-bottom: 4px; font-size: .78rem; font-weight: 800; }
.score-pill,
.coverage-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(127,127,127,.16);
  background: rgba(127,127,127,.08);
  font-size: .8rem;
  font-weight: 800;
}
.coverage-pill { background: rgba(127,127,127,.12); }

.two-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.block-list,
.fact-list { display: grid; gap: 8px; }
.block-item,
.fact-item {
  padding: 10px 12px;
  border: 1px solid rgba(127,127,127,.20);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
  line-height: 1.43;
}
.block-item small,
.fact-item small { display: block; margin-top: 4px; opacity: .68; }
.empty { opacity: .65; font-style: italic; }
.methodology p { line-height: 1.58; }
.report-signature {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(127,127,127,.20);
  opacity: .72;
  font-size: .85rem;
}

.interpretation-guide .guide-table { max-width: 900px; }
.guide-table td:first-child,
.guide-table th:first-child { width: 120px; white-space: nowrap; }
.guide-note { margin: 12px 0 0 !important; line-height: 1.45; }
.semantic-factual-alert,
.semantic-asymmetry-alert {
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid rgba(127,127,127,.24);
  border-radius: 10px;
  background: rgba(255,255,255,.035);
  line-height: 1.48;
}
.semantic-factual-alert,
.fact-difference { border-color: rgba(178,132,44,.42); background: rgba(178,132,44,.08); }
.fact-difference small b { opacity: 1; }
.window-note { display: block; margin: 0 0 .35rem; opacity: .62; font-weight: 650; }
.window-part + .window-part {
  margin-top: .45rem;
  padding-top: .45rem;
  border-top: 1px dashed rgba(127,127,127,.24);
}

@media (max-width: 900px) {
  .upload-grid,
  .two-columns { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .comparator-page .tools-inner { width: min(100% - 20px, 1240px); }
  .metric-grid { grid-template-columns: 1fr; }
  .results-head { align-items: stretch; flex-direction: column; }
  .actions { flex-direction: column; }
  .comparator-primary { width: 100%; }
  .source-toolbar { align-items: stretch; flex-direction: column; }
  .source-pick { width: 100%; }
}

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

@media print {
  header,
  .tools-intro-card,
  .comparator-notice,
  .upload-grid,
  .actions,
  .status-panel,
  .error-panel,
  .whatsapp-btn,
  #print-btn { display: none !important; }

  /* Papel real: neutraliza todos los fondos/gradientes heredados de AGazzo Tools. */
  html,
  body,
  main,
  .tools-page,
  .comparator-page,
  .tools-hero,
  .tools-inner,
  .results {
    background: #fff !important;
    background-color: #fff !important;
    background-image: none !important;
    color: #111 !important;
    box-shadow: none !important;
  }

  html::before, html::after,
  body::before, body::after,
  main::before, main::after,
  .tools-page::before, .tools-page::after,
  .tools-hero::before, .tools-hero::after,
  .comparator-page::before, .comparator-page::after {
    content: none !important;
    display: none !important;
    background: none !important;
  }

  html, body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .comparator-page .tools-inner {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .results { display: block !important; margin-top: 0 !important; }

  /* En papel, todo texto crítico debe conservar contraste aunque tools.css use tema oscuro. */
  .results-head h2,
  .result-section h3,
  .methodology h3,
  .interpretation-guide h3,
  .metric-card strong,
  .metric-label,
  .guide-table strong,
  .block-heading,
  .fact-item strong,
  .block-item strong {
    color: #111 !important;
    opacity: 1 !important;
  }

  .tools-kicker {
    color: #1f6f9f !important;
    opacity: 1 !important;
  }

  #comparison-meta,
  .metric-card p,
  .muted,
  .guide-note,
  .block-item small,
  .fact-item small,
  .report-signature,
  .window-note {
    color: #5e6670 !important;
    opacity: 1 !important;
  }

  .results-head,
  .metric-grid,
  .metric-card,
  .semantic-factual-alert,
  .semantic-asymmetry-alert,
  .interpretation-guide {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .tool-card,
  .metric-card,
  .result-section,
  .methodology {
    box-shadow: none !important;
    background: #fff !important;
    background-image: none !important;
    border-color: #d8dce0 !important;
    color: #111 !important;
  }

  .result-section,
  .result-section.compact,
  .methodology { break-inside: auto; page-break-inside: auto; }

  .section-head, h2, h3 { break-after: avoid; page-break-after: avoid; }

  .table-wrap { overflow: visible; }
  table { font-size: 9pt; break-inside: auto; page-break-inside: auto; color: #111 !important; }
  thead { display: table-header-group; }
  tbody { display: table-row-group; }
  tr, .block-item, .fact-item { break-inside: avoid; page-break-inside: avoid; }
  th { color: #3c4650 !important; background: #f3f5f7 !important; border-color: #d8dce0 !important; }
  td { color: #111 !important; border-color: #d8dce0 !important; }

  .two-columns { display: block; margin-bottom: 0; }
  .two-columns > .result-section { margin-bottom: 12px; }
  .block-item, .fact-item { background: #fff !important; border-color: #d8dce0 !important; color: #111 !important; }
  .score-pill, .coverage-pill { background: #f0f2f4 !important; color: #222 !important; border-color: #d8dce0 !important; }
  .semantic-factual-alert { background: #fff7e6 !important; color: #664700 !important; border-color: #d8b760 !important; }
  .semantic-asymmetry-alert { background: #f3f5f7 !important; color: #333 !important; border-color: #c9ced3 !important; }
  .methodology p { orphans: 3; widows: 3; }
}
