/* ============================================================
   NMP-ERP — COMPONENTES VISUAIS
   ============================================================
   ⚠️  ESTE ARQUIVO CONTÉM TODOS OS COMPONENTES VISUAIS DO SISTEMA.
   
   REGRA INVIOLÁVEL:
   - NUNCA criar classes CSS de componente fora deste arquivo
   - Se precisa de variação nova, ABRIR PR específica pra design system
   - É PROIBIDO sobrescrever propriedades das classes abaixo em tela
   - Dev USA as classes — não escreve CSS novo de componente
   
   USO:
   - Importar APÓS tokens.css
   - Adicionar classes no HTML: <button class="btn btn-primary">...
   
   PRD MASTER: PRD-MASTER-NMP-ERP.md seção 5
   Última atualização: 21/05/2026
   ============================================================ */


/* ============================================================
   1. BOTÕES (.btn, .btn-primary, .btn-secondary, etc.)
   ============================================================ */

.btn {
  height: var(--touch-min);
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  transition: all var(--transition-normal);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--teal-500);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) {
  background: var(--teal-600);
}
.btn-primary:active:not(:disabled) {
  background: var(--teal-700);
}

.btn-secondary {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--gray-900);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
}

.btn-tertiary {
  background: transparent;
  color: var(--teal-700);
}
.btn-tertiary:hover:not(:disabled) {
  background: var(--teal-50);
}

.btn-destructive {
  background: var(--error);
  color: var(--white);
}
.btn-destructive:hover:not(:disabled) {
  background: var(--error-text);
}

.btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border-radius: var(--r-md);
}

/* Variante: botão compacto "+ Novo" da barra de ação */
.btn-new {
  height: 36px;
  padding: 0 var(--s-3);
  font-size: var(--text-sm);
}


/* ============================================================
   2. INPUTS (.input, .input-search)
   ============================================================ */

.input {
  width: 100%;
  height: var(--touch-min);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-family: inherit;
  font-size: var(--text-md);
  color: var(--gray-900);
  transition: all var(--transition-fast);
}

.input::placeholder {
  color: var(--gray-500);
}

.input:focus {
  outline: none;
  border: 2px solid var(--teal-500);
  box-shadow: 0 0 0 4px var(--teal-100);
}

.input.is-error {
  border-color: var(--error);
}

.input-search {
  background: var(--gray-50);
  padding-left: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.input-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--gray-700);
  margin-bottom: 6px;
}

.input-label.is-required::after {
  content: ' *';
  color: var(--error);
}

.input-error-msg {
  font-size: var(--text-sm);
  color: var(--error);
  margin-top: 4px;
}


/* ============================================================
   3. CARDS (.card, .card-dense, .card-row, .catalog-row)
   ============================================================ */

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
}

.card-dense {
  padding: var(--s-3);
  margin-bottom: var(--s-2);
}

.card.is-clickable {
  cursor: pointer;
  transition: all var(--transition-fast);
}
.card.is-clickable:hover {
  border-color: var(--teal-500);
  box-shadow: var(--shadow-sm);
}

/* Border-left colorido por status (NÃO usar ícone gigante) */
.card.has-status-success { border-left: 4px solid var(--success); }
.card.has-status-warning { border-left: 4px solid var(--warning); }
.card.has-status-error   { border-left: 4px solid var(--error); }
.card.has-status-info    { border-left: 4px solid var(--info); }
.card.has-status-accent  { border-left: 4px solid var(--orange-500); }

/* Card-row: linha em bloco único (para catálogos enxutos) */
.catalog-block {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.catalog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch-min);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.catalog-row:last-child {
  border-bottom: none;
}
.catalog-row:hover {
  background: var(--gray-50);
}


/* ============================================================
   4. BADGES (.badge, .badge-success, etc.)
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 var(--s-2);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-error   { background: var(--error-bg);   color: var(--error-text); }
.badge-info    { background: var(--info-bg);    color: var(--info-text); }
.badge-neutral { background: var(--gray-100);   color: var(--gray-700); }
.badge-accent  { background: var(--orange-100); color: var(--orange-500); }

/* Badge sem bolinha (uppercase only) */
.badge-flat::before {
  display: none;
}


/* ============================================================
   5. CHIPS DE FILTRO (.chip, .chip-active)
   ============================================================ */

.chip-group {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding: var(--s-3) var(--s-4);
  background: var(--gray-50);
  scrollbar-width: none;
}
.chip-group::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .chip-group {
    flex-wrap: wrap;
    overflow-x: visible;
  }
}

.chip {
  height: 36px;
  padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--gray-200);
  background: var(--white);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip:hover {
  border-color: var(--teal-500);
}

.chip.is-active {
  background: var(--teal-500);
  color: var(--white);
  border-color: var(--teal-500);
}

.chip .chip-count {
  font-weight: var(--weight-bold);
  opacity: 0.85;
}


/* ============================================================
   5b. CHIP GRID (.chip-grid) — Grid de chips selecionáveis
   ============================================================
   Pra formulários onde o usuário escolhe 1 opção entre 2-6.
   Diferente de .chip-group (horizontal scroll), aqui as opções
   são fixas e visíveis simultaneamente em grid.
   ============================================================ */

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-2);
}

@media (min-width: 768px) {
  .chip-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Chip dentro do grid ocupa largura total da célula */
.chip-grid .chip {
  width: 100%;
  justify-content: center;
}

/* Variante: erro de validação no grid */
.chip-grid.is-error .chip {
  border-color: var(--error);
}

.chip-grid-error-msg {
  font-size: var(--text-sm);
  color: var(--error);
  margin-top: var(--s-1);
}


/* ============================================================
   6. AVATARS (.avatar, .avatar-sm/md/lg/xl)
   ============================================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--teal-700);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }

.avatar.is-pj {
  background: var(--orange-100);
  color: var(--orange-500);
}

.avatar.is-guest {
  background: var(--gray-100);
  color: var(--gray-500);
}


/* ============================================================
   7. FAB (.fab)
   ============================================================ */

.fab {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-4);
  height: 56px;
  padding: 0 var(--s-6);
  border-radius: var(--r-pill);
  background: var(--teal-500);
  color: var(--white);
  border: none;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  z-index: var(--z-fab);
  transition: all var(--transition-normal);
}

.fab:hover {
  background: var(--teal-600);
  transform: translateY(-2px);
}

.fab .fab-icon {
  font-size: 22px;
  font-weight: var(--weight-regular);
  line-height: 1;
}

/* FAB círculo (sem texto) */
.fab.fab-round {
  width: 56px;
  padding: 0;
  justify-content: center;
}


/* ============================================================
   8. HEADERS E BARRA DE AÇÃO (.page-header, .action-bar)
   ============================================================ */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.page-header-back,
.page-header-action {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.page-header-action-primary {
  background: var(--teal-500);
  color: var(--white);
}

.page-header-action-ghost {
  background: transparent;
  color: var(--gray-500);
}

.page-header-title {
  flex: 1;
  text-align: center;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--gray-900);
  margin: 0;
}

.page-header-counter {
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--gray-500);
  margin-left: 4px;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.action-bar .input-search {
  flex: 1;
}


/* ============================================================
   9. DRAWER (.drawer, .drawer-backdrop, .drawer-header, .drawer-body, .drawer-footer)
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: var(--z-drawer-backdrop);
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.drawer-backdrop.is-open {
  opacity: 1;
}

.drawer {
  position: fixed;
  background: var(--white);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

/* Mobile: bottom-sheet */
@media (max-width: 767px) {
  .drawer {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85%;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
    transition: transform var(--transition-slow);
  }
  .drawer.is-open {
    transform: translateY(0);
  }

  .drawer.drawer-list {
    max-height: 75%;
  }

  .drawer::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: var(--s-2) auto 0;
    flex-shrink: 0;
  }
}

/* Desktop: lateral direita */
@media (min-width: 768px) {
  .drawer {
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
  }
  .drawer.is-open {
    transform: translateX(0);
  }

  .drawer.drawer-wide {
    width: 640px;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.drawer-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--gray-900);
}

.drawer-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-4) var(--s-5);
}

.drawer-footer {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--gray-100);
  background: var(--white);
  flex-shrink: 0;
}

.drawer-footer .btn-primary {
  flex: 1;
}


/* ============================================================
   10. HERO CARDS (.hero-card)
   ============================================================ */

.hero-card {
  padding: var(--s-5) var(--s-4);
  margin: var(--s-4);
  border-radius: var(--r-lg);
  color: var(--white);
}

.hero-card.is-teal {
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
}

.hero-card.is-success {
  background: linear-gradient(135deg, var(--success), #047857);
}

.hero-card.is-error {
  background: linear-gradient(135deg, var(--error), #DC2626);
}

.hero-card-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  opacity: 0.9;
  margin-bottom: var(--s-1);
}

.hero-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold);
}

.hero-card-sub {
  font-size: var(--text-sm);
  opacity: 0.9;
  margin-top: var(--s-2);
}


/* ============================================================
   11. STATS GRID (.stats-grid, .stat-card)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  padding: 0 var(--s-4) var(--s-4);
}

@media (max-width: 390px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  text-align: center;
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--gray-500);
  margin-bottom: var(--s-1);
}

.stat-card-value {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--gray-900);
}

.stat-card-value.is-warning { color: var(--warning); }
.stat-card-value.is-error   { color: var(--error); }
.stat-card-value.is-success { color: var(--success); }


/* ============================================================
   12. EMPTY STATE (.empty-state)
   ============================================================
   Resets explícitos para sobrescrever .empty-state legado
   (style.css e dashboard-modern.css definem font-size:55px,
   height:200px, background, border dashed — herança indevida).

   Especificidade aumentada via .card .empty-state e .drawer
   .empty-state. Variante .empty-state-card pra uso compacto.
   ============================================================ */

.empty-state,
.card .empty-state,
.drawer .empty-state {
  /* Resets contra legado */
  font-size: inherit;
  height: auto;
  background: transparent;
  border: none;
  box-shadow: none;
  font-style: normal;
  color: inherit;

  /* Layout do design system */
  padding: var(--s-12) var(--s-4);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--gray-300);
  margin: 0 auto var(--s-3);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--gray-900);
  margin-bottom: var(--s-1);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--gray-500);
  max-width: 240px;
  margin: 0 auto var(--s-4);
}

/* ------------------------------------------------------------
   Variante: empty-state-card
   Uso embed dentro de cards pequenos (ex: card de status no PDV).
   Padding e tamanhos reduzidos pra não inflar o container pai.
   ------------------------------------------------------------ */

.empty-state.empty-state-card,
.card .empty-state.empty-state-card,
.drawer .empty-state.empty-state-card {
  padding: var(--s-4) var(--s-3);
}

.empty-state.empty-state-card .empty-state-icon {
  width: 32px;
  height: 32px;
  margin-bottom: var(--s-2);
  font-size: 24px;
}

.empty-state.empty-state-card .empty-state-title {
  font-size: var(--text-base);
  margin-bottom: 2px;
}

.empty-state.empty-state-card .empty-state-text {
  font-size: var(--text-sm);
  margin-bottom: var(--s-3);
}


/* ============================================================
   13. TOASTS (.toast)
   ============================================================ */

.toast {
  position: fixed;
  bottom: var(--s-6);
  left: var(--s-4);
  right: var(--s-4);
  background: var(--gray-900);
  color: var(--white);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  animation: slideUp var(--transition-slow);
}

@media (min-width: 768px) {
  .toast {
    top: var(--s-4);
    right: var(--s-4);
    bottom: auto;
    left: auto;
    max-width: 320px;
  }
}


/* ============================================================
   14. SECTION TITLE (.section-title)
   ============================================================ */

.section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--gray-500);
  padding: var(--s-3) 0 var(--s-2);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-title-link {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--teal-700);
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}


/* ============================================================
   15. PAGE LAYOUT (.page, .page-body)
   ============================================================ */

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--gray-50);
}

.page-body {
  flex: 1;
  padding: var(--s-4);
}

@media (min-width: 1024px) {
  .page {
    max-width: 100%;
  }
  .page-body {
    padding: var(--s-6);
  }
}


/* ============================================================
   16. RESPONSIVE GRID (.grid-cards)
   ============================================================ */

.grid-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}

@media (min-width: 768px) {
  .grid-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ============================================================
   17. ANIMAÇÕES
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.1); }
}


/* ============================================================
   18. UTILITÁRIOS PERMITIDOS (apenas estes)
   ============================================================ */

/* Flex helpers */
.u-flex { display: flex; }
.u-flex-1 { flex: 1; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-1 { gap: var(--s-1); }
.u-gap-2 { gap: var(--s-2); }
.u-gap-3 { gap: var(--s-3); }
.u-gap-4 { gap: var(--s-4); }

/* Spacing helpers */
.u-mt-1 { margin-top: var(--s-1); }
.u-mt-2 { margin-top: var(--s-2); }
.u-mt-3 { margin-top: var(--s-3); }
.u-mt-4 { margin-top: var(--s-4); }
.u-mb-1 { margin-bottom: var(--s-1); }
.u-mb-2 { margin-bottom: var(--s-2); }
.u-mb-3 { margin-bottom: var(--s-3); }
.u-mb-4 { margin-bottom: var(--s-4); }

/* Texto */
.u-text-sm { font-size: var(--text-sm); }
.u-text-base { font-size: var(--text-base); }
.u-text-lg { font-size: var(--text-lg); }
.u-text-bold { font-weight: var(--weight-bold); }
.u-text-semibold { font-weight: var(--weight-semibold); }
.u-text-center { text-align: center; }

/* Cores semânticas de texto */
.u-text-success { color: var(--success); }
.u-text-warning { color: var(--warning); }
.u-text-error   { color: var(--error); }
.u-text-muted   { color: var(--gray-500); }

/* Truncate */
.u-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   FIM DO ARQUIVO
   ============================================================
   
   ⚠️  SE PRECISA DE UMA CLASSE QUE NÃO EXISTE AQUI:
   1. NÃO crie em outro arquivo
   2. ABRA PR específica adicionando a classe AQUI
   3. Documente o uso em SPEC-VISUAL-*.md
   4. Atualize a versão do design system
   
   ============================================================ */
