/**
 * VMarket UI Components v2 — classes globais reutilizáveis
 * Ref: resources/docs/design-guidelines.md
 * Carregado em view/template.php (após global_v2_tokens.css)
 */

/* Tipografia base dos módulos v2 já é tratada em global_v2_shell.css via
   [class*="-v2-root"] (escopado ao componente Vue, não ao .right_col
   inteiro — .right_col é usado por QUALQUER tela, não só as v2). Uma regra
   de font-size aqui em cima de body.vm-global-v2 .right_col tem
   especificidade maior que o seletor de atributo e vazava fonte grande
   pras telas legadas (PC-350). Não recriar essa regra aqui. */

/* ---- Typography ---- */
.vm-text-xs { font-size: var(--vm-text-xs); }
.vm-text-sm { font-size: var(--vm-text-sm); }
.vm-text-muted { color: var(--vm-text-muted); }
.vm-text-heading { color: var(--vm-text-heading); }
.vm-text-success { color: var(--vm-success); }
.vm-font-semibold { font-weight: var(--vm-weight-semibold); }
.vm-font-bold { font-weight: var(--vm-weight-bold); }

.vm-section-label {
  font-size: var(--vm-text-xs);
  font-weight: var(--vm-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vm-text-muted);
  padding: 0.75rem 1rem 0.25rem;
}

/* ---- Container responsivo (opt-in via classe — NÃO usa seletor de
   atributo tipo [class*="-v2-root"], então não afeta telas legadas nem
   outras telas -v2 que não adicionarem a classe explicitamente) ---- */
.vm-container-v2 {
  width: 95%;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Page title (título de página, fora de cards — telas -v2) ---- */
.vm-page-title {
  margin: 0 0 1rem;
  font-size: 28px;
  font-weight: var(--vm-weight-bold);
  color: var(--vm-text-heading);
  line-height: 1.2;
  padding-top: 1.5rem;
}

/* ---- Buttons ---- */
.vm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: var(--vm-text-sm);
  font-weight: var(--vm-weight-semibold);
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: var(--vm-radius-lg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
}

.vm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.vm-btn:focus-visible {
  outline: 2px solid rgba(var(--vm-primary-rgb), 0.35);
  outline-offset: 2px;
}

.vm-btn--primary {
  background: var(--vm-cta, var(--vm-primary));
  color: #fff;
}

.vm-btn--primary:hover {
  background: var(--vm-cta-hover, var(--vm-primary-hover));
  box-shadow: var(--vm-shadow-primary);
}

.vm-btn--secondary {
  background: var(--vm-surface);
  color: var(--vm-text);
  border-color: var(--vm-border);
  box-shadow: var(--vm-shadow-input);
}

.vm-btn--secondary:hover {
  background: var(--vm-gray-50);
  border-color: var(--vm-gray-200);
}

.vm-btn--danger {
  background: var(--vm-danger);
  color: #fff;
}

.vm-btn--danger:hover {
  background: #e02b5a;
  box-shadow: 0 4px 14px rgba(255, 51, 102, 0.32);
}

/* Ícones brand têm um traço de acento laranja; sobre fundo laranja/vermelho
   ele sumiria, então nesses botões o ícone fica monocromático. */
.vm-btn--primary svg [stroke],
.vm-btn--danger svg [stroke] {
  stroke: currentColor;
}

.vm-btn--ghost {
  background: transparent;
  color: var(--vm-text-muted);
  border-color: transparent;
  padding: 0.375rem 0.625rem;
}

.vm-btn--ghost:hover {
  background: var(--vm-primary-tint);
  color: var(--vm-primary);
}

.vm-btn--sm {
  padding: 0.375rem 0.75rem;
  font-size: var(--vm-text-xs);
}

.vm-btn--lg {
  padding: 0.5rem 1rem;
  font-size: var(--vm-text-sm);
  line-height: 1.5;
  border-radius: var(--vm-radius-lg);
}

.vm-btn--block {
  width: 100%;
}

.vm-btn--pill {
  border-radius: var(--vm-radius-pill);
}

/* ---- Form ---- */
.vm-form-group {
  margin-bottom: 1rem;
}

.vm-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: var(--vm-text-sm);
  font-weight: var(--vm-weight-medium);
  color: var(--vm-text-heading);
}

.vm-input,
.vm-select {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 0.5625rem 0.875rem;
  font-family: inherit;
  font-size: var(--vm-text-sm);
  color: var(--vm-text-heading);
  background: var(--vm-input-bg);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-lg);
  box-shadow: var(--vm-shadow-input);
  transition: border-color 0.15s, outline 0.15s;
}

.vm-select {
  border-radius: var(--vm-radius-md);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7B93' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.vm-input::placeholder {
  color: var(--vm-text-muted);
}

.vm-input:focus,
.vm-select:focus {
  outline: 2px solid rgba(var(--vm-primary-rgb), 0.35);
  border-color: var(--vm-primary);
}

.vm-input-group {
  display: flex;
  gap: 0;
}

.vm-input-group .vm-input,
.vm-input-group .vm-select-wrap {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.vm-input-group .vm-btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
}

.vm-select-wrap {
  position: relative;
  flex: 1;
}

.vm-select-fake {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5625rem 0.875rem;
  font-size: var(--vm-text-sm);
  color: var(--vm-text-heading);
  background: var(--vm-input-bg);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-lg);
  box-shadow: var(--vm-shadow-input);
  cursor: pointer;
}

.vm-select-fake:hover {
  border-color: var(--vm-primary);
}

/* ---- Cards ---- */
.vm-card {
  background: var(--vm-surface);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-xl);
  box-shadow: var(--vm-shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.vm-card--filters {
  overflow: visible;
}

.vm-card--filters .vm-card__body,
.vm-card--filters .vm-card__footer {
  overflow: visible;
}

.vm-card__body {
  padding: 1.25rem;
}

.vm-card__footer {
  padding: 0.875rem 1.25rem;
  background: var(--vm-gray-50);
  border-top: 1px solid var(--vm-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.vm-card__title {
  font-size: var(--vm-text-sm);
  font-weight: var(--vm-weight-semibold);
  color: var(--vm-text-heading);
  margin-bottom: 1rem;
}

/* ---- Stat card ---- */
.vm-stat-card .vm-card__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 88px;
}

.vm-stat-card__value {
  font-size: var(--vm-text-3xl);
  font-weight: var(--vm-weight-bold);
  color: var(--vm-text-heading);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}

.vm-stat-card__value--success {
  color: var(--vm-success);
}

.vm-stat-card__label {
  font-size: var(--vm-text-sm);
  color: var(--vm-text-muted);
}

.vm-stat-card__sublabel {
  font-size: var(--vm-text-xs);
  color: var(--vm-text-muted);
  margin-top: 0.125rem;
}

.vm-stat-card__icon {
  font-size: 2.5rem;
  color: var(--vm-gray-200);
  flex-shrink: 0;
}

.vm-stat-card__icon i {
  color: rgba(var(--vm-primary-rgb), 0.25);
}

/* ---- Badge ---- */
.vm-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: var(--vm-text-xs);
  font-weight: var(--vm-weight-medium);
  border-radius: var(--vm-radius-pill);
}

.vm-badge--success {
  background: var(--vm-success-bg);
  color: var(--vm-success-text);
}

.vm-badge--primary {
  background: rgba(var(--vm-primary-rgb), 0.12);
  color: var(--vm-primary-hover);
}

/* ---- Table ---- */
.vm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--vm-text-sm);
}

.vm-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-weight: var(--vm-weight-semibold);
  color: var(--vm-text-heading);
  border-bottom: 1px solid var(--vm-border);
}

.vm-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--vm-border);
  color: var(--vm-text);
}

.vm-table--compras th:first-child,
.vm-table--compras td:first-child {
  width: 1.75rem;
}

.vm-table--compras th:last-child,
.vm-table--compras td:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

/* ---- Section & layout grid ---- */
.vm-section {
  margin-bottom: 1.5rem;
}

/* Utilitário compartilhado de espaçamento superior — usar em vez de repetir
   margin-top em CSS por componente (PC-350). */
.vm-mt-20 {
  margin-top: 20px;
}

.vm-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.vm-section-head h2 {
  font-size: 1rem;
  color: var(--vm-text-heading);
}

.vm-section-head p {
  font-size: var(--vm-text-xs);
  color: var(--vm-text-muted);
  margin-top: 0.125rem;
}

.vm-grid {
  display: grid;
  gap: 1.5rem;
}

.vm-grid--filters {
  grid-template-columns: minmax(220px, 2fr) minmax(120px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 1rem;
}

@media (max-width: 992px) {
  .vm-grid--filters {
    grid-template-columns: 1fr;
  }
}

/* ---- Modal V2 ---- */
.vm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(22, 25, 44, 0.55);
  overflow-y: auto;
}

.vm-modal {
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--vm-surface);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-xl);
  box-shadow: var(--vm-shadow);
}

.vm-modal--md {
  max-width: 43.75rem;
}

.vm-modal--lg {
  max-width: 64rem;
}

.vm-modal--xl {
  max-width: min(90rem, 98vw);
}

.vm-modal--sm {
  max-width: 26rem;
}

.vm-modal__header,
.vm-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--vm-gray-50);
  border-bottom: 1px solid var(--vm-border);
}

.vm-modal__footer {
  justify-content: flex-end;
  border-bottom: 0;
  border-top: 1px solid var(--vm-border);
}

/* ---- Utility: card posicionado ---- */
.vm-card--relative {
  position: relative;
}

/* ---- Loading overlay base (compartilhado entre telas V2) ---- */
.vm-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--vm-radius-xl);
  z-index: 2;
  color: var(--vm-text-muted);
}

/* ---- Escala tipográfica V2 (Dashboard = referência visual) ----
   Scoped em .vm-v2-root: adicionar essa classe no root de qualquer
   nova tela V2 para herdar automaticamente o padrão tipográfico. */
.vm-v2-root .vm-section-head h2 {
  font-size: 1.5rem;
}

.vm-v2-root .vm-section-head p {
  font-size: 1.2rem;
}

.vm-v2-root .vm-label {
  font-size: 1.2rem;
}

.vm-v2-root .vm-input,
.vm-v2-root .vm-select,
.vm-v2-root .vm-btn {
  font-size: 1.2rem !important;
}

.vm-v2-root .vm-table th,
.vm-v2-root .vm-table td {
  font-size: 1.2rem;
}

.vm-v2-root .vm-badge {
  font-size: 1.2rem;
}

/* ---- Disabled state V2 ---- */
.vm-v2-root .vm-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.vm-modal__header h4 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: var(--vm-weight-semibold);
  color: var(--vm-text-heading);
  line-height: 1.3;
}

.vm-modal__body {
  padding: 1.25rem;
  overflow-y: auto;
  color: var(--vm-text);
  /* Alinha ao shell V2 (--vm-text-v2-base); --vm-text-base é 0.875rem e
     deixava o conteúdo do modal visualmente menor que a página. */
  font-size: var(--vm-text-v2-base, 1.2rem);
  line-height: var(--vm-leading);
}

.vm-modal__body p {
  margin: 0 0 0.75rem;
}

.vm-modal__body p:last-child {
  margin-bottom: 0;
}

.vm-modal__accent {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.vm-modal__accent-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: var(--vm-radius-lg);
  font-size: 1.25rem;
}

.vm-modal__accent-icon--danger {
  background: rgba(255, 51, 102, 0.12);
  color: var(--vm-danger);
}

.vm-modal__accent-icon--success {
  background: var(--vm-success-bg);
  color: var(--vm-success-text);
}

.vm-modal__accent-icon--warning {
  background: rgba(255, 140, 0, 0.12);
  color: var(--vm-warning);
}

.vm-modal__accent-icon--primary {
  background: rgba(var(--vm-primary-rgb), 0.12);
  color: var(--vm-primary);
}

/* ---- Tooltip / Popover (Bootstrap skin V2 — body.vm-global-v2) ---- */
body.vm-global-v2 .tooltip {
  font-family: var(--vm-font-sans);
  font-size: var(--vm-text-sm);
  font-weight: var(--vm-weight-normal);
}

body.vm-global-v2 .tooltip-inner {
  max-width: 16rem;
  padding: 0.4rem 0.65rem;
  color: #fff;
  background: var(--vm-gray-900);
  border-radius: var(--vm-radius-md);
  box-shadow: var(--vm-shadow);
}

body.vm-global-v2 .popover,
body.vm-global-v2 .editable-container.popover {
  max-width: 28rem;
  font-family: var(--vm-font-sans);
  font-size: var(--vm-text-v2-base, 1.2rem);
  color: var(--vm-text);
  background: var(--vm-surface);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-xl);
  box-shadow: var(--vm-shadow);
  z-index: 1060;
}

body.vm-global-v2 .popover-title,
body.vm-global-v2 .popover .popover-title,
body.vm-global-v2 .editable-container .popover-title {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  font-weight: var(--vm-weight-semibold);
  line-height: 1.35;
  color: var(--vm-text-heading);
  background: var(--vm-gray-50);
  border-bottom: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-xl) var(--vm-radius-xl) 0 0;
}

body.vm-global-v2 .popover-content,
body.vm-global-v2 .popover .popover-content,
body.vm-global-v2 .editable-container .popover-content {
  padding: 0.875rem 1rem;
  font-size: 1.05rem;
  color: var(--vm-text);
}

body.vm-global-v2 .popover .vm-table {
  margin: 0;
}

body.vm-global-v2 .editable-container .editable-input {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

body.vm-global-v2 .editable-container .editable-input input,
body.vm-global-v2 .editable-container .editable-input select,
body.vm-global-v2 .editable-container .editable-input textarea {
  min-width: 14rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  font-family: var(--vm-font-sans);
  font-size: 1.05rem;
  color: var(--vm-text-heading);
  background: var(--vm-input-bg);
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-lg);
  box-shadow: var(--vm-shadow-input);
}

body.vm-global-v2 .editable-container .editable-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.5rem;
  margin-top: 0;
  vertical-align: middle;
}

body.vm-global-v2 .editable-container .editable-buttons .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 1rem;
  font-weight: var(--vm-weight-semibold);
  border-radius: var(--vm-radius-lg);
}

/* x-editable / bootstrap-editable: form-inline do prazo */
body.vm-global-v2 .editable-container .control-group,
body.vm-global-v2 .editable-container .editable-input,
body.vm-global-v2 .editable-container form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Paleta/tokens da marca (v2) — overlay opt-in ----
   Regras visuais vêm do guia de marca v3 em brand.vmarket.com.br, mas a
   nomenclatura do NOSSO css continua v2 (a reestruturação v2 ainda não
   terminou — v3 lá é só a referência visual que estamos seguindo, não uma
   versão nova daqui). Adiciona essa classe junto de qualquer *-v2-root
   (ou no .top_nav/.left_col, chrome global) pra herdar paleta, fonte, raio
   e sombra do guia, sem tocar nos tokens em :root (que continuam valendo
   pras telas v2 que não adotarem a classe). --vm-primary vira
   verde-floresta (cor de chrome/interação geral: ícone, gráfico, tab,
   badge, timeline — usado em ~15 lugares no CSS existente). --vm-cta é um
   token à parte, só pro botão primário e pro anel de foco, pra não pintar
   a tela inteira de laranja (regra do guia: "1 botão laranja por tela").
   Adoção: dashboard_v2, header (.top_nav) e sidebar (.left_col); demais
   telas v2 adotam depois, na ordem que forem migrando (guiadefornecedores_v2,
   contagem_v2, etc). */
.vm-brand-v2 {
  --vm-primary: #1e4a3a;
  --vm-primary-hover: #163529;
  --vm-primary-rgb: 30, 74, 58;
  --vm-primary-tint: #e7eeec;

  --vm-brand-green: #1e4a3a;
  --vm-brand-green-hover: #163529;
  --vm-brand-green-rgb: 30, 74, 58;
  --vm-brand-green-tint: #e7eeec;

  --vm-brand-leaf: #8bc34a;
  --vm-brand-mint: #cfe6c1;
  --vm-brand-cream: #f5f2ec;
  --vm-brand-cream-bg: #efeae0;
  --vm-ink: #2b2b26;

  --vm-brand-danger: #b23a1d;

  --vm-cta: #e8772e;
  --vm-cta-hover: #c95f1c;
  --vm-cta-rgb: 232, 119, 46;

  --vm-font-sans: "Arimo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* font-family herdado não reavalia var() sozinho — sem isto o valor de
     --vm-font-sans acima fica sem efeito (body.vm-global-v2 já resolveu
     "Inter" e propaga o valor computado, não a expressão var()). */
  font-family: var(--vm-font-sans);

  /* Base rem = 10px (bootstrap.min.css: html{font-size:10px}), não 16px —
     px/10 pra converter, não px/16. Brand: campo/badge 6px, botão/chip
     10px, card 14px. */
  --vm-radius-md: 0.6rem;
  --vm-radius-lg: 1rem;
  --vm-radius-xl: 1.4rem;

  --vm-shadow: 0px 2px 8px -2px rgba(30, 74, 58, 0.16), 0px 0px 1px 0px rgba(30, 74, 58, 0.08);
  --vm-shadow-primary: 0 4px 14px rgba(232, 119, 46, 0.32);
  --vm-shadow-input: 0px 1px 3px rgba(30, 74, 58, 0.1);
}

/* Foco (regra do brand: "focus state = 3px orange ring"). Botão: anel com
   respiro (outline-offset). Campo: borda verde-floresta + anel laranja suave
   colado na borda (box-shadow), como no exemplo de Campos do guia. */
.vm-brand-v2 .vm-btn:focus-visible {
  outline: 3px solid rgba(232, 119, 46, 0.4);
  outline-offset: 2px;
}

.vm-brand-v2 .vm-input,
.vm-brand-v2 .vm-select {
  border-radius: var(--vm-radius-md);
}

.vm-brand-v2 .vm-input:focus,
.vm-brand-v2 .vm-select:focus {
  outline: none;
  border-color: var(--vm-primary);
  box-shadow: 0 0 0 3px rgba(232, 119, 46, 0.28);
}

/* Erro: borda vermelho-tijolo + mensagem na mesma cor (.vm-field-error). */
.vm-brand-v2 .vm-input--error,
.vm-brand-v2 .has-error .vm-input,
.vm-brand-v2 .has-error .vm-select {
  border-color: var(--vm-brand-danger);
}

.vm-brand-v2 .vm-input--error:focus,
.vm-brand-v2 .has-error .vm-input:focus,
.vm-brand-v2 .has-error .vm-select:focus {
  border-color: var(--vm-brand-danger);
  box-shadow: 0 0 0 3px rgba(178, 58, 29, 0.2);
}

.vm-brand-v2 .vm-field-error {
  margin-top: 0.6rem;
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--vm-brand-danger);
}
