/* ══════════════════════════════════════════════════════════════════════════════
   3DL 原料廠內標籤列印中心 (Label Printing & Editing Center) - Modal Styles
   ══════════════════════════════════════════════════════════════════════════════ */

#label-print-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 10, 20, 0.82);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-sizing: border-box;
}

#label-print-modal.open {
  display: flex;
}

.lp-box {
  background: #0f172a;
  border: 1.5px solid #388bfd;
  border-radius: 16px;
  max-width: 1220px;
  width: 96vw;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.65), 0 0 30px rgba(56, 139, 253, 0.25);
  animation: lpPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  box-sizing: border-box;
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}

@keyframes lpPopIn {
  from { transform: scale(0.96) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* 頂部標題與關閉按鈕 */
.lp-header {
  padding: 14px 20px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.lp-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lp-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #60a5fa;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lp-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
}

.lp-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.lp-close-btn:hover {
  background: #dc2626;
  color: white;
  border-color: #ef4444;
}

/* 工具搜尋列與歷史批號切換橫幅 */
.lp-toolbar {
  padding: 10px 20px;
  background: #131d31;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.lp-tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lp-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.lp-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: #090e1a;
  border: 1.5px solid #2563eb;
  border-radius: 8px;
  color: white;
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}

.lp-search-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.35);
}

.lp-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.95rem;
  pointer-events: none;
}

.lp-suggest-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #1e293b;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100000;
  display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.lp-suggest-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lp-suggest-item:hover {
  background: #2563eb;
  color: white;
}

/* 歷史批號切換選單 */
.lp-batch-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.lp-select {
  padding: 6px 12px;
  background: #090e1a;
  border: 1px solid #388bfd;
  border-radius: 6px;
  color: #60a5fa;
  font-weight: 600;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.lp-banner {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.lp-banner.fallback {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

/* 雙欄主體內容區 (左邊表單，右邊即時預覽) */
.lp-body {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  padding: 16px 20px;
  overflow: hidden;
  flex: 1;
  box-sizing: border-box;
}

/* 左欄：全欄位編輯表單 */
.lp-form-pane {
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lp-form-pane::-webkit-scrollbar {
  width: 6px;
}
.lp-form-pane::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

.lp-group {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
}

.lp-group-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #93c5fd;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 5px;
}

.lp-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lp-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.lp-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.lp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lp-field.span2 {
  grid-column: span 2;
}

.lp-field label {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 500;
}

.lp-field label b {
  color: #f87171;
}

.lp-input {
  width: 100%;
  padding: 7px 10px;
  background: #090e1a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.86rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.lp-input:focus {
  border-color: #3b82f6;
  background: #0d1527;
}

.lp-input.highlight {
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.lp-input-btn-group {
  display: flex;
  gap: 4px;
}

.lp-mini-btn {
  background: #1e3a8a;
  color: #bfdbfe;
  border: 1px solid #2563eb;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.lp-mini-btn:hover {
  background: #2563eb;
  color: white;
}

/* GHS 圖示點選徽章清單 */
.lp-ghs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.lp-ghs-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.76rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.lp-ghs-badge.active {
  background: rgba(220, 38, 38, 0.2);
  border-color: #ef4444;
  color: #fca5a5;
  font-weight: 700;
}

.lp-ghs-badge:hover {
  border-color: #60a5fa;
}

/* 右欄：即時預覽面板 */
.lp-preview-pane {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lp-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.lp-preview-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lp-preview-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
  background: #334155;
  border-radius: 8px;
}

/* 實體白底標籤卡片 (模擬真實 A6/A5 標籤) */
.lp-card-mockup {
  background: #ffffff;
  color: #000000;
  width: 100%;
  max-width: 440px;
  border: 2px solid #000000;
  padding: 8px 10px;
  box-sizing: border-box;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.lpm-header {
  text-align: center;
  border-bottom: 1.5px solid #000;
  padding-bottom: 2px;
  margin-bottom: 3px;
}

.lpm-company { font-size: 13px; font-weight: 900; line-height: 1.1; }
.lpm-doc { font-size: 11px; font-weight: 900; margin-top: 1px; }
.lpm-mat-title { font-size: 11px; font-weight: 900; color: #0f172a; margin-top: 2px; word-break: break-all; }

.lpm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.5px;
  margin-bottom: 4px;
}

.lpm-table td {
  border: 1px solid #000 !important;
  padding: 1.5px 3px;
  vertical-align: middle;
  line-height: 1.15;
}

.lpm-lbl {
  background: #f4f4f4;
  font-weight: bold;
  text-align: center;
  width: 20%;
  white-space: nowrap;
}

.lpm-val-bold { font-weight: 900; }
.lpm-val-mono { font-family: monospace; }
.lpm-code { font-size: 13px; font-weight: 900; }
.lpm-batch { font-size: 11.5px; font-weight: 900; word-break: break-all; }
.lpm-drum { font-size: 12px; font-weight: 900; text-align: center; }

.lpm-stamp-table {
  width: 100%;
  border-collapse: collapse;
}

.lpm-stamp-table td {
  border: 1px solid #000;
  text-align: center;
  width: 33.3%;
  padding: 0;
  vertical-align: top;
  height: 32px;
}

.lpm-sq-title {
  font-size: 7.5px;
  font-weight: 900;
  background: #f4f4f4;
  border-bottom: 1px solid #000;
  padding: 1px 0;
}

.lpm-bottom {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.lpm-ghs-box {
  flex: 1;
  border: 1px solid #000;
  padding: 2px 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 40px;
}

.lpm-qr-box {
  width: 60px;
  border: 1px solid #000;
  padding: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.lpm-qr-mock {
  width: 44px;
  height: 44px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 9px;
  font-weight: bold;
}

/* 底部操作按鈕列 */
.lp-footer {
  padding: 12px 20px;
  background: #0b1120;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 10px;
}

.lp-footer-hint {
  font-size: 0.8rem;
  color: #64748b;
}

.lp-btn-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lp {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-lp-secondary {
  background: #334155;
  color: #cbd5e1;
}

.btn-lp-secondary:hover {
  background: #475569;
  color: white;
}

.btn-lp-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-lp-primary:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.btn-print-hero {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.18s;
}

.btn-print-hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.btn-label-hub {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s;
}

.btn-label-hub:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  .lp-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .lp-box {
    height: 96vh;
    max-height: 96vh;
  }
  .lp-preview-pane {
    max-height: 300px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   雙模式頁籤導航 (Batch Checklist vs Custom Edit)
   ══════════════════════════════════════════════════════════════════════════════ */
.lp-tab-nav {
  display: flex;
  background: #090e1a;
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
}

.lp-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #94a3b8;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.lp-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.03);
}

.lp-tab-btn.active {
  color: #388bfd;
  border-bottom-color: #388bfd;
  background: rgba(56, 139, 253, 0.08);
}

.lp-tab-badge {
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.lp-tab-btn.active .lp-tab-badge {
  background: #2563eb;
  color: white;
  border-color: #388bfd;
}

/* 批次勾選檢視容器 */
.lp-view-batch {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: #0b1120;
}

.lp-view-custom {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* 批次檢視工具列 */
.lp-batch-toolbar {
  padding: 12px 20px;
  background: #131d31;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.lp-batch-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lp-pill-btn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lp-pill-btn:hover {
  background: #334155;
  color: white;
}

.lp-pill-btn.active {
  background: #2563eb;
  border-color: #388bfd;
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.lp-pill-btn.pill-today.active {
  background: #10b981;
  border-color: #059669;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.lp-batch-search {
  position: relative;
  min-width: 220px;
}

.lp-batch-search input {
  width: 100%;
  padding: 6px 12px 6px 30px;
  background: #090e1a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: white;
  font-size: 0.82rem;
  outline: none;
  box-sizing: border-box;
}

.lp-batch-search input:focus {
  border-color: #388bfd;
}

.lp-batch-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.85rem;
  pointer-events: none;
}

/* 批次操作與統計條 */
.lp-batch-action-bar {
  padding: 10px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lp-check-all-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: #388bfd;
  cursor: pointer;
  user-select: none;
}

.lp-batch-stat-text {
  font-size: 0.85rem;
  color: #94a3b8;
}

.lp-batch-stat-text b {
  color: #f59e0b;
  font-size: 0.95rem;
}

.lp-btn-batch-print {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: 1px solid #34d399;
  padding: 8px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  transition: all 0.15s ease;
}

.lp-btn-batch-print:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}

.lp-btn-batch-print:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 批次清單表格與滾動區 */
.lp-batch-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.lp-batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.lp-batch-table th {
  background: #1e293b;
  color: #94a3b8;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.lp-batch-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.lp-batch-table tr:hover {
  background: rgba(56, 139, 253, 0.06);
}

.lp-batch-table tr.selected {
  background: rgba(16, 185, 129, 0.08);
}

.lp-batch-table .row-today {
  border-left: 3px solid #10b981;
}

.lp-drum-badge {
  background: rgba(56, 139, 253, 0.15);
  color: #60a5fa;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.78rem;
  display: inline-block;
}

.lp-status-tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
}

.lp-status-tag.pending {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.lp-status-tag.passed {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.lp-row-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.lp-row-btn:hover {
  background: #2563eb;
  color: white;
  border-color: #388bfd;
}

