/* css/print.css - Reglas Estrictas de Impresión PDF en Formato A4 (3 Vales por Hoja) */

/* Contenedor de Hoja A4 en Vista previa Web */
.a4-print-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background-color: #4b5563;
  overflow-y: auto;
  overflow-x: auto;
  box-sizing: border-box;
}

#a4-print-preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
}

.a4-sheet-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.a4-sheet-indicator {
  width: 210mm;
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 6px 6px 0 0;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.a4-sheet {
  width: 210mm;
  min-height: 295mm;
  height: 295mm;
  max-height: 295mm;
  background-color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 4mm 8mm;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 2px 2px;
}

/* Cada uno de los 3 slots en la hoja A4 */
.print-voucher-slot {
  height: 91mm;
  max-height: 91mm;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

/* Línea de división punteada entre los vales */
.cut-line-separator {
  height: 6mm;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0;
}

.cut-line-separator::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1.5px dashed #888888;
}

.cut-line-badge {
  display: none;
}

/* Estilo Imprimible del Vale */
.print-voucher-card {
  border: 1.5px solid #147a45;
  border-radius: 0px;
  width: 100%;
  height: 91mm;
  font-family: Arial, Helvetica, sans-serif;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

.print-voucher-header {
  background-color: #147a45 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color: #ffffff !important;
  padding: 0.2mm 2mm 0.2mm 0.6mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid #147a45;
}

.print-voucher-header .logo-container {
  display: flex;
  align-items: center;
  max-width: 65mm;
  height: 9.8mm;
}

.print-voucher-header img {
  height: 9.5mm;
  max-width: 65mm;
  object-fit: contain;
  object-position: left center;
  display: block;
}

.print-voucher-header .title {
  font-size: 10.5pt;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
  flex: 1;
}

.print-voucher-header .version {
  font-size: 8pt;
  font-weight: 700;
}

.print-voucher-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  height: 100%;
}

.print-table td {
  border: 1.2px solid #147a45;
  padding: 1mm 2mm;
  vertical-align: top;
  font-size: 8.5pt;
  line-height: 1.2;
}

.print-label {
  font-size: 7.5pt;
  font-weight: 800;
  color: #147a45;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.5mm;
}

.print-date-grid {
  display: flex;
  gap: 3mm;
  text-align: center;
  font-weight: 700;
}

.print-amount-words {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 8pt;
  word-break: break-word;
  line-height: 1.15;
}

.print-amount-numeric {
  background-color: #e8f5e9 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  font-size: 10.5pt;
  font-weight: 900;
  color: #147a45;
  text-align: right;
  padding: 1mm 2mm;
}

.print-concept-cell {
  vertical-align: top;
  font-size: 8.5pt;
  line-height: 1.2;
}

.print-footer-cell {
  vertical-align: top;
  padding: 0.6mm 1.5mm 0.2mm 1.5mm;
  height: 100%;
  box-sizing: border-box;
}

.print-approval-text {
  font-weight: 700;
  font-size: 8.5pt;
}

.print-signature-line {
  border-top: 1px dashed #333;
  margin-top: 2.5mm;
  padding-top: 0.5mm;
  font-size: 7pt;
  color: #555;
}

/* -------------------------------------------------------------
   REGLAS STRICTAS PARA @media print (IMPRESIÓN A4 EXCLUSIVA)
------------------------------------------------------------- */
@media print {
  @page {
    size: A4 portrait;
    margin: 0mm;
  }

  html, body, .app-container {
    width: 210mm !important;
    height: auto !important;
    min-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
    position: static !important;
  }

  /* Ocultar interfaz general y otros modales que NO sean el modal de impresión */
  .top-header,
  .main-wrapper,
  .sidebar-nav,
  .bottom-nav,
  .content-area,
  #companies-admin-view,
  #new-voucher-view,
  #vouchers-list-view,
  #approval-queue-view,
  #dashboard-view,
  #qr-scanner-modal,
  #create-company-modal,
  #users-management-modal,
  #company-config-modal,
  #beneficiaries-modal,
  #concepts-modal,
  #detail-modal,
  .modal-header,
  .modal-footer,
  .modal-close,
  .a4-sheet-indicator,
  .no-print {
    display: none !important;
  }

  /* Hacer visible e imponer #print-modal sobre el flujo de impresión */
  #print-modal,
  #print-modal.modal-backdrop {
    display: block !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 210mm !important;
    height: auto !important;
    min-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
    z-index: 999999 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  #print-modal .modal-content,
  #print-modal .modal-body,
  #print-modal .a4-print-preview-container,
  #print-modal #a4-print-preview-content {
    display: block !important;
    position: static !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #ffffff !important;
    width: 210mm !important;
    max-width: 210mm !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .a4-sheet-wrapper {
    display: block !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .a4-sheet-wrapper:not(:last-child) {
    page-break-after: always !important;
    break-after: page !important;
  }

  .a4-sheet-wrapper:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .a4-sheet {
    width: 210mm !important;
    height: 295mm !important;
    min-height: 295mm !important;
    max-height: 295mm !important;
    box-shadow: none !important;
    padding: 4mm 8mm !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    overflow: hidden !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    border-radius: 0 !important;
  }

  .a4-sheet:not(:last-child) {
    page-break-after: always !important;
    break-after: page !important;
  }

  .a4-sheet:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    scrollbar-width: none !important;
  }

  ::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }
}
