/* ═══════════════════════════════════════════════
   Smart PO Allocation — Feature CSS
   Uses design system tokens from application.css
   ═══════════════════════════════════════════════ */

/* ── Step Indicator ── */
.sa-steps {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}
.sa-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--border);
  color: var(--light);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.sa-step--active {
  background: var(--ink);
  color: #fff;
}
.sa-step--done {
  background: #d4edda;
  color: #155724;
  cursor: pointer;
}
.sa-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,0.2);
}
.sa-step--active .sa-step-num { background: rgba(255,255,255,0.25); }
.sa-step--done .sa-step-num { background: rgba(21,87,36,0.15); }

/* ── Config Grid ── */
.sa-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ── Budget ── */
.sa-budget-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sa-budget-prefix {
  font-size: 18px;
  font-weight: 600;
  color: var(--stone);
}
.sa-slider {
  width: 100%;
  margin: 8px 0;
  accent-color: var(--accent);
}
.sa-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--light);
}

/* ── Subtitle List ── */
.sa-subtitle-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sa-subtitle-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}
.sa-subtitle-item:hover { background: var(--bg); }
.sa-subtitle-item--active {
  background: #fef3f0;
  border-left: 3px solid var(--accent);
}
.sa-subtitle-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.sa-subtitle-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.sa-fc-badge {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.sa-empty-state {
  padding: 24px;
  text-align: center;
  color: var(--light);
  font-size: 14px;
}

/* ── Subtitle Detail ── */
.sa-subtitle-detail { margin-top: 16px; }
.sa-baseline-detail h4 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ── Weight Mode Selector ── */
.sa-weight-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sa-weight-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.sa-weight-options {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sa-weight-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sa-weight-btn:last-child { border-right: none; }
.sa-weight-btn:hover { background: var(--border-light, #eee); }
.sa-weight-btn--active {
  background: var(--ink);
  color: #fff;
}
.sa-weight-btn--active:hover { background: var(--ink); }

/* ── Mix Bar ── */
.sa-mix-bar {
  display: flex;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}
.sa-mix-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  min-width: 2px;
  transition: width 0.3s;
}

/* ── Type Rows ── */
.sa-type-rows { display: flex; flex-direction: column; gap: 4px; }
.sa-type-row { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.sa-type-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.sa-type-header:hover { background: var(--bg); }
.sa-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
}
.sa-type-name { font-weight: 600; font-size: 14px; flex: 1; }
.sa-type-stat { font-size: 12px; color: var(--muted); }
.sa-type-expand { font-size: 10px; color: var(--light); }

/* ── Forecast Badges ── */
.sa-fc-confidence {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.sa-fc-confidence--high { background: #d4edda; color: #155724; }
.sa-fc-confidence--normal { background: #fff3cd; color: #856404; }
.sa-fc-confidence--low { background: #f8d7da; color: #721c24; }
.sa-fc-accuracy { font-size: 11px; color: var(--muted); }

/* ── Size Curve ── */
.sa-size-curve { padding: 0 14px 14px; }
.sa-size-table { margin: 0; }
.sa-curve-bar-container {
  width: 100%;
  height: 16px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.sa-curve-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.3s;
}

/* ── Product Types Card ── */
.sa-product-types-card { margin-bottom: 20px; }
.sa-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
.sa-type-qty { width: 60px !important; }

/* ── Actions ── */
.sa-actions {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

/* ── Baseline Label ── */
.sa-baseline-label {
  font-size: 14px;
  color: var(--light);
  margin-bottom: 12px;
}
.sa-baseline-label strong {
  color: var(--ink);
}

/* ── KPI Strip override for smart allocation (5 equal cols, centered text) ── */
.sa-kpi-strip {
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* ── Warnings ── */
.sa-warnings { margin-bottom: 16px; }
.sa-warning {
  background: #fff3cd;
  color: #856404;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 4px;
}

/* ── Tab Bar ── */
.sa-tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.sa-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.sa-tab:hover { color: var(--ink); }
.sa-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.sa-back-btn { margin-left: auto; }

/* ── Allocate Actions ── */
.sa-allocate-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* ── Product Card ── */
.sa-product-card { margin-bottom: 12px; }
.sa-product-card--locked {
  border-color: var(--amber);
  background: #fffdf5;
}
.sa-product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.sa-product-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sa-product-name {
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  width: 250px;
}
.sa-product-name:focus {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}
.sa-lock-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}
.sa-product-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--stone);
}
.sa-expand-icon { font-size: 10px; color: var(--light); }

/* ── Scale Row ── */
.sa-scale-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 0;
}
.sa-scale-row label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.sa-scale-input {
  width: 80px;
  text-align: center;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
}

/* ── Qty Input ── */
.sa-qty-input {
  width: 70px;
  text-align: center;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 4px;
  font-size: 13px;
}
.sa-qty-input:focus { border-color: var(--accent); outline: none; }
.sa-qty-modified { border-color: var(--amber) !important; background: #fffdf5; }

/* ── Review ── */
.sa-review-details { margin-bottom: 20px; }
.sa-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.sa-review-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

/* ── Budget Breakdown ── */
.sa-budget-breakdown { margin-bottom: 20px; }
.sa-breakdown-row {
  display: grid;
  grid-template-columns: 200px 100px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.sa-breakdown-name { font-size: 13px; font-weight: 600; }
.sa-breakdown-cost { font-size: 13px; text-align: right; }
.sa-breakdown-bar {
  height: 16px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.sa-breakdown-bar > div {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* ── Export ── */
.sa-export-actions {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}

/* ── Page header ── */
.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Usage Guide Button ── */
.sa-guide-btn {
  font-size: 11px;
  padding: 4px 12px;
  vertical-align: middle;
  margin-left: 8px;
}

/* ── Usage Guide Modal ── */
.sa-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sa-modal {
  background: var(--surface, #fff);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.sa-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border, #e8e6e1);
  flex-shrink: 0;
}
.sa-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.sa-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted, #8a8a8a);
  padding: 0 4px;
  line-height: 1;
}
.sa-modal-close:hover { color: var(--ink, #2d2d2d); }
.sa-modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.7;
}
.sa-modal-body .sa-guide-intro {
  font-size: 14px;
  color: var(--stone, #555);
  margin: 0 0 20px;
  line-height: 1.7;
}
.sa-modal-body h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light, #f0eeea);
}
.sa-modal-body h3:first-of-type { margin-top: 0; }
.sa-modal-body h4 {
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 4px;
  color: var(--stone, #555);
}
.sa-modal-body ul, .sa-modal-body ol {
  margin: 0 0 10px;
  padding-left: 20px;
}
.sa-modal-body li { margin-bottom: 4px; }
.sa-guide-section {
  padding-left: 4px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sa-config-grid { grid-template-columns: 1fr; }
  .sa-kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .sa-breakdown-row { grid-template-columns: 1fr 80px; }
  .sa-breakdown-bar { display: none; }
  .sa-modal { max-width: 100%; max-height: 90vh; }
  .sa-modal-overlay { padding: 12px; }
}
