// js/components/widgets/freight-badges.jsx
// [Wave 13 v223.38 20260520] Extraído de AprovacoesFrete.jsx L35-62
// Badges visuais — FreightTypeBadge (tipo request) + FreightStatusBadge (status request)
// Reusado em AprovacaoFreteList + DenyCloseRequestModal
(function(){
  'use strict';

  function FreightTypeBadge(props) {
    const { type } = props;
    const map = {
      close_with_loss: { bg: '#FEE2E2', fg: '#DC2626', label: '❌ Fechar com perda' },
      sku_surprise:    { bg: '#EFF6FF', fg: '#2563EB', label: '🆕 SKU surpresa' },
      qty_extra:       { bg: '#FEF3C7', fg: '#92400E', label: '⚠️ Qty extra' },
    };
    const c = map[type] || { bg: '#F3F4F6', fg: '#374151', label: type };
    return (
      <span style={{ background: c.bg, color: c.fg, padding: '3px 10px', borderRadius: 6, fontSize: 11, fontWeight: 700 }}>
        {c.label}
      </span>
    );
  }

  function FreightStatusBadge(props) {
    const { status } = props;
    const map = {
      pending:               { bg: '#FEF9E7', fg: '#B89840', label: '⏳ Pendente' },
      approved:              { bg: '#DCFCE7', fg: '#16A34A', label: '✓ Aprovado' },
      denied:                { bg: '#F3F4F6', fg: '#6B7280', label: '✗ Negado' },
      more_info_requested:   { bg: '#EFF6FF', fg: '#2563EB', label: '? Info' },
    };
    const c = map[status] || { bg: '#F3F4F6', fg: '#374151', label: status };
    return (
      <span style={{ background: c.bg, color: c.fg, padding: '3px 10px', borderRadius: 6, fontSize: 11, fontWeight: 700 }}>
        {c.label}
      </span>
    );
  }

  // Namespace
  window.ZNX = window.ZNX || {};
  window.ZNX.components = window.ZNX.components || {};
  window.ZNX.components.FreightTypeBadge = FreightTypeBadge;
  window.ZNX.components.FreightStatusBadge = FreightStatusBadge;
  window.FreightTypeBadge = FreightTypeBadge;
  window.FreightStatusBadge = FreightStatusBadge;
})();
