/* =========================================
   1. CORE TYPOGRAPHY & RESET
   ========================================= */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 11pt;
  color: #000;
  background: #505050;

  /* RESET TOTAL: Hapus padding 40px yg lama */
  padding: 0;
  margin: 0;

  line-height: 1.5;
}

/* KERTAS MEMANJANG */
.paper {
  background: white;

  /* UBAH JADI PIXEL (Supaya 100% Akurat dengan JS) */
  width: 794px;

  /* TINGGI MINIMAL (Biarkan auto atau pixel) */
  min-height: 1123px; /* Setara 297mm */

  /* MARGIN TENGAH */
  margin: 40px auto; /* Margin atas 40px buat estetika web, nanti dihilangkan JS saat print */

  /* HAPUS SHADOW (PENTING! Shadow bikin ukuran melenceng saat screenshot) */
  box-shadow: none;
  border: 1px solid #ccc; /* Pakai border tipis aja sebagai pengganti shadow */

  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}

.header-img-container {
  width: 100%;
  line-height: 0;
  margin-bottom: 0;
}
.header-img-container img {
  width: 100%;
  display: block;
}

.footer-img-container {
  width: 100%;
  line-height: 0;
  margin-top: 30px;
}
.footer-img-container img {
  width: 100%;
  display: block;
}

.img-placeholder {
  background: #f0f0f0;
  color: #888;
  text-align: center;
  padding: 20px;
  font-size: 10pt;
  border: 2px dashed #ccc;
}

/* ISI KONTEN */
.main-content {
  padding: 5mm 20mm;
  width: 100%;
  box-sizing: border-box;
}

/* TYPOGRAPHY */
.doc-title {
  text-align: center;
  margin-bottom: 25px;
  margin-top: 10px;
}
.doc-title h2 {
  margin: 0;
  font-size: 16pt;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: underline;
}
.doc-subtitle {
  text-align: center;
  font-size: 11pt;
  font-weight: bold;
  margin-top: 5px;

  /* GANTI JADI INI: */
  font-family: "Consolas", "Monaco", "Andale Mono", monospace;
  color: #000;
}

.editable-text {
  cursor: text;
  padding: 2px;
  border-radius: 3px;
  outline: none;
}
.editable-text:hover,
.editable-text:focus {
  background: rgba(245, 165, 17, 0.1);
}
.opening-paragraph,
.transition-paragraph {
  text-align: justify;
  margin-bottom: 20px;
  font-size: 11pt;
}

/* --- INFO BOXES (PERBAIKAN FONT & BORDER) --- */
.info-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}
.info-box {
  background: #fff;
  padding: 15px;
  /* REVISI: Border dimatikan total, hanya menyisakan border kiri */
  border: none;
  border-left-width: 8px;
  border-left-style: solid;
}
.box-sender {
  border-left-color: #f5a511 !important;
}
.box-receiver {
  border-left-color: #222 !important;
}

.info-box label {
  display: block;
  font-weight: 700;
  font-size: 10pt;
  color: #444;
  text-transform: uppercase;
  margin-bottom: 5px;
  /* Hilangkan garis bawah label agar lebih bersih */
  border-bottom: none;
}

/* INPUT FORM LEBIH BESAR & BERSIH */
input.clean-input,
textarea.clean-input {
  width: 100%;
  font-family: inherit;
  font-size: 12pt; /* REQ 1: Font Nama Pihak diperbesar */
  font-weight: 600;
  border: 1px dashed #ccc; /* Border putus2 saat ngisi */
  padding: 4px;
  background: transparent;
  margin-bottom: 2px;
}
input.clean-input:focus,
textarea.clean-input:focus {
  outline: none;
  border-color: #f5a511;
  background: #fffdf5;
  border-style: solid;
}

/* --- TABEL (PERBAIKAN RATA KIRI) --- */
.delivery-info {
  margin: 15px 0;
  font-weight: bold;
  border-bottom: 2px solid #000;
  padding-bottom: 5px;
  font-size: 11pt;
}
.item-section {
  margin-bottom: 20px;
}
.section-title {
  font-weight: bold;
  font-size: 11pt;
  margin-bottom: 5px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
}
.remove-btn {
  color: red;
  cursor: pointer;
  font-size: 9pt;
  border: none;
  background: none;
}

table.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10pt;
  margin-bottom: 10px;
  table-layout: fixed;
}
table.custom-table td,
table.custom-table th {
  border: 1px solid #888;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
}
table.custom-table th {
  background: #222;
  color: white;
  font-weight: 700;
}

/* REQ 4: Kolom Pertama (Nama Barang) Rata Kiri */
table.custom-table td:first-child {
  text-align: left !important;
  padding-left: 8px;
}

input.qty {
  width: 100%;
  border: none;
  text-align: center;
  font-weight: bold;
  background: transparent;
  font-size: 10pt;
}
tr.total-row {
  background-color: #f5a511 !important;
  font-weight: 700;
}
.grand-total {
  text-align: right;
  font-weight: 700;
  font-size: 13pt;
  margin-top: 5px;
  padding: 8px;
  background-color: #f5a511 !important;
  border: none;
}

/* --- FOOTER & TTD (PERBAIKAN BACKGROUND & POSISI) --- */
.footer-wrap {
  margin-top: 30px;
}
.legal-clause {
  margin-top: 10px;
  font-size: 11pt;
  font-style: normal;
  text-align: justify;
  border-top: 1px solid #000;
  padding-top: 10px;
}

.signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 20px;
  text-align: center;
}
.sig-block p {
  margin-bottom: 5px;
  font-weight: bold;
  text-transform: uppercase;
  font-size: 10pt;
}

/* REQ 5: Hapus Background Blok Warna */
.sig-wrapper {
  position: relative;
  width: 250px;
  height: 100px;
  margin: 0 auto;
  border-bottom: 2px solid #000;
  background: transparent; /* Transparan */
}
.sig-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
.sig-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.sig-tools {
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.8);
}
.sig-tools button {
  border: none;
  background: none;
  color: red;
  font-size: 9pt;
  cursor: pointer;
}
.sig-name-input {
  margin-top: 5px;
  text-align: center;
  font-weight: 600;
  font-size: 11pt;
  border: none;
  background: transparent;
  width: 100%;
  text-transform: uppercase;
}

/* REQ 6: QR Code Pojok Kanan */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* Rata Kanan */
  justify-content: center;
  margin-top: 30px;
  margin-bottom: 10px;
  padding-right: 10px; /* Space dari tepi kertas */
}
#qrcode-box {
  margin-bottom: 5px;
}
.qr-label {
  font-size: 9pt;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: bold;
  text-align: right;
}

/* UI PANEL */
.ui-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  color: white;
}
.btn-blue {
  background: #007bff;
}
.btn-green {
  background: #28a745;
}
.btn-black {
  background: #222;
}
.btn-orange {
  background: #f5a511;
  color: white;
}
/* --- SETTINGAN FOOTER (RESET NORMAL) --- */
.footer-img-container {
  width: 100%; /* Lebar Penuh mengikuti Paper */
  margin: 0; /* HAPUS margin negatif (-20mm) yang lama! */
  padding: 0;

  /* HAPUS CELAH PUTIH BAWAH */
  line-height: 0;
  font-size: 0;
  display: block;
  background: transparent;

  /* PENTING: Agar nempel di dasar (jika pakai Flexbox) */
  margin-top: auto;
}

.footer-img-container img {
  width: 100%;
  display: block;
  vertical-align: bottom; /* Mematikan celah baris teks pada gambar */
  border: none;
  outline: none;
}
