/* ========================================
   DARK MODE - SACFiscal
   ======================================== */

/* ===== Imports compartilhados =====
   pf-tokens.css: design tokens (cores, tipografia, motion).
   pf-common.css: estilos antes duplicados em ~40 páginas. */
@import url('pf-tokens.css');
@import url('pf-common.css');

/* ===== Page fade-in global =====
   Aplica fade-in suave em toda página ao carregar, evitando o "snap"
   entre navegações. Respeita prefers-reduced-motion. */
@keyframes pfPageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

body {
  animation: pfPageFadeIn 180ms ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
}

/* ===== Toggle button ===== */
#pf-dark-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  border: 0.09375rem solid #e2e8f0;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
  flex-shrink: 0;
  vertical-align: middle;
  margin-left: 0.75rem;
  margin-right: 1rem;
}

#pf-dark-mode-btn:hover {
  transform: scale(1.1);
  color: #334155;
  border-color: #94a3b8;
}

#pf-dark-mode-btn .pf-icon-moon {
  display: block;
}

#pf-dark-mode-btn .pf-icon-sun {
  display: none;
}

html.dark #pf-dark-mode-btn {
  background: transparent;
  color: #fbbf24;
  border-color: #4b5563;
}

html.dark #pf-dark-mode-btn:hover {
  color: #fcd34d;
  border-color: #6b7280;
}

html.dark #pf-dark-mode-btn .pf-icon-moon {
  display: none;
}

html.dark #pf-dark-mode-btn .pf-icon-sun {
  display: block;
}

/* ===== Body / Background ===== */
html.dark body {
  background-color: #0f1117 !important;
  color: #cbd5e1 !important;
}

/* ===== Login hero image ===== */
.pf-login-hero-img--dark {
  display: none;
}

html.dark .pf-login-hero-img--light {
  display: none;
}

html.dark .pf-login-hero-img--dark {
  display: block;
}

html.dark body.bg-gray-50 {
  background-color: #0f1117 !important;
}

/* ===== Sidebar ===== */
html.dark aside,
html.dark aside.bg-white {
  /* No mobile o sidebar é um painel sobreposto; no modo escuro ele não pode ficar transparente. */
  background-color: #1e2433 !important;
  box-shadow: none !important;
}

/* Em telas grandes, o template usa sidebar transparente (xl:bg-transparent). */
@media (min-width: 75rem) {

  html.dark aside,
  html.dark aside.bg-white {
    background-color: transparent !important;
  }
}

html.dark aside hr {
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.15), transparent) !important;
}

html.dark aside .bg-gray-200 {
  background-color: #2d3748 !important;
}

html.dark [sidenav-card] {
  background-color: #252d3f !important;
}

/* ===== Navbar ===== */
html.dark nav[navbar-main] .text-slate-700 {
  color: #cbd5e1 !important;
}

html.dark nav[navbar-main] h6 {
  color: #f1f5f9 !important;
}

html.dark nav[navbar-main] .opacity-50 {
  color: #94a3b8 !important;
}

/* ===== Sidenav burger bars ===== */
html.dark .bg-slate-500 {
  background-color: #94a3b8 !important;
}

/* ===== White backgrounds (cards, panels) ===== */
html.dark .bg-white {
  background-color: #1e2433 !important;
  color: #cbd5e1;
}

/* ===== Video player shell ===== */
html.dark .pf-video-shell {
  background-color: #0f1117 !important;
}

/* ===== Light gray backgrounds ===== */
html.dark .bg-gray-50 {
  background-color: #0f1117 !important;
}

html.dark .bg-gray-100 {
  background-color: #1a1f2e !important;
}

html.dark .bg-gray-200 {
  background-color: #252d3f !important;
}

/* ===== Text colors ===== */
html.dark .text-slate-800 {
  color: #f1f5f9 !important;
}

html.dark .text-slate-700 {
  color: #cbd5e1 !important;
}

html.dark .text-slate-600 {
  color: #94a3b8 !important;
}

html.dark .text-slate-500 {
  color: #94a3b8 !important;
}

html.dark .text-slate-400 {
  color: #64748b !important;
}

html.dark .text-gray-700 {
  color: #cbd5e1 !important;
}

html.dark .text-gray-600 {
  color: #94a3b8 !important;
}

html.dark .text-gray-500 {
  color: #64748b !important;
}

/* ===== Borders ===== */
html.dark .border-gray-200 {
  border-color: #374151 !important;
}

html.dark .border-slate-200 {
  border-color: #374151 !important;
}

html.dark hr {
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.12), transparent) !important;
}

/* ===== Inputs / Form controls ===== */
html.dark input:not([type="checkbox"]):not([type="radio"]) {
  background-color: #1e2433 !important;
  color: #f1f5f9 !important;
  border-color: #374151 !important;
}

html.dark textarea {
  background-color: #1e2433 !important;
  color: #f1f5f9 !important;
  border-color: #374151 !important;
}

html.dark select {
  background-color: #1e2433 !important;
  color: #f1f5f9 !important;
  border-color: #374151 !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #4b5563 !important;
}

/* ===== Tables ===== */
html.dark table {
  color: #cbd5e1 !important;
}

html.dark table thead th {
  color: #94a3b8 !important;
  background-color: #252d3f !important;
  border-color: #374151 !important;
}

html.dark table tbody td {
  border-color: #374151 !important;
  color: #cbd5e1 !important;
}

html.dark table tbody tr:hover td {
  background-color: #252d3f !important;
}

/* ===== Sticky last column (Ações) =====
   Várias páginas fixam a última coluna com background branco via CSS inline.
   No modo escuro, forçamos o fundo a acompanhar o tema. */
html.dark table thead th:last-child {
  background-color: #252d3f !important;
}

html.dark table tbody td:last-child {
  background-color: #1e2433 !important;
}

html.dark table tbody tr:hover td:last-child {
  background-color: #252d3f !important;
}

html.dark table thead th:last-child::after {
  background-color: #252d3f !important;
}

html.dark table tbody td:last-child::after {
  background-color: #1e2433 !important;
}

/* DataTables */
html.dark .dataTable-wrapper .dataTable-top,
html.dark .dataTable-wrapper .dataTable-bottom {
  background-color: #1e2433 !important;
  color: #cbd5e1 !important;
  border-color: #374151 !important;
}

html.dark .dataTable-wrapper table.dataTable {
  border-color: #374151 !important;
}

/* ===== Dropdown menus ===== */
html.dark .dropdown-menu {
  background-color: #1e2433 !important;
  color: #cbd5e1 !important;
}

html.dark aside [id^="dropdown-"] {
  background-color: transparent !important;
}

/* ===== Modals ===== */
html.dark .modal-content,
html.dark [id^="modal"] .bg-white,
html.dark [id*="Modal"] .bg-white {
  background-color: #1e2433 !important;
  color: #cbd5e1 !important;
}

/* Header do modal: remove border-b (evita faixa clara no escuro) */
html.dark [id^="modal"] .rounded-t-2xl.border-b,
html.dark [id*="Modal"] .rounded-t-2xl.border-b {
  border-bottom: 0 !important;
}

/* Footer do modal: mesmo fundo do corpo do modal */
html.dark [id^="modal"] .rounded-b-2xl.bg-gray-50,
html.dark [id*="Modal"] .rounded-b-2xl.bg-gray-50 {
  background-color: #1e2433 !important;
  border-top: 0.0625rem solid #374151 !important;
}

html.dark [class*="modal"] label,
html.dark [id*="modal"] label,
html.dark [id*="Modal"] label {
  color: #94a3b8 !important;
}

/* ===== Badges ===== */
html.dark .bg-slate-100 {
  background-color: #252d3f !important;
  color: #94a3b8 !important;
}

/* ===== Scrollbar ===== */
html.dark ::-webkit-scrollbar {
  background-color: #0f1117;
}

html.dark ::-webkit-scrollbar-thumb {
  background-color: #374151;
  border-radius: 0.25rem;
}

html.dark ::-webkit-scrollbar-track {
  background-color: #1e2433;
}

/* ===== Toastr notifications ===== */
html.dark #toast-container>div {
  background-color: #1e2433 !important;
  color: #cbd5e1 !important;
  border-color: #374151 !important;
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.4) !important;
}

/* ===== Soft UI Shadow cards ===== */
html.dark .shadow-soft-xl {
  box-shadow: 0 1.25rem 1.6875rem rgba(0, 0, 0, 0.5) !important;
}

html.dark .shadow-soft-2xl {
  box-shadow: 0 1.5625rem 3.125rem rgba(0, 0, 0, 0.5) !important;
}

/* ===== Sidebar nav active item ===== */
html.dark aside a.shadow-soft-xl {
  background-color: #252d3f !important;
}

/* Itens ativos/abertos (marcados via JS) também devem ter o “bloco” */
html.dark aside>div>ul>li>a.pf-nav-active,
html.dark aside>div>ul>li>a.pf-nav-open {
  background-color: #252d3f !important;
}

/* ===== Sidebar nav hover ===== */
html.dark aside .hover\:bg-gray-100:hover {
  background-color: transparent !important;
}

/* ===== Sidebar nav text ===== */
html.dark aside .text-slate-700 {
  color: #cbd5e1 !important;
}

html.dark aside .text-slate-500 {
  color: #94a3b8 !important;
}

/* ===== Sidebar dropdown chevron ===== */
html.dark aside .fa-chevron-down {
  color: #94a3b8 !important;
}

/* ===== Sidebar dropdown sub-items ===== */
html.dark aside ul ul a {
  color: #94a3b8 !important;
}

html.dark aside ul ul a:hover {
  background: linear-gradient(to top left, #7e22ce, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Loading overlay global ===== */
html.dark #global-loading-overlay {
  background: rgba(0, 0, 0, 0.6) !important;
}

html.dark #global-loading-overlay>div {
  background: #1e2433 !important;
  box-shadow: 0 0.625rem 2.5rem rgba(0, 0, 0, 0.5) !important;
}

html.dark #global-loading-overlay>div>div:first-child {
  border-color: #374151 !important;
  border-top-color: #7b3fe4 !important;
}

html.dark #global-loading-text {
  color: #cbd5e1 !important;
}

/* ===== Headings e textos base (Soft UI define color:#344767 para h1-h6) ===== */
html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6 {
  color: #f1f5f9 !important;
}

html.dark p {
  color: #94a3b8;
}

html.dark label {
  color: #94a3b8 !important;
}

html.dark small {
  color: #64748b !important;
}

/* ===== Blog carousel - cores dos slides ===== */
html.dark .blog-slide h5 {
  color: #f1f5f9 !important;
}

html.dark .blog-slide .blog-excerpt {
  color: #cbd5e1 !important;
}

html.dark .blog-slide p[style*="94a3b8"] {
  color: #64748b !important;
}

html.dark .blog-slide hr {
  border-top-color: #374151 !important;
}

html.dark .blog-nav-btn {
  background: rgba(30, 36, 51, 0.94) !important;
  border-color: #374151 !important;
  color: #94a3b8 !important;
}

html.dark .blog-nav-btn:hover {
  background: #252d3f !important;
  color: #f1f5f9 !important;
}

html.dark .blog-dot {
  background: #374151 !important;
}

/* ===== Avatar border em dark mode ===== */
html.dark #avatar-trigger {
  border-color: transparent !important;
  box-shadow: none !important;
}

/* ===== Choices.js dropdown (avatar + outros) ===== */
html.dark .choices__list--dropdown,
html.dark .choices__list[aria-expanded="true"] {
  background-color: #1e2433 !important;
  border-color: #374151 !important;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4) !important;
}

html.dark .choices__item {
  color: #cbd5e1 !important;
}

html.dark .choices__item--selectable.is-highlighted,
html.dark .choices__item--selectable:hover {
  background-color: #252d3f !important;
  color: #f1f5f9 !important;
}

html.dark .choices__inner {
  background-color: #1e2433 !important;
  border-color: #374151 !important;
  color: #f1f5f9 !important;
}

html.dark .choices__placeholder {
  color: #64748b !important;
}

/* ===== Fixed plugin card (configurator) ===== */
html.dark [fixed-plugin-card] {
  background-color: #1e2433 !important;
  color: #cbd5e1 !important;
}

html.dark [fixed-plugin-card] h5,
html.dark [fixed-plugin-card] h6,
html.dark [fixed-plugin-card] p {
  color: #cbd5e1 !important;
}

/* ===== transição suave ao trocar tema =====
   Aplicada apenas durante a troca real do tema (toggle do dark mode).
   Evita que toda mudança de classe utilitária (hover de tabela, abrir menu,
   etc.) dispare transições desnecessárias no documento inteiro. */
html[data-theme-transitioning="true"] body,
html[data-theme-transitioning="true"] body * {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: 0.25s;
  transition-timing-function: ease;
}

/* Exceções que não devem ter transição (performance) */
html[data-theme-transitioning="true"] body * svg,
html[data-theme-transitioning="true"] body * img,
html[data-theme-transitioning="true"] body * canvas,
html[data-theme-transitioning="true"] body * i[class*="fa"],
html[data-theme-transitioning="true"] body * .transition-transform,
html[data-theme-transitioning="true"] body * [class*="translate"],
html[data-theme-transitioning="true"] body * [class*="scale"],
html[data-theme-transitioning="true"] body * [class*="rotate"] {
  transition: none;
}

/* ===== Focus ring global (a11y) =====
   Garante feedback visível para navegação por teclado, mesmo quando o
   utilitário Tailwind `focus:outline-none` é aplicado em formulários.
   `:focus-visible` não dispara em cliques de mouse — só em teclado/AT. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible {
  outline: 0.125rem solid #a855f7;
  outline-offset: 0.125rem;
  border-radius: 0.375rem;
  box-shadow: 0 0 0 0.1875rem rgba(168, 85, 247, 0.18);
}

html.dark a:focus-visible,
html.dark button:focus-visible,
html.dark input:focus-visible,
html.dark select:focus-visible,
html.dark textarea:focus-visible,
html.dark [tabindex]:focus-visible,
html.dark [role="button"]:focus-visible,
html.dark [role="link"]:focus-visible {
  outline-color: #c084fc;
  box-shadow: 0 0 0 0.1875rem rgba(192, 132, 252, 0.22);
}