/* =====================
   Warehouse Location Label Generator
   All styles scoped under #warehouse-labels to avoid conflicts
   ===================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700&family=DM+Sans:wght@400;500;600&display=swap');

/* ── Layout ─────────────────────────────────────────────────── */
#warehouse-labels .wh-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f0efe9;
}

#warehouse-labels .wh-toolbar {
  background: #181816;
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

#warehouse-labels .wh-toolbar h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin: 0;
}

#warehouse-labels .wh-spec {
  font-size: 11px;
  opacity: .45;
  margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
  display: block;
}

#warehouse-labels .wh-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 20px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Panels ─────────────────────────────────────────────────── */
#warehouse-labels .wh-panel {
  background: white;
  border: 1px solid #dddbd4;
  border-radius: 8px;
  overflow: hidden;
}

#warehouse-labels .wh-config-panel {
  overflow-y: auto;
}

#warehouse-labels .wh-preview-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#warehouse-labels .wh-ph {
  padding: 12px 16px;
  border-bottom: 1px solid #dddbd4;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6b6a64;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#warehouse-labels .wh-ph-hint {
  font-size: 10px;
  font-weight: 400;
  opacity: .6;
}

#warehouse-labels .wh-pb {
  padding: 16px;
}

#warehouse-labels .wh-section-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6b6a64;
  margin-bottom: 8px;
}

/* ── Zone list ──────────────────────────────────────────────── */
#warehouse-labels .wh-zone-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

#warehouse-labels .wh-zone-row {
  border: 1px solid #dddbd4;
  border-radius: 6px;
  overflow: hidden;
  transition: border-color .12s;
}
#warehouse-labels .wh-zone-row:hover { border-color: #bbb; }
#warehouse-labels .wh-zone-row.active { border-color: #181816 !important; }

#warehouse-labels .wh-zr-view {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  cursor: pointer;
  background: white;
}
#warehouse-labels .wh-zone-row.active .wh-zr-view { background: #fafaf7; }

#warehouse-labels .wh-zone-swatch {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: .05em;
}

#warehouse-labels .wh-zone-info { flex: 1; min-width: 0; }
#warehouse-labels .wh-zcode-lbl { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; }
#warehouse-labels .wh-zname-lbl { font-family: 'DM Sans', sans-serif; font-size: 11px; color: #6b6a64; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#warehouse-labels .wh-zone-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
#warehouse-labels .wh-zone-count { background: #f0efe9; border: 1px solid #dddbd4; color: #6b6a64; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; }

#warehouse-labels .wh-icon-btn { background: none; border: none; cursor: pointer; padding: 4px; border-radius: 3px; color: #6b6a64; display: flex; align-items: center; transition: background .1s, color .1s; }
#warehouse-labels .wh-icon-btn:hover { background: #f0efe9; color: #181816; }
#warehouse-labels .wh-icon-btn.del:hover { color: #c0392b; background: #fef2f2; }
#warehouse-labels .wh-icon-btn svg { width: 12px; height: 12px; }

/* ── Zone edit state ────────────────────────────────────────── */
#warehouse-labels .wh-zr-edit { display: none; padding: 9px 10px; gap: 7px; background: #fafaf7; flex-direction: column; }
#warehouse-labels .wh-zone-row.editing .wh-zr-view { display: none; }
#warehouse-labels .wh-zone-row.editing .wh-zr-edit { display: flex; }

#warehouse-labels .wh-edit-row1 { display: flex; align-items: center; gap: 8px; }
#warehouse-labels .wh-color-wrap { position: relative; width: 32px; height: 32px; border-radius: 4px; overflow: hidden; flex-shrink: 0; cursor: pointer; }
#warehouse-labels .wh-color-wrap input[type=color] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0; }
#warehouse-labels .wh-color-preview { position: absolute; inset: 0; border-radius: 4px; pointer-events: none; display: flex; align-items: center; justify-content: center; }
#warehouse-labels .wh-color-preview span { font-family: 'JetBrains Mono', monospace; font-size: 8px; font-weight: 700; color: white; letter-spacing: .04em; }

#warehouse-labels .wh-code-input { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; border: 1px solid #dddbd4; border-radius: 4px; padding: 5px 8px; width: 52px; text-transform: uppercase; outline: none; background: white; color: #181816; letter-spacing: .06em; }
#warehouse-labels .wh-code-input:focus { border-color: #181816; }
#warehouse-labels .wh-name-input-edit { flex: 1; font-family: 'DM Sans', sans-serif; font-size: 12px; border: 1px solid #dddbd4; border-radius: 4px; padding: 5px 8px; outline: none; background: white; color: #181816; }
#warehouse-labels .wh-name-input-edit:focus { border-color: #181816; }

#warehouse-labels .wh-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
#warehouse-labels .wh-save-btn { background: #181816; color: white; border: none; border-radius: 4px; padding: 4px 12px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: 'DM Sans', sans-serif; }
#warehouse-labels .wh-save-btn:hover { opacity: .82; }
#warehouse-labels .wh-cancel-btn { background: none; border: 1px solid #dddbd4; border-radius: 4px; padding: 4px 10px; font-size: 11px; cursor: pointer; color: #6b6a64; font-family: 'DM Sans', sans-serif; }
#warehouse-labels .wh-cancel-btn:hover { border-color: #999; color: #181816; }

/* ── Add zone button ────────────────────────────────────────── */
#warehouse-labels .wh-add-zone-btn { width: 100%; padding: 8px; background: none; border: 1px dashed #dddbd4; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 12px; color: #6b6a64; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: border-color .12s, color .12s; margin-bottom: 14px; }
#warehouse-labels .wh-add-zone-btn:hover { border-color: #999; color: #181816; }

/* ── Bay config ─────────────────────────────────────────────── */
#warehouse-labels .wh-divider { height: 1px; background: #dddbd4; margin: 14px 0; }
#warehouse-labels .wh-cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
#warehouse-labels .wh-cfg-field { display: flex; flex-direction: column; gap: 5px; }
#warehouse-labels .wh-cfg-field label { font-family: 'DM Sans', sans-serif; font-size: 10.5px; color: #6b6a64; font-weight: 500; }

#warehouse-labels select,
#warehouse-labels input[type="number"] { border: 1px solid #dddbd4; border-radius: 5px; padding: 7px 9px; font-family: 'JetBrains Mono', monospace; font-size: 12px; background: white; color: #181816; outline: none; width: 100%; }
#warehouse-labels select:focus,
#warehouse-labels input[type="number"]:focus { border-color: #181816; }

#warehouse-labels .wh-add-btn { width: 100%; padding: 11px; background: #181816; color: white; border: none; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .12s; margin-top: 4px; }
#warehouse-labels .wh-add-btn:hover { opacity: .82; }
#warehouse-labels .wh-count-preview { font-family: 'DM Sans', sans-serif; font-size: 11px; color: #6b6a64; text-align: center; margin-top: 8px; }

/* ── Tag chips ──────────────────────────────────────────────── */
#warehouse-labels .wh-tag-field { display: flex; flex-direction: column; gap: 5px; }
#warehouse-labels .wh-tag-field label { font-family: 'DM Sans', sans-serif; font-size: 10.5px; color: #6b6a64; font-weight: 500; }

#warehouse-labels .wh-tag-box { border: 1px solid #dddbd4; border-radius: 5px; padding: 4px 6px; background: white; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 36px; cursor: text; transition: border-color .15s; }
#warehouse-labels .wh-tag-box:focus-within { border-color: #181816; }

#warehouse-labels .wh-tag-chip { display: inline-flex; align-items: center; gap: 3px; background: #f0efe9; border: 1px solid #dddbd4; border-radius: 4px; padding: 2px 6px 2px 7px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; white-space: nowrap; }
#warehouse-labels .wh-tag-chip .rm { background: none; border: none; cursor: pointer; color: #6b6a64; padding: 0; line-height: 1; font-size: 13px; display: flex; align-items: center; margin-left: 1px; }
#warehouse-labels .wh-tag-chip .rm:hover { color: #c0392b; }

#warehouse-labels .wh-tag-input { border: none; outline: none; font-family: 'JetBrains Mono', monospace; font-size: 12px; background: transparent; color: #181816; min-width: 36px; flex: 1; padding: 2px 3px; }

#warehouse-labels .wh-no-cols-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
#warehouse-labels .wh-no-cols-row input[type=checkbox] { width: auto; accent-color: #181816; cursor: pointer; }
#warehouse-labels .wh-no-cols-row label { font-family: 'DM Sans', sans-serif; font-size: 11px; color: #6b6a64; cursor: pointer; font-weight: 400; }

/* ── Preview panel ──────────────────────────────────────────── */
#warehouse-labels .wh-queue-bar { padding: 10px 16px; border-bottom: 1px solid #dddbd4; font-family: 'DM Sans', sans-serif; font-size: 11.5px; color: #6b6a64; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
#warehouse-labels .wh-clear-btn { font-family: 'DM Sans', sans-serif; font-size: 11px; color: #6b6a64; background: none; border: none; cursor: pointer; text-decoration: underline; padding: 0; }
#warehouse-labels .wh-clear-btn:hover { color: #c0392b; }

#warehouse-labels .wh-preview-grid { padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; max-height: 100%; overflow-y: auto; }

#warehouse-labels .wh-empty-state { padding: 56px 24px; text-align: center; color: #6b6a64; font-family: 'DM Sans', sans-serif; font-size: 13px; line-height: 1.7; }
#warehouse-labels .wh-empty-icon { font-size: 28px; opacity: .2; display: block; margin-bottom: 12px; letter-spacing: .2em; font-family: 'JetBrains Mono', monospace; }

/* ── Preview cards ──────────────────────────────────────────── */
#warehouse-labels .wh-lcard { height: 100px; border-radius: 6px; background: white; border: 1px solid #dddbd4; display: flex; overflow: hidden; flex-shrink: 0; }
#warehouse-labels .wh-lcard-band { width: 32.3%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: white; white-space: nowrap; letter-spacing: 0; }
#warehouse-labels .wh-lcard-bay { width: 28.3%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-left: 1px solid #dddbd4; border-right: 1px solid #dddbd4; position: relative; }
#warehouse-labels .wh-lcard-bay-label { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-family: 'DM Sans', sans-serif; font-size: 7px; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: .08em; }
#warehouse-labels .wh-lcard-bay-value { font-family: 'JetBrains Mono', monospace; font-size: 36px; font-weight: 700; color: #111; line-height: 1; }
#warehouse-labels .wh-lcard-right { flex: 1; display: flex; flex-direction: column; }
#warehouse-labels .wh-lcard-shelf { flex: 1; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid #dddbd4; position: relative; }
#warehouse-labels .wh-lcard-col { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
#warehouse-labels .wh-lcard-cell-label { position: absolute; top: 3px; left: 5px; font-family: 'DM Sans', sans-serif; font-size: 7px; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: .08em; line-height: 1; }
#warehouse-labels .wh-lcard-cell-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; color: #111; line-height: 1; }
#warehouse-labels .wh-lcard-arrow { font-size: 14px; font-weight: 700; margin-left: 2px; }

/* ── Sheet separators ───────────────────────────────────────── */
#warehouse-labels .wh-sheet-sep { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
#warehouse-labels .wh-sheet-sep-line { flex: 1; height: 1px; background: #dddbd4; }
#warehouse-labels .wh-sheet-sep-label { font-family: 'DM Sans', sans-serif; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: #6b6a64; white-space: nowrap; }

/* ── Print note ─────────────────────────────────────────────── */
#warehouse-labels .wh-print-note { margin: 0 20px 20px; padding: 12px 16px; background: #fffbeb; border: 1px solid #f59e0b; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 12px; color: #78350f; display: flex; gap: 10px; line-height: 1.5; flex-shrink: 0; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  #warehouse-labels .wh-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  #warehouse-labels .wh-preview-col {
    min-height: 400px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES — Warehouse Label Sheets
   Applied when body has .wh-printing class
   ═══════════════════════════════════════════════════════════════ */

/* Print sheets container — hidden on screen */
.wh-print-sheets { display: none; }

@media print {
  /* When NOT warehouse-printing, hide the print sheets */
  body:not(.wh-printing) .wh-print-sheets { display: none !important; }

  /* When warehouse-printing, hide everything except print sheets */
  body.wh-printing * { visibility: hidden; }
  body.wh-printing { background: white; margin: 0; padding: 0; }
  body.wh-printing .wh-print-sheets { display: block !important; visibility: visible; position: absolute; top: 0; left: 0; width: 100%; }
  body.wh-printing .wh-print-sheets * { visibility: visible; }

  /* Print color accuracy */
  body.wh-printing * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.wh-printing { overflow: visible; height: auto; }
  body.wh-printing html { overflow: visible; height: auto; }

  @page { size: A4 portrait; margin: 0mm; }

  .wh-sheet {
    width: 210mm;
    height: 297mm;
    padding-top: 15.09mm;
    padding-left: 4.65mm;
    display: grid;
    grid-template-columns: 99.1mm 99.1mm;
    grid-auto-rows: 38.1mm;
    column-gap: 2.54mm;
    row-gap: 0mm;
    align-content: start;
    page-break-after: always;
    overflow: hidden;
  }
  .wh-sheet:last-child { page-break-after: auto; }

  .wh-plabel {
    width: 99.1mm;
    height: 38.1mm;
    border: 0.4mm solid #ccc;
    border-radius: 5mm;
    display: flex;
    overflow: hidden;
    background: white;
  }
  .wh-plabel-blank { width: 99.1mm; height: 38.1mm; }

  .wh-pband {
    width: 32mm;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 46pt;
    font-weight: 700;
    color: white;
    letter-spacing: 0;
    border-radius: 4.2mm 0 0 4.2mm;
    padding: 0 1.5mm;
    white-space: nowrap;
    overflow: hidden;
  }

  .wh-pbay-section {
    width: 28mm;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 0.4mm solid #ddd;
    border-right: 0.4mm solid #ddd;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
  }
  .wh-pbay-label { position: absolute; top: 1mm; left: 0; right: 0; text-align: center; font-family: 'DM Sans', sans-serif; font-size: 8pt; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: .12em; line-height: 1; }
  .wh-pbay-value { font-family: 'JetBrains Mono', monospace; font-size: 62pt; font-weight: 700; color: #111; line-height: 1; }

  .wh-pright-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .wh-pshelf-cell { flex: 1; display: flex; align-items: center; justify-content: center; border-bottom: 0.4mm solid #ddd; position: relative; overflow: hidden; }
  .wh-pcol-cell { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
  .wh-pcell-label { position: absolute; top: .8mm; left: 1.5mm; font-family: 'DM Sans', sans-serif; font-size: 6pt; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: .08em; line-height: 1; }
  .wh-pcell-value { font-family: 'JetBrains Mono', monospace; font-size: 52pt; font-weight: 700; color: #111; line-height: 1; }

  .wh-pdown-arrow { font-size: 16pt; line-height: 1; color: #111; font-weight: 700; margin-left: .5mm; vertical-align: middle; }
}
