/* ═══════════════════════════════════════════════════════
   SUPPLY CHAIN CONFIG PANEL — ChronoForge Pulse
   Matches existing dataset manager UI patterns
   ═══════════════════════════════════════════════════════ */

/* Toggle button in chat settings bar */
.sc-toggle {
  margin-left: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.68rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.sc-toggle:hover,
.sc-toggle.active {
  border-color: var(--accent, #38bdf8);
  color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.06);
}

.sc-toggle .sc-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #64748b);
  transition: background 0.3s;
}

.sc-toggle .sc-status-dot.configured {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

/* Main panel */
.sc-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-bottom 0.2s;
  border-bottom: 0 solid transparent;
  background: var(--bg-card, #111827);
}

.sc-panel.open {
  max-height: 280px;
  border-bottom: 1px solid var(--border, #2a2f3a);
  overflow-y: auto;
}

.sc-panel::-webkit-scrollbar { width: 4px; }
.sc-panel::-webkit-scrollbar-track { background: transparent; }
.sc-panel::-webkit-scrollbar-thumb { background: var(--border, #2a2f3a); border-radius: 4px; }

/* Panel header */
.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg-card, #111827);
  z-index: 2;
}

.sc-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #64748b);
}

.sc-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tabs */
.sc-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border, #2a2f3a);
}

.sc-tab {
  padding: 5px 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted, #64748b);
  font-size: 0.68rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.sc-tab:hover {
  color: var(--text-secondary, #94a3b8);
}

.sc-tab.active {
  color: var(--accent, #38bdf8);
  border-bottom-color: var(--accent, #38bdf8);
}

/* Tab content */
.sc-tab-content {
  display: none;
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
}

.sc-tab-content::-webkit-scrollbar { width: 4px; }
.sc-tab-content::-webkit-scrollbar-track { background: transparent; }
.sc-tab-content::-webkit-scrollbar-thumb { background: var(--border, #2a2f3a); border-radius: 4px; }

.sc-tab-content.active {
  display: block;
}

/* Upload zone */
.sc-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  border: 1.5px dashed var(--border, #2a2f3a);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.sc-upload-zone:hover {
  border-color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.03);
}

.sc-upload-zone.drag-over {
  border-color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.06);
  box-shadow: inset 0 0 20px rgba(56, 189, 248, 0.05);
}

.sc-upload-icon {
  color: var(--text-muted, #64748b);
  transition: color 0.2s;
}

.sc-upload-zone:hover .sc-upload-icon {
  color: var(--accent, #38bdf8);
}

.sc-upload-text {
  font-size: 0.72rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
}

.sc-upload-text strong {
  color: var(--accent, #38bdf8);
}

.sc-upload-hint {
  font-size: 0.62rem;
  color: var(--text-muted, #64748b);
}

/* Config summary cards */
.sc-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.sc-config-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.sc-config-card:hover {
  border-color: var(--border-hover, #3a4050);
}

.sc-config-card .sc-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
}

.sc-card-icon.products { background: rgba(56, 189, 248, 0.1); color: #38bdf8; }
.sc-card-icon.resources { background: rgba(251, 191, 36, 0.1); color: #fbbf24; }
.sc-card-icon.items { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.sc-card-icon.boms { background: rgba(167, 139, 250, 0.1); color: #a78bfa; }
.sc-card-icon.receipts { background: rgba(248, 113, 113, 0.1); color: #f87171; }
.sc-card-icon.settings { background: rgba(148, 163, 184, 0.1); color: #94a3b8; }

.sc-card-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sc-card-count {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  line-height: 1.1;
}

.sc-card-label {
  font-size: 0.6rem;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* Demand table */
.sc-demand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
}

.sc-demand-table th {
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  border-bottom: 1px solid var(--border, #2a2f3a);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.sc-demand-table td {
  padding: 5px 8px;
  color: var(--text-secondary, #94a3b8);
  border-bottom: 1px solid rgba(42, 47, 58, 0.5);
  white-space: nowrap;
}

.sc-demand-table tr:hover td {
  background: rgba(56, 189, 248, 0.03);
}

.sc-demand-table .product-name {
  color: var(--text-primary, #f1f5f9);
  font-weight: 500;
}

.sc-demand-input {
  width: 52px;
  padding: 3px 5px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 4px;
  color: var(--text-primary, #f1f5f9);
  font-size: 0.65rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  text-align: right;
  transition: border-color 0.15s;
}

.sc-demand-input:focus {
  outline: none;
  border-color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.04);
}

.sc-demand-scroll {
  max-height: 140px;
  overflow-x: auto;
  overflow-y: auto;
}

.sc-demand-scroll::-webkit-scrollbar { height: 4px; width: 4px; }
.sc-demand-scroll::-webkit-scrollbar-track { background: transparent; }
.sc-demand-scroll::-webkit-scrollbar-thumb { background: var(--border, #2a2f3a); border-radius: 4px; }

/* Item list (for Items/BOMs detail view) */
.sc-item-list {
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sc-item-list::-webkit-scrollbar { width: 3px; }
.sc-item-list::-webkit-scrollbar-track { background: transparent; }
.sc-item-list::-webkit-scrollbar-thumb { background: var(--border, #2a2f3a); border-radius: 3px; }

.sc-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface, rgba(255,255,255,0.02));
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 6px;
  font-size: 0.66rem;
}

.sc-item-row .sc-item-id {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--accent, #38bdf8);
  font-weight: 600;
  font-size: 0.62rem;
  min-width: 80px;
}

.sc-item-row .sc-item-name {
  color: var(--text-primary, #f1f5f9);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-item-row .sc-item-meta {
  color: var(--text-muted, #64748b);
  font-size: 0.6rem;
  white-space: nowrap;
}

.sc-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sc-type-badge.finished { background: rgba(56, 189, 248, 0.12); color: #38bdf8; }
.sc-type-badge.subassembly { background: rgba(167, 139, 250, 0.12); color: #a78bfa; }
.sc-type-badge.purchased { background: rgba(52, 211, 153, 0.12); color: #34d399; }
.sc-type-badge.raw { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }

/* Buttons */
.sc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.66rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  border: 1px solid transparent;
  white-space: nowrap;
}

.sc-btn.primary {
  background: var(--accent, #38bdf8);
  color: #06080d;
  border-color: var(--accent, #38bdf8);
}

.sc-btn.primary:hover {
  background: var(--accent-bright, #7dd3fc);
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.2);
}

.sc-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.sc-btn.secondary {
  background: var(--surface, rgba(255,255,255,0.03));
  color: var(--text-secondary, #94a3b8);
  border-color: var(--border, #2a2f3a);
}

.sc-btn.secondary:hover {
  border-color: var(--border-hover, #3a4050);
  color: var(--text-primary, #f1f5f9);
}

.sc-btn.danger {
  background: rgba(248, 113, 113, 0.08);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.2);
}

.sc-btn.danger:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: #f87171;
}

/* Run button area */
.sc-run-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border, #2a2f3a);
  background: var(--bg-card, #111827);
  position: sticky;
  bottom: 0;
}

.sc-run-status {
  font-size: 0.64rem;
  color: var(--text-muted, #64748b);
}

.sc-run-status.running {
  color: var(--accent, #38bdf8);
}

.sc-run-status .sc-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent, #38bdf8);
  border-radius: 50%;
  animation: sc-spin 0.6s linear infinite;
  margin-right: 5px;
  vertical-align: middle;
}

@keyframes sc-spin {
  to { transform: rotate(360deg); }
}

/* Results panel */
.sc-results-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.sc-result-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  text-align: center;
}

.sc-result-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.sc-result-label {
  font-size: 0.55rem;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.sc-result-value.cost { color: #fbbf24; }
.sc-result-value.good { color: #34d399; }
.sc-result-value.warn { color: #f87171; }

/* Warnings list */
.sc-warnings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.sc-warning-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(248, 113, 113, 0.05);
  border: 1px solid rgba(248, 113, 113, 0.12);
  border-radius: 6px;
  font-size: 0.64rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.4;
}

.sc-warning-icon {
  color: #f87171;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Empty / placeholder states */
.sc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  color: var(--text-muted, #64748b);
  font-size: 0.68rem;
  text-align: center;
  line-height: 1.5;
}

.sc-empty svg {
  opacity: 0.3;
}

/* Section headers inside tabs */
.sc-section-title {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #64748b);
  margin: 12px 0 6px;
}

.sc-section-title:first-child {
  margin-top: 0;
}

/* File loaded indicator */
.sc-file-loaded {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(52, 211, 153, 0.06);
  border: 1px solid rgba(52, 211, 153, 0.15);
  border-radius: 8px;
  margin-bottom: 12px;
}

.sc-file-loaded-icon {
  color: #34d399;
}

.sc-file-loaded-info {
  flex: 1;
  min-width: 0;
}

.sc-file-loaded-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-primary, #f1f5f9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc-file-loaded-meta {
  font-size: 0.6rem;
  color: var(--text-muted, #64748b);
}

/* Light theme overrides */
[data-theme="light"] .sc-panel { background: #fff; }
[data-theme="light"] .sc-header { background: #fff; }
[data-theme="light"] .sc-run-bar { background: #fff; }
[data-theme="light"] .sc-btn.primary { color: #fff; }
[data-theme="light"] .sc-demand-input { background: #f8fafc; color: #1e293b; }
