/* =========================================
   BASE LAYOUT (SCREEN)
========================================= */
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

body {
  display: flex;
  background: #f5f7fa;
}

/* =========================================
   SIDEBAR
========================================= */
.sidebar {
  width: 300px;
  padding: 20px;
  background: #e9f2fa;
  border-left: 1px solid #ccc;
  height: 100vh;
  overflow-y: auto;
}

.sidebar label {
  font-size: 13px;
  font-weight: bold;
  display: block;
  margin-top: 10px;
}

.sidebar input {
  width: 100%;
  padding: 6px;
  margin-bottom: 10px;
}

.sidebar button {
  width: 100%;
  padding: 10px;
  margin-top: 5px;
  cursor: pointer;
}

/* =========================================
   MAIN AREA
========================================= */
.main {
  flex: 1;
  padding: 20px;
}

/* =========================================
   GRID PREVIEW (SCREEN)
========================================= */
.grid-container {
  display: grid;
  grid-template-columns: 50mm 50mm;
  column-gap: 5mm;
  row-gap: 5mm;
}

/* =========================================
   BARCODE CARD — SCREEN
========================================= */
.barcode-card {
  width: 50mm;
  height: 20mm;
  box-sizing: border-box;
  border: 1px solid #ddd;
  padding: 2mm;
  background: #fff;
  position: relative;
  font-size: 12px;
}

/* NAMA PRODUK */
.name-row {
  font-weight: bold;
  font-size: 10px;
  text-align: left;
}

/* HARGA & GRADE */
.price-row {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  margin-top: 2px;
}

/* BARCODE */
.barcode {
  display: block;
  width: 30mm;
  height: 7mm;
  margin: 3px auto 0;
}

/* =========================================
   PRINT MODE — THERMAL LABEL 50x20mm
========================================= */
@media print {

  /* HILANGKAN UI */
  .sidebar,
  button,
  input,
  label,
  h3 {
    display: none !important;
  }

  /* RESET HALAMAN */
  @page {
    size: 106mm auto;
    margin: 0;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 106mm !important;
    background: #fff !important;
  }

  /* MATIKAN FLEX MAIN */
  .main {
    display: block !important;
    padding: 0 !important;
  }

  /* GRID PRINT — WAJIB */
  .grid-container {
    display: grid !important;
    grid-template-columns: 50mm 50mm !important;
    column-gap: 3mm !important;
    row-gap: 0mm !important;
    grid-auto-flow: row dense !important;
    width: 106mm !important;
  }

  .barcode-card {
    width: 50mm !important;
    height: 20mm !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
    position: relative !important;
    contain: layout paint !important;
  }
  /* NAMA PRODUK */
  .name-row {
    position: absolute !important;
    top: 1mm !important;
    left: 1mm !important;
    width: 47mm !important;
    height: 7mm !important;
    font-size: 3mm !important;
    font-weight: bold !important;
    line-height: 3.2mm !important;
    white-space: normal !important;
    overflow: hidden !important;
  }

  /* HARGA & GRADE */
  .price-row {
    position: absolute !important;
    top: 9mm !important;
    left: 1mm !important;
    width: 48mm !important;
    font-size: 3mm !important;
    font-weight: bold !important;
    display: flex !important;
    justify-content: space-between !important;
  }

  /* BARCODE */
  .barcode {
    position: absolute !important;
    bottom: 0.5mm !important;
    left: 10mm !important;
    width: 30mm !important;
    height: 7mm !important;
  }
}
