/* ============================================================
   Warehouse workspace styles
   Magnolia DS v1.0 — CHANNEL palette (Bloomberg Light)
   Trader terminal trên giấy · navy + cyan + amber · JetBrains Mono cho KPI/title
   ============================================================ */

#workspace-warehouse {
  display: none;
  padding: 24px 32px;
  max-width: none;
  margin: 0;
  background: var(--bg-card, #ffffff);

  /* DS tokens (--p-* per spec) */
  --p-page: #ffffff;
  --p-card: #ffffff;
  --p-border: #e3e8ee;
  --p-text: #0a2540;
  --p-muted: #697386;
  --p-primary: #0a2540;          /* Bloomberg navy */
  --p-primary-light: #425466;
  --p-secondary: #0891b2;        /* Deep cyan */
  --p-secondary-light: #22d3ee;
  --p-warm: #d97706;             /* Amber */
  --p-warm-light: #ffaa00;       /* Signature Bloomberg amber */
  --p-neutral: #cfd7df;

  /* Legacy aliases */
  --bg: #ffffff;
  --bg-soft: #f6f9fb;
  --bg-card: #ffffff;
  --bg-hover: #f6f9fb;
  --text: #0a2540;
  --text-muted: #697386;
  --text-soft: #94a4b6;
  --accent: #0a2540;
  --accent-2: #0891b2;
  --accent-soft: #e0f2fe;
  --border: #e3e8ee;
  --border-soft: #f1f5f9;
}
#workspace-warehouse.active { display: block; }

/* JetBrains Mono cho KPI/title/labels per Channel domain spec */
#workspace-warehouse .wh-kpi-value,
#workspace-warehouse .wh-kpi-label,
#workspace-warehouse .wh-card-title,
#workspace-warehouse .wh-tab-btn,
#workspace-warehouse code,
#workspace-warehouse .num {
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
  letter-spacing: 0;
}

/* Header --------------------------------------------------- */
.wh-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.wh-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wh-header .wh-sync-badge {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.wh-header .wh-sync-badge.alert {
  background: #fee2e2;
  color: var(--danger);
  font-weight: 600;
}

/* Tabs ----------------------------------------------------- */
.wh-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wh-tab-btn {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.wh-tab-btn:hover { color: var(--text); }
.wh-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.wh-tab-content { display: none; }
.wh-tab-content.active { display: block; }

/* KPI grid ------------------------------------------------- */
.wh-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.wh-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s;
}
.wh-kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.wh-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.wh-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  line-height: 1.1;
}
.wh-kpi-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 4px;
}
.wh-kpi-card.accent .wh-kpi-value { color: var(--accent); }
.wh-kpi-card.teal   .wh-kpi-value { color: var(--cs); }
.wh-kpi-card.orange .wh-kpi-value { color: var(--ca); }
.wh-kpi-card.indigo .wh-kpi-value { color: var(--total); }

/* Section card --------------------------------------------- */
.wh-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.wh-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.wh-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.wh-card-actions { display: flex; gap: 8px; }

/* Tables --------------------------------------------------- */
.wh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wh-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.wh-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.wh-table tr:hover td { background: var(--bg-hover); }
.wh-table .num {
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  text-align: right;
  white-space: nowrap;
}
.wh-table .num.zero { color: var(--text-soft); }
.wh-table .num.neg { color: var(--danger); }

/* Chart container ------------------------------------------ */
.wh-chart-wrap {
  position: relative;
  height: 280px;
}

/* Buttons -------------------------------------------------- */
.wh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.wh-btn:hover {
  background: var(--bg-soft);
  border-color: var(--text-muted);
}
.wh-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.wh-btn.primary:hover { background: #d97706; }
.wh-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Placeholder for non-Phase 1 tabs ------------------------- */
.wh-placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.wh-placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .5;
}
.wh-placeholder h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}
.wh-placeholder p { font-size: 14px; margin: 0; }
.wh-placeholder .wh-placeholder-eta {
  display: inline-block;
  margin-top: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
}

/* Empty state for tables/charts ---------------------------- */
.wh-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
  font-size: 13px;
}
.wh-empty-hint {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  background: var(--bg-soft);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Loading shimmer ------------------------------------------ */
.wh-loading {
  color: var(--text-soft);
  font-style: italic;
  padding: 12px;
}

/* Error box ------------------------------------------------ */
.wh-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.wh-error code {
  background: var(--bg-card, #fff);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* Status pill --------------------------------------------- */
.wh-status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: 8px;
  vertical-align: middle;
}

/* Modal --------------------------------------------------- */
.wh-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  overflow-y: auto;
}
.wh-modal[hidden] { display: none; }
.wh-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.wh-modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  z-index: 1;
}
.wh-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wh-modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.wh-modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.wh-modal-close:hover { background: var(--bg-soft); color: var(--text); }
.wh-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.wh-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Forms --------------------------------------------------- */
.wh-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 160px;
  gap: 14px;
  margin-bottom: 14px;
}
.wh-form-field {
  display: flex;
  flex-direction: column;
}
.wh-form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.wh-form-field input,
.wh-form-field select,
.wh-form-field textarea {
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card, #fff);
  color: var(--text);
  font-family: inherit;
}
.wh-form-field input:focus,
.wh-form-field select:focus,
.wh-form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}
.wh-form-divider {
  margin: 20px 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 6px;
}
.num-input {
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: right;
  width: 100%;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}
.num-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Detail grid --------------------------------------------- */
.wh-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border-radius: 8px;
  margin-bottom: 12px;
}
.wh-detail-grid > div { display: flex; flex-direction: column; }
.wh-detail-grid label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 3px;
}
.wh-detail-grid strong { font-size: 14px; color: var(--text); }
.wh-detail-notes {
  padding: 10px 14px;
  background: #fffbeb;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
}
.wh-detail-notes label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

/* Remove button (item row) -------------------------------- */
.wh-tv-rm {
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}
.wh-tv-rm:hover { background: #fee2e2; color: var(--danger); }

/* Product picker ------------------------------------------ */
.wh-pp { position: relative; }
.wh-pp-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-card, #fff);
  font-family: inherit;
}
.wh-pp-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .12);
}
.wh-pp-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .1);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
}
.wh-pp-item {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.wh-pp-item:last-child { border-bottom: none; }
.wh-pp-item:hover, .wh-pp-item.active { background: var(--bg-soft); }
.wh-pp-sku {
  font-weight: 600;
  font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--accent);
}
.wh-pp-name { color: var(--text); }
.wh-pp-fmt { color: var(--text-muted); font-size: 11px; text-align: right; }
.wh-pp-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

/* Toast --------------------------------------------------- */
.wh-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #15803d;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .2);
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  transform: translateY(40px);
  opacity: 0;
  transition: transform .25s, opacity .25s;
}
.wh-toast.show { transform: translateY(0); opacity: 1; }

/* Mobile --------------------------------------------------- */
@media (max-width: 900px) {
  #workspace-warehouse { padding: 16px; }
  .wh-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .wh-kpi-value { font-size: 22px; }
  .wh-header h1 { font-size: 20px; }
  .wh-table { font-size: 12px; }
  .wh-table th, .wh-table td { padding: 8px; }
  .wh-form-row { grid-template-columns: 1fr; gap: 10px; }
  .wh-modal { padding: 20px 10px; }
  .wh-modal-content { max-height: calc(100vh - 40px); }
  .wh-modal-body, .wh-modal-header, .wh-modal-footer { padding-left: 14px; padding-right: 14px; }
  .wh-pp-item { grid-template-columns: 90px 1fr; }
  .wh-pp-fmt { display: none; }
}
@media (max-width: 500px) {
  .wh-kpi-grid { grid-template-columns: 1fr; }
}

/* ── Tồn kho — card chọn kho + popup ─────────────────── */
.wh-inv-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 14px;
}
.wh-inv-card {
  text-align: left;
  background: var(--bg-card, #fff);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  font: inherit;
}
.wh-inv-card:hover:not(.empty) {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.wh-inv-card.empty { opacity: .55; cursor: default; }
.wh-inv-card-name { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.wh-inv-card-value { font-size: 20px; font-weight: 700; color: var(--accent); }
.wh-inv-card-value small { font-size: 12px; color: #94a3b8; font-weight: 500; }
.wh-inv-card-meta { font-size: 12px; color: #64748b; margin-top: 8px; line-height: 1.5; }
.wh-inv-card-hint { font-size: 11.5px; color: #94a3b8; margin-top: 10px; }
.wh-inv-card:hover:not(.empty) .wh-inv-card-hint { color: var(--accent); }
.wh-inv-modal-content { max-width: 1100px; width: 96vw; }

.wh-inv-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.wh-inv-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.wh-inv-group-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}
.wh-inv-group-sub {
  font-size: 12.5px;
  color: #64748b;
  white-space: nowrap;
}
.wh-inv-group .wh-table { margin: 0; }
.wh-inv-subtotal td {
  font-weight: 700;
  background: #f8fafc;
  border-top: 2px solid #e5e7eb;
}
.wh-inv-fmt-banner td {
  background: #eef2ff;
  font-weight: 600;
  font-size: 12.5px;
  color: #4338ca;
  padding-top: 6px;
  padding-bottom: 6px;
}
.wh-inv-fmt-banner small { color: #6366f1; font-weight: 500; }
.wh-inv-empty {
  text-align: center;
  color: #94a3b8;
  font-style: italic;
  padding: 18px 0;
}
