/* print-uplatnica.css - Единая печатная форма уплатницы (унифицированная версия) */
/* Используется на всех страницах для генерации печатной версии платежки */

/* ============================================
   ОСНОВНОЙ КОНТЕЙНЕР ПЕЧАТНОЙ ФОРМЫ
   ============================================ */

.uplatnica-print {
  width: 210mm;
  min-height: 89mm;
  display: flex;
  font-family: Arial, sans-serif;
  font-size: 10pt;
  position: relative;
  padding: 4mm;
  box-sizing: border-box;
  background: white;
  border: 1px solid #ddd;
  margin: 10px auto;
}

/* ============================================
   СТРУКТУРА: ЛЕВАЯ И ПРАВАЯ ЧАСТИ
   ============================================ */

.uplatnica-print .left,
.uplatnica-print .right {
  width: 50%;
  padding-right: 4mm;
  box-sizing: border-box;
}

/* ============================================
   ОБЩИЕ СТИЛИ ДЛЯ ПОЛЕЙ
   ============================================ */

.uplatnica-print label {
  font-size: 9pt;
  text-transform: lowercase;
  display: block;
  margin-bottom: 0.1mm;
  color: #666;
  font-weight: normal;
}

/* Фиксированная высота для заголовков в таблице */
.uplatnica-print .trs label {
  min-height: 18pt;
  display: flex;
  align-items: flex-end;
  line-height: 1.1;
}

.uplatnica-print .field { 
  margin-bottom: 1mm; 
}

/* Больше отступа между полями в левой части */
.uplatnica-print .left .field {
  margin-bottom: 1mm;
}

/* Дополнительный отступ сверху для поля прималац */
.uplatnica-print .left .field:nth-child(3) {
  margin-top: 1mm;
}

.uplatnica-print .box {
  border: 1px solid #000;
  min-height: 7mm;
  padding: 0.5mm 1mm 0.1mm 1mm;
  box-sizing: border-box;
  word-wrap: break-word;
  font-size: 10pt;
  line-height: 1.2;
}

/* ============================================
   РАЗМЕРЫ ПОЛЕЙ
   ============================================ */

.uplatnica-print .tall .box {
  height: 17mm;
  line-height: 1.3;
  padding-top: 1mm;
}

.uplatnica-print .small .box { 
  height: 8mm; 
}

.uplatnica-print .big .box { 
  height: 8mm; 
  font-size: 12pt; 
  font-weight: bold; 
  text-align: left;
}

/* ============================================
   ТАБЛИЦА ПРАВОЙ ЧАСТИ (шифра, валута, износ)
   ============================================ */

.uplatnica-print .trs {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1mm;
}

.uplatnica-print .trs td { 
  padding-right: 4mm; 
  vertical-align: top;
}

.uplatnica-print .trs td:nth-child(1) {
  width: 20%;
}

.uplatnica-print .trs td:nth-child(2) {
  width: 20%;
}

.uplatnica-print .trs td:nth-child(3) {
  width: 50%;
}

.uplatnica-print .trs td:last-child {
  padding-right: 0;
}

/* ============================================
   МОДЕЛЬ И ПОЗИВ НА БРОЈ
   ============================================ */

.uplatnica-print .ref { 
  display: flex; 
  gap: 4mm; 
  margin-top: 3mm; 
}

.uplatnica-print .ref > div:first-child {
  width: 15%;
  flex-shrink: 0;
}

.uplatnica-print .ref-number { 
  flex: 1; 
}

/* ============================================
   ФУТЕР (подпись, дата)
   ============================================ */

.uplatnica-print .footer-left, 
.uplatnica-print .footer-right { 
  margin-top: 4mm; 
}

.uplatnica-print .footer-right {
  max-width: 55mm;
}

.uplatnica-print .line {
  border-bottom: 1px solid #000;
  height: 8mm;
  margin-bottom: 0.5mm;
}

.uplatnica-print .footer-left label,
.uplatnica-print .footer-right label {
  margin-bottom: 0;
  margin-top: 0.5mm;
}

/* ============================================
   QR КОД
   ============================================ */

.uplatnica-print .qr {
  position: absolute;
  bottom: 2mm;
  right: 2mm;
  width: 37mm;
  height: 37mm;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  overflow: hidden;
}

.uplatnica-print .qr img,
.uplatnica-print .qr canvas {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

/* ============================================
   ФУТЕР "ГЕНЕРИСАНО НА PLATIM.RS"
   ============================================ */

.uplatnica-print .generated-footer {
  position: absolute;
  bottom: 1mm;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 8pt;
  color: #888;
  font-style: italic;
}

/* ============================================
   НАСТРОЙКИ ПЕЧАТИ
   ============================================ */

@page {
  size: A4;
  margin: 0;
}

@media print {
  /* Убираем границу и отступ при печати */
  .uplatnica-print {
    border: none;
    margin: 0;
    page-break-after: always;
  }
  
  .uplatnica-print:last-child {
    page-break-after: auto;
  }
  
  /* Скрываем все элементы с классом .no-print */
  .no-print {
    display: none !important;
  }
}

/* ============================================
   КОМПАКТНЫЙ РЕЖИМ ДЛЯ НЕСКОЛЬКИХ УПЛАТНИЦ
   (3 уплатницы на одной странице A4)
   ============================================ */

@media print {
  /* Контейнер с классом .print-compact активирует компактный режим */
  .print-compact .uplatnica-print {
    /* Уменьшаем высоту до ~95мм для размещения 3 платежек на A4 (297мм) */
    min-height: 95mm;
    max-height: 95mm;
    padding: 2mm;
    margin: 0 0 2mm 0;
    page-break-after: auto;
    page-break-inside: avoid;
  }

  .print-compact .uplatnica-print:last-child {
    margin-bottom: 0;
  }

  /* Уменьшаем размеры полей в компактном режиме */
  .print-compact .uplatnica-print .box {
    min-height: 5mm;
    padding: 0.3mm 0.8mm 0.1mm 0.8mm;
    font-size: 9pt;
    line-height: 1.15;
  }

  .print-compact .uplatnica-print .tall .box {
    height: 14mm;
    line-height: 1.2;
    padding-top: 0.5mm;
  }

  .print-compact .uplatnica-print .small .box {
    height: 6mm;
  }

  .print-compact .uplatnica-print .big .box {
    height: 6mm;
    font-size: 11pt;
  }

  /* Уменьшаем отступы между полями */
  .print-compact .uplatnica-print .field {
    margin-bottom: 0.8mm;
  }

  .print-compact .uplatnica-print .left .field {
    margin-bottom: 0.8mm;
  }

  .print-compact .uplatnica-print .left .field:nth-child(3) {
    margin-top: 0.5mm;
  }

  /* Уменьшаем размер QR кода */
  .print-compact .uplatnica-print .qr-container {
    width: 24.2mm;
    height: 24.2mm;
  }

  .print-compact .uplatnica-print .qr-container canvas {
    max-width: 24.2mm !important;
    max-height: 24.2mm !important;
  }

  /* Уменьшаем шрифт для меток */
  .print-compact .uplatnica-print label {
    font-size: 8pt;
    margin-bottom: 0.05mm;
  }

  .print-compact .uplatnica-print .trs label {
    min-height: 16pt;
  }

  /* Уменьшаем размер таблицы правой части */
  .print-compact .uplatnica-print .trs {
    margin-bottom: 0.8mm;
  }

  .print-compact .uplatnica-print .trs td {
    padding: 0 0.5mm;
  }
}
