/* ─────────────────────────────────────────────────────────────────────────
   components.css — Buttons, badges, cards, modals, KPI, alerts
   ───────────────────────────────────────────────────────────────────────── */

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.btn-primary   { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn-success   { background: var(--color-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #219a52; }

.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #c0392b; }

.btn-warning   { background: var(--color-warning); color: #333; }
.btn-warning:hover:not(:disabled)  { background: #e0a800; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: #555;
}
.btn-outline:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--color-muted);
}
.btn-ghost:hover { color: var(--color-text); background: rgba(0,0,0,.05); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* Status badges */
.badge-unopened  { background: #d4edda; color: #155724; }
.badge-in_use    { background: #cce5ff; color: #004085; }
.badge-depleted  { background: #e2e3e5; color: #383d41; }
.badge-disposed  { background: #f8d7da; color: #721c24; }
.badge-quarantined { background: #fff3cd; color: #856404; }
.badge-damaged   { background: #f8d7da; color: #721c24; }
.badge-expired   { background: #f8d7da; color: #721c24; }
.badge-adjusted  { background: #e2e3e5; color: #383d41; }

/* Purchase request status */
.badge-requested  { background: #e2e3e5; color: #383d41; }
.badge-po_requested { background: #e2e3e5; color: #383d41; }
.badge-quoting    { background: #fff3cd; color: #856404; }
.badge-approved   { background: #d4edda; color: #155724; }
.badge-ordered    { background: #cce5ff; color: #004085; }
.badge-expected   { background: #e8d5f5; color: #5b2182; }
.badge-received   { background: #d4edda; color: #155724; }
.badge-cancelled  { background: #f8d7da; color: #721c24; }
.badge-delayed    { background: #fff3cd; color: #856404; }

/* COA */
.badge-issued     { background: #d4edda; color: #155724; }
.badge-not_issued { background: #e2e3e5; color: #383d41; }

/* Generic */
.badge-primary { background: #cce5ff; color: #004085; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-neutral { background: #e2e3e5; color: #383d41; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}

.card-sm { padding: 14px 18px; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.kpi-icon.blue   { background: #e8f2fd; }
.kpi-icon.green  { background: #e8f7ee; }
.kpi-icon.orange { background: #fff4e5; }
.kpi-icon.red    { background: #fde8e8; }
.kpi-icon.purple { background: #f0e8fd; }

.kpi-body { flex: 1; min-width: 0; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--color-text); }
.kpi-label { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.kpi-change { font-size: 11px; margin-top: 4px; }
.kpi-change.up   { color: var(--color-success); }
.kpi-change.down { color: var(--color-danger); }

/* ── Alert strip ────────────────────────────────────────────────────────── */
.alert-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}
.alert .alert-icon { font-size: 16px; flex-shrink: 0; }
.alert-text { flex: 1; }
.alert-danger  { background: #fde8e8; color: #7b1d1d; border-left: 4px solid var(--color-danger); }
.alert-warning { background: #fff8e1; color: #7a5c00; border-left: 4px solid var(--color-warning); }
.alert-info    { background: #e8f2fd; color: #1a4a7a; border-left: 4px solid var(--color-primary); }

/* ── Progress bar chart (CSS only) ─────────────────────────────────────── */
.status-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.status-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.status-bar-label {
  width: 90px;
  color: var(--color-muted);
  text-align: right;
  flex-shrink: 0;
}

.status-bar-track {
  flex: 1;
  height: 10px;
  background: #f0f2f7;
  border-radius: 5px;
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .4s ease;
}
.fill-requested { background: #adb5bd; }
.fill-quoting   { background: var(--color-warning); }
.fill-ordered   { background: var(--color-primary); }
.fill-expected  { background: #9b59b6; }
.fill-received  { background: var(--color-success); }
.fill-cancelled { background: var(--color-danger); }

.status-bar-count {
  width: 28px;
  text-align: right;
  color: var(--color-text);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 0;
  overflow-x: auto;
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}
.tab:hover { color: var(--color-primary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal h3 { margin-bottom: 16px; font-size: 16px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* ── Import stepper ─────────────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0e4ed;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.step.active .step-num { background: var(--color-primary); color: #fff; }
.step.done .step-num   { background: var(--color-success); color: #fff; }

.step-label {
  font-size: 13px;
  font-weight: 500;
  color: #aaa;
}
.step.active .step-label { color: var(--color-primary); }
.step.done .step-label   { color: var(--color-success); }

.step-connector {
  flex: 1;
  height: 2px;
  background: #e0e4ed;
  margin: 0 8px;
}
.step-connector.done { background: var(--color-success); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  border-left: 4px solid var(--color-primary);
  animation: toast-in .2s ease;
  position: relative;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.info    { border-left-color: var(--color-primary); }

.toast.out { animation: toast-out .2s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

.toast-icon  { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body  { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast-msg   { font-size: 12px; color: var(--color-muted); line-height: 1.4; }

.toast-close {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
}
.toast-close:hover { background: #f0f0f0; color: var(--color-text); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: #666; }
.empty-state .empty-sub { font-size: 13px; }
