/* ======================================
   SellSync - Inventory-specific Styles
   ====================================== */

/* ─── Dashboard Layout ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.dashboard-grid .chart-card {
  grid-column: span 2;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-fast);
}
.chart-card:hover {
  border-color: var(--border-default);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── Mini Bar Chart ─── */
.mini-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 80px;
}

.mini-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: var(--primary-alpha);
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}
.mini-bar:hover {
  background: var(--primary);
  opacity: 0.8;
}
.mini-bar.highlight { background: var(--primary); }

/* ─── Stock Level Indicator ─── */
.stock-level-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stock-level-row:last-child { border-bottom: none; }

.stock-level-name {
  font-size: 12.5px;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 100px;
}

.stock-level-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.stock-level-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(.25,.1,.25,1);
}

.stock-level-pct {
  font-size: 12px;
  font-weight: 700;
  min-width: 38px;
  text-align: right;
}

/* ─── Activity Feed ─── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  animation: fadeInUp 0.3s ease;
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.4;
}

.activity-text strong {
  font-weight: 700;
  color: var(--text-primary);
}

.activity-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ─── Product Table ─── */
.product-img-cell {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}

.product-img-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.product-sku {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'Courier New', monospace;
}

/* ─── Product list: wider name column, hidden SKU / market ID ─── */
.product-col-product {
  min-width: 220px;
  width: 30%;
  max-width: 420px;
}

.product-list-primary-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.product-name-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.product-name-row .product-name {
  flex: 1;
  min-width: 0;
}

.product-list-meta-wrap {
  position: relative;
  flex-shrink: 0;
  margin-top: 1px;
}

.product-list-meta-trigger {
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--text-tertiary);
}

.product-list-meta-trigger:hover,
.product-list-meta-trigger:focus-visible {
  color: var(--primary-light);
}

.product-list-meta-popover {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 120;
  min-width: 210px;
  max-width: min(340px, 88vw);
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.product-list-meta-popover.is-open {
  display: block;
}

@media (hover: hover) and (pointer: fine) {
  .product-list-meta-wrap:hover .product-list-meta-popover,
  .product-list-meta-wrap:focus-within .product-list-meta-popover {
    display: block;
  }
}

.product-list-meta-row + .product-list-meta-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.product-list-meta-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}

.product-list-meta-value {
  display: block;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: var(--text-secondary);
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.4;
}

/* ─── Stock Current Page ─── */
.stock-summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: var(--spacing-md);
}

.stock-summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  transition: all var(--transition-fast);
}
.stock-summary-item:hover {
  border-color: var(--border-default);
  background: var(--bg-card-hover);
}

.stock-summary-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stock-summary-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ─── Low Stock Alert Card ─── */
.alert-card {
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.alert-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--danger-light);
  border-bottom: 1px solid rgba(239, 68, 68, 0.15);
}

.alert-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--danger);
}

/* ─── Inbound Form Panel ─── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-body {
  padding: 20px;
}

/* ─── Inbound Step Indicator ─── */
.step-indicator {
  display: flex;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.step {
  display: flex;
  align-items: center;
  flex: 1;
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.step.done .step-circle {
  background: var(--success);
  color: #fff;
}

.step.current .step-circle {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.5);
}

.step.future .step-circle {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
}

.step-label {
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
}

.step.current .step-label { color: var(--primary-light); }
.step.done .step-label { color: var(--success); }
.step.future .step-label { color: var(--text-tertiary); }

.step-line {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
  margin: 0 8px;
}

/* ─── Quantity Control ─── */
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1;
}
.qty-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.qty-input {
  width: 60px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}
.qty-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-alpha);
}

/* ─── Donut Chart ─── */
.donut-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-center {
  position: absolute;
  text-align: center;
}

.donut-center-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.donut-center-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Legend ─── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-item-label { flex: 1; }
.legend-item-value { font-weight: 700; color: var(--text-primary); }

/* ─── 대시보드: 주간 재고 변동 막대 ─── */
.dash-week-card { display: flex; flex-direction: column; }
.dash-week-bars {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 260px;
  padding: 4px 4px 0;
}
.dash-week-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dash-week-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid var(--border-subtle);
  background-image: linear-gradient(to top, var(--border-subtle) 1px, transparent 1px);
  background-size: 100% 25%;
}
.dash-week-track .mini-bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
}
.dash-week-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.dash-week-val.has { color: var(--text-primary); }
.dash-week-label { font-size: 11px; color: var(--text-tertiary); }
/* 입고 = 보라(기본 primary), 출고 = 주황 — 탭을 바꿨을 때 한눈에 구분 */
.dash-week-bars { --dash-week-bar: var(--primary); --dash-week-bar-soft: var(--primary-alpha); }
.dash-week-bars.mode-out { --dash-week-bar: #F59E0B; --dash-week-bar-soft: rgba(245, 158, 11, 0.28); }
.dash-week-track .mini-bar { background: var(--dash-week-bar-soft); }
.dash-week-track .mini-bar.highlight,
.dash-week-track .mini-bar:hover { background: var(--dash-week-bar); opacity: 1; }
.dash-week-bars.mode-out .dash-week-label.today { color: #F59E0B; }
.dash-week-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.dash-week-key.in { background: var(--primary); }
.dash-week-key.out { background: #F59E0B; }
.dash-week-label.today { color: var(--primary-light, var(--primary)); font-weight: 700; }

/* ─── 대시보드: 카테고리별 재고 (도넛 위 · 목록 2~3열 아래) ─── */
.dash-cat {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
}
.dash-cat-donut { align-self: center; }
.dash-cat-donut .donut-center-value { font-size: 28px; }
.dash-cat-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 18px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.dash-cat-legend .legend-item { min-width: 0; padding: 4px 0; border-bottom: 1px dashed var(--border-subtle); }
.dash-cat-legend .legend-item-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-cat-legend .legend-item-value { white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-cat-legend .legend-item-value small { margin-left: 6px; font-size: 11px; font-weight: 500; color: var(--text-tertiary); }
.dash-cat-legend .legend-item.empty { opacity: 0.5; }
.dash-cat-legend .legend-item.empty .legend-item-value { font-weight: 500; color: var(--text-tertiary); }
