/* ==========================================================================
   PDF-DOCUMENT.CSS - Estilos do Formulário Físico Oficial MRS (FOR-GNO-0051/00.00)
   Reprodução 1:1 do documento de papel para Impressão e Exportação PDF
   ========================================================================== */

/* Container de Impressão na tela normal (oculto) */
#print-document-container {
  display: none;
}

/* Modal de Pré-visualização do PDF */
#modal-pdf-preview .mrs-modal-window {
  max-width: 920px;
  width: 96%;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
}

#modal-pdf-preview .modal-body {
  background: #1E293B;
  padding: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 520px;
}

.pdf-iframe-wrapper {
  width: 100%;
  height: 75vh;
  min-height: 500px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #0F172A;
}

.pdf-stream-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #FFFFFF;
  display: block;
}

.pdf-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  z-index: 10;
  transition: opacity 0.25s ease;
}

.pdf-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #FFCC00;
  border-radius: 50%;
  animation: spin-pdf 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin-pdf {
  to { transform: rotate(360deg); }
}

/* Folha A4 do Documento (Simulação e Impressão) */
.pdf-page-sheet {
  background: #FFFFFF;
  color: #000000;
  width: 100%;
  max-width: 790px;
  min-height: 1020px;
  padding: 20px 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1.25;
  box-sizing: border-box;
}

/* Cabeçalho do Documento */
.pdf-header-grid {
  display: grid;
  grid-template-columns: 140px 1fr 150px;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1.5px solid #000000;
  padding-bottom: 8px;
}

.pdf-logo-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.pdf-mrs-logo-img {
  height: 38px;
  width: auto;
}

.pdf-title-col {
  text-align: center;
}

.pdf-main-title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #000000;
  text-transform: uppercase;
  margin: 0;
}

.pdf-meta-col {
  text-align: right;
  font-size: 9.5px;
  font-weight: 700;
  color: #1E293B;
  line-height: 1.35;
}

/* Linhas de Identificação */
.pdf-fields-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 6px;
  font-size: 10.5px;
  flex-wrap: nowrap;
  gap: 8px;
}

.pdf-field-item {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.pdf-field-item.grow {
  flex: 1;
}

.pdf-field-label {
  font-weight: 700;
  color: #000000;
  margin-right: 4px;
}

.pdf-field-value {
  border-bottom: 1px solid #000000;
  padding: 0 4px;
  min-width: 60px;
  display: inline-block;
  font-weight: 600;
  color: #000000;
}

.pdf-field-value.full-line {
  flex: 1;
  width: 100%;
}

.pdf-field-value.sig-field {
  min-width: 130px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  padding: 0 4px;
}

.pdf-sig-img {
  max-height: 26px;
  max-width: 120px;
  object-fit: contain;
}

.pdf-cursive-sig {
  font-family: 'Dancing Script', cursive, sans-serif;
  font-size: 16px;
  color: #002D62;
  font-weight: 700;
}

/* Tabelas Oficiais */
.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5px;
  margin-bottom: 6px;
  border: 1.5px solid #000000;
  font-size: 10px;
}

.pdf-table th,
.pdf-table td {
  border: 1px solid #000000;
  padding: 3px 5px;
  vertical-align: middle;
}

.pdf-table th {
  background-color: #D5D8DC;
  font-weight: 800;
  text-align: center;
  color: #000000;
  font-size: 9.5px;
  text-transform: uppercase;
}

.pdf-table .col-center {
  text-align: center;
}

.pdf-table .col-num {
  width: 26px;
  text-align: center;
  font-weight: 700;
}

.pdf-table .col-cat {
  width: 82px;
  font-weight: 700;
  text-align: center;
  background-color: #F8FAFC;
}

.pdf-table .col-opt-atencao {
  width: 78px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
}

.pdf-table .col-opt-ok {
  width: 58px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
}

/* Marcação de Opções com [ X ] */
.pdf-check-mark {
  font-family: 'Courier New', monospace;
  font-weight: 900;
  font-size: 11px;
  display: inline-block;
}

.pdf-check-mark.active {
  color: #000000;
}

.pdf-check-mark.inactive {
  color: #94A3B8;
}

/* Linha de Corte / Destacável */
.pdf-cut-section {
  margin: 10px 0 12px;
  text-align: center;
}

.pdf-cut-line {
  border-top: 1.5px dashed #475569;
  position: relative;
  margin-bottom: 4px;
}

.pdf-cut-icon {
  position: absolute;
  top: -9px;
  left: 10px;
  background: #FFFFFF;
  padding: 0 4px;
  font-size: 12px;
}

.pdf-cut-warning {
  font-size: 9px;
  font-weight: 700;
  color: #000000;
  text-transform: uppercase;
  margin: 0;
  letter-spacing: 0.3px;
}

/* Rodapé Oficial */
.pdf-footer-section {
  margin-top: 8px;
  font-size: 8.5px;
  color: #000000;
  line-height: 1.35;
}

.pdf-footer-instructions strong {
  display: block;
  margin-bottom: 2px;
}

.pdf-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid #000000;
  font-weight: 700;
  font-size: 8px;
}

/* ==========================================================================
   REGRAS ESPECÍFICAS DE IMPRESSÃO (@media print)
   Garante 1 página A4 sem elementos de navegação ou fundo da página
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 6mm 8mm 6mm 8mm;
  }

  html, body {
    background: #FFFFFF !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Oculta tudo que pertence ao app móvel */
  #app-viewport-wrapper,
  .mrs-modal-backdrop,
  .app-bottom-nav,
  #toast-container,
  .btn-header-back,
  header,
  footer {
    display: none !important;
  }

  /* Exibe exclusivamente a folha do documento na impressão */
  #print-document-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .pdf-page-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }
}
