/* ============================================================================
   XControl — TEMA ERP (skin visual opcional)
   Ativado por  body.erp-theme  (ligado pelo flag Parametros.bo_tema_erp).
   100% reversível: sem a classe no body, NADA aqui tem efeito.
   Pegada: corporativo denso — acento teal/grafite, hero flat, grid técnica
   com números tabulares, status em pill, menu lateral com acento.
   ============================================================================ */

body.erp-theme {
    /* O acento SEGUE a cor do sistema escolhida em "Personalizar"
       (--mud-palette-primary), em vez de uma cor fixa — assim o tema ERP e a
       personalização de cor do app ficam integrados (troque a cor lá, o ERP acompanha). */
    --erp-accent:      var(--mud-palette-primary);
    --erp-accent-dk:   var(--mud-palette-primary-darken);
    --erp-accent-ink:  var(--mud-palette-primary-darken);
    --erp-accent-soft: rgba(var(--mud-palette-primary-rgb), 0.10);
    --erp-line:        rgba(120, 120, 120, 0.18);
    font-feature-settings: "tnum" 1, "cv01" 1;
}

/* ---- Cantos mais retos (cara de ERP) ------------------------------------ */
body.erp-theme .mud-paper,
body.erp-theme .mud-card,
body.erp-theme .mud-table,
body.erp-theme .kpi-card-modern { border-radius: 8px !important; }

/* ---- Acento teal: botões primários / FAB / switches --------------------- */
body.erp-theme .mud-button-filled-primary,
body.erp-theme .mud-fab-primary,
body.erp-theme .mud-button-filled.mud-button-filled-primary {
    background-color: var(--erp-accent) !important;
    color: #fff !important;
    box-shadow: none !important;
}
body.erp-theme .mud-button-filled-primary:hover { background-color: var(--erp-accent-dk) !important; }
body.erp-theme .mud-button-outlined-primary,
body.erp-theme .mud-button-text-primary { color: var(--erp-accent-ink) !important; }

/* FORMA ÚNICA dos botões em todo o sistema: PÍLULA (como era), igual em todas as
   telas. Padroniza pílulas/quadrados/radius variados numa só cara, sem sombra. */
body.erp-theme .mud-button-root {
    border-radius: 999px !important;
    text-transform: none !important;
    font-weight: 500 !important;
    box-shadow: none !important;
}
body.erp-theme .mud-button-outlined-primary,
body.erp-theme .mud-button-outlined { border-color: var(--erp-line) !important; }
body.erp-theme .mud-button-outlined-primary { border-color: var(--erp-accent) !important; }

/* ---- Switches: monocromáticos (acento único, sem arco-íris) ------------- */
/* No tema padrão os switches são coloridos por semântica (verde/azul/laranja);
   no skin ERP TODOS seguem o MESMO acento da cor do sistema. Afeta só o estado
   LIGADO (thumb sólido + track tingido); desligado fica neutro. Independe da
   cor declarada no MudSwitch (primary/success/warning/info/secondary/error). */
body.erp-theme .mud-switch-base.mud-checked .mud-switch-thumb { background-color: var(--erp-accent) !important; }
body.erp-theme .mud-switch-base.mud-checked + .mud-switch-track { background-color: var(--erp-accent) !important; }

/* ---- Banners: padroniza TODOS (hero-banner + fh-banner do FiscalHero) ---- */
body.erp-theme .hero-banner,
body.erp-theme .fh-banner {
    background: var(--mud-palette-surface) !important;
    background-image: none !important;
    border: 0.5px solid var(--erp-line) !important;
    border-left: 3px solid var(--erp-accent) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    color: var(--mud-palette-text-primary) !important;
}
/* mata os círculos decorativos dos heros */
body.erp-theme .hero-banner::before,
body.erp-theme .hero-banner::after,
body.erp-theme .fh-banner::before,
body.erp-theme .fh-banner::after { display: none !important; }

/* catch-all: QUALQUER texto solto no hero (incl. inline color:white) → legível */
body.erp-theme .hero-banner *,
body.erp-theme .fh-banner * { color: var(--mud-palette-text-primary) !important; }
/* ícones soltos do hero (título) → acento */
body.erp-theme .hero-banner .mud-icon-root,
body.erp-theme .fh-banner .mud-icon-root { color: var(--erp-accent) !important; }
/* títulos e subtítulo (vêm depois pra ganhar do catch-all) */
body.erp-theme .hero-greeting,
body.erp-theme .fh-titulo { color: var(--mud-palette-text-primary) !important; }
body.erp-theme .hero-sub,
body.erp-theme .fh-subtitulo { color: var(--mud-palette-text-secondary) !important; opacity: 1 !important; }
/* chips/badges soltos no hero → pill de acento legível */
body.erp-theme .hero-banner .mud-chip,
body.erp-theme .fh-banner .mud-chip {
    background: var(--erp-accent-soft) !important;
    color: var(--erp-accent-ink) !important;
    border: 0.5px solid var(--erp-line) !important;
}

/* caixa de ícone do hero → acento teal */
body.erp-theme .hero-banner .mud-avatar,
body.erp-theme .fh-icon-box {
    background: var(--erp-accent-soft) !important;
    box-shadow: none !important;
}
body.erp-theme .hero-banner .mud-avatar .mud-icon-root,
body.erp-theme .fh-icon-box .mud-icon-root { color: var(--erp-accent) !important; }

/* badges do hero → pill neutro legível */
body.erp-theme .hero-badge,
body.erp-theme .fh-badges .mud-chip {
    background: var(--erp-accent-soft) !important;
    color: var(--erp-accent-ink) !important;
    border: 0.5px solid var(--erp-line) !important;
}

/* botões dentro do hero → legíveis sobre superfície clara */
body.erp-theme .hero-banner .mud-button-root,
body.erp-theme .fh-banner .mud-button-root {
    color: var(--mud-palette-text-primary) !important;
    background: var(--mud-palette-background) !important;
    border: 0.5px solid var(--erp-line) !important;
}
body.erp-theme .hero-banner .mud-button-root .mud-icon-root,
body.erp-theme .fh-banner .mud-button-root .mud-icon-root { color: var(--mud-palette-text-secondary) !important; }
/* ação primária do hero (filled/primary/surface) → acento sólido + texto BRANCO.
   O catch-all de texto acima NÃO pode deixar a legenda escura sobre o acento. */
body.erp-theme .hero-banner .mud-button-filled-primary,
body.erp-theme .hero-banner .hero-btn-primary,
body.erp-theme .fh-banner .mud-button-filled-primary,
body.erp-theme .fh-banner .hero-btn-primary,
body.erp-theme .fh-banner .mud-button-filled-surface {
    background: var(--erp-accent) !important;
    border-color: var(--erp-accent) !important;
}
body.erp-theme .hero-banner .mud-button-filled-primary,
body.erp-theme .hero-banner .mud-button-filled-primary *,
body.erp-theme .hero-banner .hero-btn-primary,
body.erp-theme .hero-banner .hero-btn-primary *,
body.erp-theme .fh-banner .mud-button-filled-primary,
body.erp-theme .fh-banner .mud-button-filled-primary *,
body.erp-theme .fh-banner .hero-btn-primary,
body.erp-theme .fh-banner .hero-btn-primary *,
body.erp-theme .fh-banner .mud-button-filled-surface,
body.erp-theme .fh-banner .mud-button-filled-surface * { color: #fff !important; }

/* ---- KPIs: shape uniforme (flat, sem lift) + MESMA altura, largura original  */
/* min-height (em vez de stretch via flex) mantém a largura/proporção original
   dos cards e só iguala a ALTURA — o card com sub-linha não fica maior. */
body.erp-theme .kpi-card-modern,
body.erp-theme .fk-card,
body.erp-theme .insight-card { border-radius: 8px !important; box-shadow: none !important; min-height: 96px; }
body.erp-theme .fk-card,
body.erp-theme .insight-card { border-left-width: 3px !important; }
body.erp-theme .kpi-card-modern:hover,
body.erp-theme .fk-card:hover,
body.erp-theme .insight-card:hover { transform: none !important; box-shadow: none !important; }

/* ---- Tabelas: densas, técnicas, números tabulares ----------------------- */
body.erp-theme .mud-table-root { font-size: 0.82rem; }
body.erp-theme .mud-table-cell {
    padding: 6px 10px !important;
    font-variant-numeric: tabular-nums;
}
body.erp-theme .mud-table-head .mud-table-cell {
    text-transform: none;
    font-weight: 500;
    font-size: 0.72rem !important;
    letter-spacing: 0.2px;
    color: var(--mud-palette-text-secondary) !important;
    background: var(--mud-palette-background-grey) !important;
    border-bottom: 1px solid var(--erp-line) !important;
}
body.erp-theme .mud-table-root tbody tr:hover > td { background: var(--erp-accent-soft) !important; }

/* ---- Chips → pill discreto ---------------------------------------------- */
body.erp-theme .mud-chip { border-radius: 16px !important; font-weight: 500; }

/* ---- Menu lateral: ícones monocromáticos (sem arco-íris) ---------------- */
body.erp-theme .mud-navmenu .mud-icon-root,
body.erp-theme .mud-nav-link .mud-icon-root,
body.erp-theme .mud-nav-group > .mud-nav-link .mud-icon-root {
    color: var(--mud-palette-text-secondary) !important;
}
body.erp-theme .mud-nav-link:hover .mud-icon-root { color: var(--mud-palette-text-primary) !important; }

/* ---- Menu lateral: item ativo com barra de acento ----------------------- */
body.erp-theme .mud-nav-link.active,
body.erp-theme .mud-nav-link.mud-nav-link-active {
    background: var(--erp-accent-soft) !important;
    color: var(--erp-accent-ink) !important;
    border-left: 2px solid var(--erp-accent) !important;
    font-weight: 500;
}
body.erp-theme .mud-nav-link.active .mud-icon-root,
body.erp-theme .mud-nav-link.mud-nav-link-active .mud-icon-root { color: var(--erp-accent) !important; }

/* ---- Inputs / cards: bordas finas, cantos retos ------------------------- */
body.erp-theme .mud-input-control .mud-input-outlined-border { border-radius: 8px; }
body.erp-theme .border-1,
body.erp-theme .mud-card { border-color: var(--erp-line) !important; }

/* ---- Cards "premium" (accent-*): laterais coloridas → acento único ------- */
/* Padrão compartilhado por ~83 popups (site.css: .card-premium.accent-*). No
   tema ERP a borda lateral colorida (azul/info/âmbar/verde/secondary) vira o
   ACENTO do sistema, e o card fica flat (raio 8px, sem sombra) pra casar com o
   restante. 'accent-error' (vermelho) fica INTACTO — sinaliza perigo/destrutivo.
   Os ícones de header (.accent-*-icon) acompanham o acento. Uma regra, 83 telas. */
body.erp-theme .card-premium { border-radius: 8px !important; box-shadow: none !important; }
body.erp-theme .card-premium.accent-primary,
body.erp-theme .card-premium.accent-info,
body.erp-theme .card-premium.accent-success,
body.erp-theme .card-premium.accent-secondary,
body.erp-theme .card-premium.accent-warning { border-left-color: var(--erp-accent) !important; }
body.erp-theme .card-header .accent-primary-icon,
body.erp-theme .card-header .accent-info-icon,
body.erp-theme .card-header .accent-success-icon,
body.erp-theme .card-header .accent-secondary-icon,
body.erp-theme .card-header .accent-warning-icon { color: var(--erp-accent) !important; }

/* ---- Tabs: barra FLAT (não bloco navy) + aba ativa no acento + underline - */
body.erp-theme .mud-tabs-tabbar {
    background: transparent !important;
    background-color: transparent !important;
    border-bottom: 0.5px solid var(--erp-line) !important;
    box-shadow: none !important;
}
body.erp-theme .mud-tabs-tabbar .mud-tab,
body.erp-theme .mud-tabs-tabbar .mud-tab .mud-icon-root { color: var(--mud-palette-text-secondary) !important; }
body.erp-theme .mud-tabs-tabbar .mud-tab.mud-tab-active { color: var(--erp-accent-ink) !important; }
body.erp-theme .mud-tabs-tabbar .mud-tab.mud-tab-active .mud-icon-root { color: var(--erp-accent) !important; }
body.erp-theme .mud-tabs-tabbar .mud-tab-scroll-button .mud-icon-root { color: var(--mud-palette-text-secondary) !important; }
body.erp-theme .mud-tab-slider { background: var(--erp-accent) !important; }

/* ---- Headers de diálogo premium (Personalizar, buscas, etc.): flat ------- */
body.erp-theme .premium-dialog { border-radius: 12px !important; box-shadow: 0 12px 32px rgba(0,0,0,0.18) !important; }
body.erp-theme .premium-header {
    background: var(--mud-palette-surface) !important;
    background-image: none !important;
    border-bottom: 0.5px solid var(--erp-line) !important;
    border-left: 3px solid var(--erp-accent) !important;
}
body.erp-theme .premium-header::before,
body.erp-theme .premium-header::after { display: none !important; }
/* texto do header era branco sobre gradiente → cor primária legível */
body.erp-theme .premium-header,
body.erp-theme .premium-header * { color: var(--mud-palette-text-primary) !important; }
body.erp-theme .premium-header .header-badge {
    background: var(--erp-accent-soft) !important;
    color: var(--erp-accent-ink) !important;
    border: 0.5px solid var(--erp-line) !important;
}
body.erp-theme .premium-header .mud-avatar { background: var(--erp-accent-soft) !important; }
body.erp-theme .premium-header .mud-avatar .mud-icon-root { color: var(--erp-accent) !important; }
body.erp-theme .premium-header .mud-icon-button { background: transparent !important; }
body.erp-theme .premium-header .mud-icon-button .mud-icon-root { color: var(--mud-palette-text-secondary) !important; }

/* ═══════════════ PALETA PROFISSIONAL — 1 acento + neutros ════════════════ */
/* Mata o "arco-íris": tudo fala a COR DO SISTEMA + cinzas. Cor semântica
   (verde/vermelho/âmbar) fica reservada pros pills de STATUS, que informam algo.
   KPIs deixam de ter uma cor por card; o número é o dado, o acento é único. */

/* KPIs FiscalKpi — força o acento na cor do sistema (era hex por instância) */
body.erp-theme .fk-card  { --fk-cor: var(--erp-accent) !important; }
body.erp-theme .fk-valor { color: var(--mud-palette-text-primary) !important; }
body.erp-theme .fk-ico   { color: var(--erp-accent) !important; opacity: 0.9 !important; }

/* KPIs kpi-card-modern — faixa e ícone no acento; número neutro forte */
body.erp-theme .kpi-card-modern { border-left: 3px solid var(--erp-accent) !important; }
body.erp-theme .kpi-card-modern .kpi-value { color: var(--mud-palette-text-primary) !important; }
body.erp-theme .kpi-card-modern .kpi-icon-bg,
body.erp-theme .kpi-card-modern .kpi-icon-bg.mud-icon-root { color: var(--erp-accent) !important; }

/* KPIs insight-card — idem (some o success/info/warning/error decorativo) */
body.erp-theme .insight-card { border-left-color: var(--erp-accent) !important; }
body.erp-theme .insight-card .mud-icon-root { color: var(--erp-accent) !important; }

/* Ícones decorativos "tertiary" (3ª cor da paleta) → neutros */
body.erp-theme .mud-icon-root.mud-tertiary-text { color: var(--mud-palette-text-secondary) !important; }

/* HubCard (.hub-card usa --hc-cor por instância) → acento único do sistema */
body.erp-theme .hub-card { --hc-cor: var(--erp-accent) !important; }

/* Dialogo de confirmação com header em gradiente (.dialogo-grad-*) → flat */
body.erp-theme [class*="dialogo-grad-"] {
    background: var(--mud-palette-surface) !important;
    background-image: none !important;
    border-bottom: 0.5px solid var(--erp-line) !important;
}
body.erp-theme [class*="dialogo-grad-"],
body.erp-theme [class*="dialogo-grad-"] * { color: var(--mud-palette-text-primary) !important; }

/* Abas de telas abertas (TabsHistorico): seguem a cor do sistema; ativa FLAT */
body.erp-theme .tab { --tab-cor: var(--erp-accent) !important; }
body.erp-theme .tab-ativa {
    background: var(--erp-accent) !important;
    background-image: none !important;
    box-shadow: none !important;
}
body.erp-theme .tab-ativa,
body.erp-theme .tab-ativa .tab-label,
body.erp-theme .tab-ativa .mud-icon-root,
body.erp-theme .tab-ativa .tab-close { color: #fff !important; }
body.erp-theme .tab::before { display: none !important; }
