/* V18-CW — limpeza profunda de tema.
   Mantém impressão/DANFE branco e corrige componentes ativos antigos no dark mode. */

:root {
  --flow-deep-bg: var(--bg-card, #ffffff);
  --flow-deep-bg-soft: var(--bg-secondary, #f8fafc);
  --flow-deep-bg-input: var(--bg-card, #ffffff);
  --flow-deep-text: var(--text-primary, #0f172a);
  --flow-deep-muted: var(--text-secondary, #64748b);
  --flow-deep-border: var(--border, #e5e7eb);
}

html[data-theme="dark"],
html[data-flow-theme="dark"],
body.dark,
body.dark-mode,
body.flow-theme-dark,
body.theme-dark {
  --flow-deep-bg: #111827;
  --flow-deep-bg-soft: #0b1220;
  --flow-deep-bg-input: #0b1220;
  --flow-deep-text: #f9fafb;
  --flow-deep-muted: #cbd5e1;
  --flow-deep-border: rgba(148, 163, 184, .22);
}

/* Toasts antigos do main.css */
html[data-theme="dark"] .toast,
html[data-theme="dark"] .toast-success,
html[data-theme="dark"] .toast-error,
html[data-theme="dark"] .toast-warning,
html[data-theme="dark"] .toast-info,
html[data-flow-theme="dark"] .toast,
html[data-flow-theme="dark"] .toast-success,
html[data-flow-theme="dark"] .toast-error,
html[data-flow-theme="dark"] .toast-warning,
html[data-flow-theme="dark"] .toast-info,
body.flow-theme-dark .toast,
body.flow-theme-dark .toast-success,
body.flow-theme-dark .toast-error,
body.flow-theme-dark .toast-warning,
body.flow-theme-dark .toast-info,
body.dark .toast,
body.dark .toast-success,
body.dark .toast-error,
body.dark .toast-warning,
body.dark .toast-info {
  background: var(--flow-deep-bg) !important;
  color: var(--flow-deep-text) !important;
  border-color: var(--flow-deep-border) !important;
  box-shadow: 0 18px 46px rgba(0,0,0,.34) !important;
}

/* Modais/dropdowns/cards antigos */
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .users-governance-card,
html[data-flow-theme="dark"] .modal,
html[data-flow-theme="dark"] .modal-content,
html[data-flow-theme="dark"] .dropdown-menu,
html[data-flow-theme="dark"] .popover,
html[data-flow-theme="dark"] .empty-state,
html[data-flow-theme="dark"] .login-card,
html[data-flow-theme="dark"] .auth-card,
html[data-flow-theme="dark"] .users-governance-card,
body.flow-theme-dark .modal,
body.flow-theme-dark .modal-content,
body.flow-theme-dark .dropdown-menu,
body.flow-theme-dark .popover,
body.flow-theme-dark .empty-state,
body.flow-theme-dark .login-card,
body.flow-theme-dark .auth-card,
body.flow-theme-dark .users-governance-card,
body.dark .modal,
body.dark .modal-content,
body.dark .dropdown-menu,
body.dark .popover,
body.dark .empty-state,
body.dark .login-card,
body.dark .auth-card,
body.dark .users-governance-card {
  background: var(--flow-deep-bg) !important;
  color: var(--flow-deep-text) !important;
  border-color: var(--flow-deep-border) !important;
}

/* Governança/usuários antigos com style inline ou classe própria */
html[data-theme="dark"] [class*="governance"],
html[data-theme="dark"] [class*="permission"],
html[data-theme="dark"] [class*="access-control"],
html[data-flow-theme="dark"] [class*="governance"],
html[data-flow-theme="dark"] [class*="permission"],
html[data-flow-theme="dark"] [class*="access-control"],
body.flow-theme-dark [class*="governance"],
body.flow-theme-dark [class*="permission"],
body.flow-theme-dark [class*="access-control"] {
  border-color: var(--flow-deep-border);
}

html[data-theme="dark"] [class*="governance"] input,
html[data-theme="dark"] [class*="governance"] select,
html[data-theme="dark"] [class*="governance"] textarea,
html[data-flow-theme="dark"] [class*="governance"] input,
html[data-flow-theme="dark"] [class*="governance"] select,
html[data-flow-theme="dark"] [class*="governance"] textarea,
body.flow-theme-dark [class*="governance"] input,
body.flow-theme-dark [class*="governance"] select,
body.flow-theme-dark [class*="governance"] textarea {
  background: var(--flow-deep-bg-input) !important;
  color: var(--flow-deep-text) !important;
  border-color: var(--flow-deep-border) !important;
}

/* Badges de canal mantêm identidade, mas ficam menos gritantes no dark. */
html[data-theme="dark"] .channel-shopee,
html[data-flow-theme="dark"] .channel-shopee,
body.flow-theme-dark .channel-shopee {
  background: rgba(255,102,51,.14) !important;
  color: #ff9b73 !important;
}

html[data-theme="dark"] .channel-ml,
html[data-flow-theme="dark"] .channel-ml,
body.flow-theme-dark .channel-ml {
  background: rgba(255,230,0,.12) !important;
  color: #facc15 !important;
  border-color: rgba(250,204,21,.32) !important;
}

html[data-theme="dark"] .channel-amazon,
html[data-flow-theme="dark"] .channel-amazon,
body.flow-theme-dark .channel-amazon {
  background: rgba(255,153,0,.14) !important;
  color: #fbbf24 !important;
}

/* Garantia: qualquer caixa antiga dentro do app, sem tocar DANFE/print. */
html[data-theme="dark"] #app [style*="background: var(--bg-card,#fff)"],
html[data-flow-theme="dark"] #app [style*="background: var(--bg-card,#fff)"],
body.flow-theme-dark #app [style*="background: var(--bg-card,#fff)"] {
  background: var(--flow-deep-bg) !important;
  color: var(--flow-deep-text) !important;
}

@media print {
  .toast,
  .modal,
  .modal-content,
  [style*="background"] {
    background: #fff !important;
    color: #111827 !important;
  }
}
