/* ==========================================================================
   assets/css/bc-lot-dist-box.css
   BOM Consumption Multi-LOT Distribution Box-Based UI Stylesheet
   Task: BC-LOT-DIST-FEEDBACK-v2
   Owned by: AGY 3 (Visual Contract & Accessibility)
   File line limit: < 500 lines strictly enforced
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Window, Card Geometry & Category Badge Wrapper Reset
   - Target size around min(1120px, calc(100vw - 20px)) x min(680px, calc(100vh - 20px))
   - Safe minimum size (320px x 280px) and mobile bottom clearance
   - Override legacy 920px width constraints from screens.css
   - Reset outer #bc-lot-dist-cat-badge wrapper (has .badge class) so it does
     not show redundant background/border/padding around inner category badge.
   - Preserves inner accessible palette without overriding child spans.
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal.jfk-float-window {
  min-width: 320px;
  min-height: 280px;
  box-sizing: border-box;
}

#bc-lot-dist-modal.jfk-float-window #bc-lot-dist-card,
#bc-lot-dist-modal.jfk-float-window .jfk-float-body.pw-card {
  width: 100% !important; /* override screens.css min(920px, 96vw) !important */
  max-width: 100% !important;
  height: calc(100% - 48px);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  background-color: var(--surface, #1e293b);
  color: var(--text, #f1f5f9);
}

#bc-lot-dist-modal #bc-lot-dist-cat-badge,
#bc-lot-dist-cat-badge {
  background: transparent;
  background-color: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
  outline: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   2. Toolbar & 3-Dropdown Filter Layout
   - Labeled selects: #bc-lot-dist-filter-supplier, #bc-lot-dist-filter-bl, #bc-lot-dist-filter-mfg
   - Clean wrapping toolbar with gap and alignment
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal .bc-lot-dist-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  margin-bottom: 8px;
}

#bc-lot-dist-modal .bc-lot-dist-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

#bc-lot-dist-modal .bc-lot-dist-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#bc-lot-dist-modal .bc-lot-dist-filter-item label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted, #94a3b8);
  white-space: nowrap;
  user-select: none;
}

#bc-lot-dist-modal select.bc-lot-filter-select,
#bc-lot-dist-modal #bc-lot-dist-filter-supplier,
#bc-lot-dist-modal #bc-lot-dist-filter-bl,
#bc-lot-dist-modal #bc-lot-dist-filter-mfg {
  height: 28px;
  font-size: 12px;
  line-height: 1.2;
  padding: 2px 24px 2px 8px;
  border: 1px solid var(--border, #334155);
  border-radius: 4px;
  background-color: var(--bg, #0f172a);
  color: var(--text, #f1f5f9);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

#bc-lot-dist-modal select.bc-lot-filter-select:focus,
#bc-lot-dist-modal #bc-lot-dist-filter-supplier:focus,
#bc-lot-dist-modal #bc-lot-dist-filter-bl:focus,
#bc-lot-dist-modal #bc-lot-dist-filter-mfg:focus {
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#bc-lot-dist-modal #bc-lot-dist-filter-supplier { min-width: 120px; max-width: 180px; }
#bc-lot-dist-modal #bc-lot-dist-filter-bl { min-width: 120px; max-width: 180px; }
#bc-lot-dist-modal #bc-lot-dist-filter-mfg { min-width: 110px; max-width: 150px; }

#bc-lot-dist-modal .bc-lot-dist-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistAutoFill"],
#bc-lot-dist-modal [data-control-id="Btn_BcLotDistClearAll"] {
  height: 28px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 0 9px;
  border-radius: 4px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   3. Table Wrapper (Flex-Fill, X/Y Auto Scroll, No Fixed 360px)
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal .bc-lot-dist-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  background-color: var(--bg, #0f172a);
  position: relative;
}

/* Remove legacy fixed max-height: 360px restriction */
#bc-lot-dist-modal .pw-card > div:has(table),
#bc-lot-dist-modal .pw-card > div.bc-lot-dist-table-wrap {
  max-height: none !important;
}

/* --------------------------------------------------------------------------
   4. Table Architecture & Exactly 8-Column Layout
   Columns in exact order:
   (1) 공급사
   (2) B/L (송장번호)
   (3) LOT 번호 (제조일자)
   (4) 현재고
   (5) 박스수
   (6) 사용 박스
   (7) 선택
   (8) 비고
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal table.bc-lot-dist-table,
#bc-lot-dist-modal table.tbl-modern,
#bc-lot-dist-modal [data-control-id="Table_BcLotDist"] {
  width: 100%;
  min-width: 920px !important; /* Sufficient for 8 columns without layout crunch */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

/* Sticky Header with surface backdrop */
#bc-lot-dist-modal table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background-color: var(--surface, #1e293b);
  color: var(--muted, #94a3b8);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #334155);
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 1px 0 var(--border, #334155);
}

#bc-lot-dist-modal table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  vertical-align: middle;
  color: var(--text, #f1f5f9);
}

#bc-lot-dist-modal table tbody tr:hover td {
  background-color: rgba(255, 255, 255, 0.03);
}

/* Column Specific Alignments & Sizing */
#bc-lot-dist-modal th:nth-child(1), #bc-lot-dist-modal td:nth-child(1) { width: 120px; text-align: left; }
#bc-lot-dist-modal th:nth-child(2), #bc-lot-dist-modal td:nth-child(2) { width: 125px; text-align: left; }
#bc-lot-dist-modal th:nth-child(3), #bc-lot-dist-modal td:nth-child(3) { min-width: 160px; text-align: left; }
#bc-lot-dist-modal th:nth-child(4), #bc-lot-dist-modal td:nth-child(4) { width: 105px; text-align: right; font-family: monospace; }
#bc-lot-dist-modal th:nth-child(5), #bc-lot-dist-modal td:nth-child(5) { width: 85px; text-align: right; font-family: monospace; }
#bc-lot-dist-modal th:nth-child(6), #bc-lot-dist-modal td:nth-child(6) { width: 105px; text-align: right; }
#bc-lot-dist-modal th:nth-child(7), #bc-lot-dist-modal td:nth-child(7) { width: 105px; text-align: center; }
#bc-lot-dist-modal th:nth-child(8), #bc-lot-dist-modal td:nth-child(8) { min-width: 130px; text-align: left; }

/* --------------------------------------------------------------------------
   5. Row Input, Button, Badge & Note Sizing
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal .bc-lot-dist-box-input,
#bc-lot-dist-modal input.bc-lot-dist-input {
  width: 88px;
  height: 28px;
  font-size: 12px;
  font-family: monospace;
  font-weight: 700;
  text-align: right;
  padding: 2px 6px;
  border-radius: 3px;
  box-sizing: border-box;
  background-color: var(--surface, #1e293b);
  border: 1px solid var(--border, #334155);
  color: var(--text, #f1f5f9);
}

#bc-lot-dist-modal .bc-lot-dist-box-input:focus {
  border-color: var(--accent, #3b82f6);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#bc-lot-dist-modal .bc-lot-dist-box-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: rgba(255, 255, 255, 0.05);
}

#bc-lot-dist-modal .bc-lot-dist-full-btn {
  height: 24px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

#bc-lot-dist-modal .bc-lot-dist-note-input {
  width: 100%;
  min-width: 90px;
  height: 28px;
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border, #334155);
  background-color: var(--surface, #1e293b);
  color: var(--text, #f1f5f9);
  box-sizing: border-box;
}

#bc-lot-dist-modal .bc-lot-dist-note-input:focus {
  border-color: var(--accent, #3b82f6);
  outline: none;
}

/* --------------------------------------------------------------------------
   6. Footer (Totals Summary & Symmetrical Action Buttons)
   - Dual box sum (#bc-lot-dist-box-sum-disp) and canonical sum (#bc-lot-dist-sum-disp)
   - Btn_BcLotDistCancel and Btn_BcLotDistConfirm with matching height (32px),
     min-width (84px), padding, box-sizing:border-box, line-height, inline-flex centering
   -------------------------------------------------------------------------- */
#bc-lot-dist-modal .bc-lot-dist-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border, #334155);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

#bc-lot-dist-modal .bc-lot-dist-summary {
  font-size: 12.5px;
  color: var(--text, #f1f5f9);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

#bc-lot-dist-modal #bc-lot-dist-box-sum-disp {
  font-family: monospace;
  font-size: 14.5px;
  color: var(--accent, #3b82f6);
  font-weight: 700;
}

#bc-lot-dist-modal #bc-lot-dist-sum-disp {
  font-family: monospace;
  font-size: 13.5px;
  font-weight: 700;
}

#bc-lot-dist-modal .bc-lot-dist-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"],
#bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"] {
  height: 32px;
  min-width: 84px;
  padding: 0 14px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"] {
  background-color: transparent;
  border: 1px solid var(--border, #334155);
  color: var(--text, #f1f5f9);
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"]:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--accent, #3b82f6);
}

[data-theme="light"] #bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"]:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"] {
  background-color: var(--accent, #3b82f6);
  border: 1px solid var(--accent, #3b82f6);
  color: #ffffff;
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"]:hover {
  filter: brightness(1.08);
}

#bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

/* --------------------------------------------------------------------------
   7. Viewport <= 900px Responsive Fallback
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  #bc-lot-dist-modal .bc-lot-dist-toolbar {
    gap: 8px;
  }

  #bc-lot-dist-modal .bc-lot-dist-filters {
    gap: 8px;
  }

  #bc-lot-dist-modal select.bc-lot-filter-select {
    min-width: 95px;
    max-width: 140px;
    font-size: 11.5px;
  }

  #bc-lot-dist-modal .bc-lot-dist-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  #bc-lot-dist-modal .bc-lot-dist-footer-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* --------------------------------------------------------------------------
   8. Viewport <= 768px Mobile Adaptation
   - Symmetrical equal width footer action buttons via flex-basis 50%
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #bc-lot-dist-modal.jfk-float-window #bc-lot-dist-card {
    padding: 10px 12px;
  }

  #bc-lot-dist-modal .bc-lot-dist-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  #bc-lot-dist-modal .bc-lot-dist-filters {
    width: 100%;
  }

  #bc-lot-dist-modal .bc-lot-dist-filter-item {
    flex: 1 1 100%;
  }

  #bc-lot-dist-modal select.bc-lot-filter-select {
    width: 100%;
    max-width: none;
    height: 34px;
  }

  #bc-lot-dist-modal .bc-lot-dist-actions {
    width: 100%;
    justify-content: flex-end;
  }

  #bc-lot-dist-modal .bc-lot-dist-footer-actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  #bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"],
  #bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"] {
    flex: 1 1 50%;
    min-width: 0;
    height: 38px;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* --------------------------------------------------------------------------
   9. Forced Colors Mode & High Contrast Accessibility
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  #bc-lot-dist-modal table thead th {
    border-bottom: 2px solid CanvasText;
    box-shadow: none;
  }

  #bc-lot-dist-modal .bc-lot-dist-box-input,
  #bc-lot-dist-modal .bc-lot-dist-note-input,
  #bc-lot-dist-modal select.bc-lot-filter-select {
    border: 1px solid ButtonBorder;
    forced-color-adjust: none;
  }

  #bc-lot-dist-modal .bc-lot-dist-table-wrap {
    border: 1px solid CanvasText;
  }

  #bc-lot-dist-modal [data-control-id="Btn_BcLotDistCancel"],
  #bc-lot-dist-modal [data-control-id="Btn_BcLotDistConfirm"] {
    border: 1px solid ButtonBorder;
  }
}
