/* Font loaded via <link> in HTML for reliable print/PDF embedding */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --frenvit-red: #c8102e;
  --frenvit-dark: #1a1a1a;
  --ink: #000;
  --line: #000;
  --bg: #f4f4f4;
}

body {
  font-family: "Space Mono", monospace;
  background: var(--bg);
  color: var(--frenvit-dark);
  padding: 20px;
  min-height: 100vh;
}

/* ============ FORM PANEL ============ */
.container {
  max-width: 1100px;
  margin: 0 auto;
}

.header {
  background: var(--frenvit-dark);
  color: white;
  padding: 24px 32px;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header .brand-mark {
  color: var(--frenvit-red);
}

.header p {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 4px;
}

.form-panel {
  background: white;
  padding: 32px;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--frenvit-red);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--frenvit-red);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  text-transform: uppercase;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--frenvit-red);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 24px;
  border-top: 1px solid #eee;
}

button {
  padding: 14px 28px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition:
    transform 0.1s,
    opacity 0.15s;
}

button:hover {
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--frenvit-red);
  color: white;
}

.btn-secondary {
  background: var(--frenvit-dark);
  color: white;
}

.btn-ghost {
  background: white;
  color: var(--frenvit-dark);
  border: 1px solid #ddd;
}

/* ============ LABEL PREVIEW ============ */
.preview-wrapper {
  margin-top: 32px;
  background: white;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.preview-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #888;
  margin-bottom: 20px;
}

.preview-scale {
  overflow: auto;
  background: #e8e8e8;
  padding: 24px;
  border-radius: 4px;
}

/* ============ THE LABEL ITSELF (A5 LANDSCAPE = 210mm x 148mm) ============ */
.awb-label {
  background: white;
  width: 210mm; /* A5 landscape width */
  min-height: 148mm;
  padding: 4mm;
  margin: 0 auto;
  color: var(--ink);
  font-family: "Space Mono", "Courier New", monospace;
  font-size: 8pt;
  border: 1.5px solid var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.awb-label table {
  width: 100%;
  border-collapse: collapse;
}

.awb-label td {
  border: 1px solid var(--ink);
  padding: 3px 5px;
  vertical-align: top;
}

.label-cell {
  font-size: 6pt;
  color: #444;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}

.value-cell {
  font-size: 8pt;
  font-weight: 600;
  line-height: 1.3;
  text-transform: uppercase;
}

/* TOP HEADER ROW */
.header-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  border: 1px solid var(--ink);
  border-bottom: none;
}

.brand-section {
  padding: 5px 8px;
  border-right: 1px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 30px !important;
  min-width: 0; /* allows flex children to shrink properly */
}

.frenvit-logo {
  font-family: "Arial Black", sans-serif;
  font-size: 16pt;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1;
}

.frenvit-logo .accent {
  color: var(--frenvit-red);
}

.brand-tag {
  font-size: 6pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #555;
  margin-top: 2px;
}

.brand-meta {
  font-size: 10px;
  line-height: 1.5;
  color: #333;
  flex: 1;
  min-width: 0; /* prevents long text from blowing out the layout */
}

.brand-meta strong {
  color: black !important;
  font-size: 14px;
}

/* LOGO — increased for better visibility */
.brand-logo {
  display: block !important;
  max-width: 110pt !important;
  max-height: 60pt !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

.brand-text {
  font-family: "Arial Black", sans-serif;
  font-size: 10pt;
  font-weight: 900;
  color: var(--frenvit-dark);
}

.barcode-section {
  padding: 5px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.barcode-section svg {
  max-width: 100%;
  height: auto;
}

.awb-number {
  font-family: "Courier New", monospace;
  font-size: 8pt;
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* ADDRESS BLOCK */
.address-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.4fr;
  border-left: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
}

.address-cell {
  border-right: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
  padding: 6px 8px;
  min-height: 50px;
}

.address-cell:last-child {
  border-right: none;
}

.address-cell .value-cell {
  font-size: 7.5pt;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 3px;
}

.dest-cell {
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}

/* Thin red top accent bar */
.dest-top {
  border-top: 3px solid var(--frenvit-red);
  text-align: center;
  padding: 5px 4px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dest-top .label-cell {
  font-size: 5pt;
  color: #999 !important;
  letter-spacing: 2.5px;
}

/* Huge clean destination code */
.dest-code {
  font-size: 30pt;
  font-weight: 900;
  line-height: 1;
  color: var(--frenvit-dark);
  letter-spacing: 6px;
  margin-top: 2px;
  padding-bottom: 6px;
}

/* Clean stats bar — light grey */
.dest-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #f2f2f2;
  border-top: 1.5px solid var(--ink);
}

.dest-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  border-right: 1px solid #ccc;
  gap: 0;
}

.dest-stat:last-child {
  border-right: none;
}

.dest-stat-label {
  font-size: 4.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  line-height: 1.2;
}

.dest-stat-val {
  font-size: 12pt;
  font-weight: 900;
  line-height: 1.1;
  color: var(--frenvit-dark);
}

.dest-stat-unit {
  font-size: 4pt;
  font-weight: 700;
  color: var(--frenvit-red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* CONTACT ROW */
.contact-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-left: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  border-top: 1px solid var(--ink);
}

.contact-row > div {
  padding: 4px 6px;
  border-right: 1px solid var(--ink);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.contact-row > div:last-child {
  border-right: none;
}

/* DESCRIPTION/PAYMENT GRID */
.desc-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  border: 1px solid var(--ink);
  border-top: none;
}

.desc-cell {
  padding: 6px 8px;
  border-right: 1px solid var(--ink);
  min-height: 50px;
}

.desc-cell:last-child {
  border-right: none;
}

.desc-cell .qty-val {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.desc-cell .qty-val > div .label-cell {
  margin-bottom: 3px;
}

/* PAYMENT METHOD */
.pay-options {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}

.pay-option {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 6.5pt;
  font-weight: 600;
}

.pay-checkbox {
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
  display: inline-block;
  text-align: center;
  line-height: 8px;
  font-weight: 900;
  font-size: 7pt;
  flex-shrink: 0;
}

.pay-checkbox.checked {
  background: white;
}
.pay-checkbox.checked::after {
  content: "✓";
  color: var(--frenvit-red);
}

/* SIGNATURE / REMARK */
.sig-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-left: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.sig-cell {
  padding: 5px 8px;
  border-right: 1px solid var(--ink);
  min-height: 38px;
}

.sig-cell:last-child {
  border-right: none;
}

.sig-line {
  border-bottom: 1px dashed #888;
  margin-top: 4px;
  padding-bottom: 14px;
}

/* DATE ROW */
.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  border-left: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.date-row > div {
  padding: 4px 6px;
  border-right: 1px solid var(--ink);
}

.date-row > div:last-child {
  border-right: none;
}

/* FOOTER */
.label-footer {
  margin-top: 3mm;
  padding: 4px 0;
  border-top: 1.5px solid var(--ink);
  display: flex;
  justify-content: space-between;
  font-size: 6pt;
  color: #444;
}

.label-footer strong {
  color: var(--frenvit-dark);
}

/* ============ PRINT ============ */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body {
    background: white;
    padding: 0;
    margin: 0;
  }
  /* Hide everything except the labels */
  .header,
  .form-panel,
  .preview-title,
  .label-separator {
    display: none !important;
  }
  .container {
    max-width: none;
    margin: 0;
    padding: 0;
  }
  .preview-wrapper {
    margin: 0;
    padding: 0;
    box-shadow: none;
    background: white;
    border-radius: 0;
  }
  /* Force both labels onto exactly one A4 page */
  .preview-scale {
    background: white !important;
    padding: 0 !important;
    overflow: hidden !important;
    width: 210mm !important;
    height: 297mm !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
  }
  /* Each label = exactly half of A4 */
  .awb-label {
    box-shadow: none;
    border: 1.5px solid black;
    margin: 0 !important;
    width: 210mm !important;
    height: 148.5mm !important;
    min-height: unset !important;
    overflow: hidden !important;
    flex: 0 0 148.5mm !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* Ensure payment options are uppercase in print */
  .pay-option {
    text-transform: uppercase !important;
  }
  .print-only {
    display: block;
  }
}

.print-only {
  display: none;
}
