/**
 * FGS — temas de cor.
 * Theme 1: visual FacturGrade Web clássico (navy próprio).
 * Theme 2: consola escura estilo Plataforma (fase 1 — CSS only): fundo slate-950, cartões slate-900.
 *          Detalhe em fgs-theme-2-dark.css (injectado por fgs-theme.js após DOM).
 * fgs-theme.js: html[data-fgs-theme="1"|"2"] + localStorage fgs_theme_id.
 */

html,
html[data-fgs-theme="1"] {
  --fgs-theme-label: "Clássico FGS";
  --fgs-page-bg: #f1f5f9;
  --fgs-header-g1: #0b1220;
  --fgs-header-g2: #0f1b33;
  --fgs-header-g3: #152a50;
  --fgs-offcanvas-g1: #0b1220;
  --fgs-offcanvas-g2: #0f1b33;
  --fgs-client-gray-50: #f8fafc;
  --fgs-client-gray-100: #f1f5f9;
  --fgs-client-primary: #1d4ed8;
}

html[data-fgs-theme="2"] {
  --fgs-theme-label: "Consola escura";
  --fgs-page-bg: #020617;
  --fgs-header-g1: #020617;
  --fgs-header-g2: #0f172a;
  --fgs-header-g3: #1e293b;
  --fgs-offcanvas-g1: #020617;
  --fgs-offcanvas-g2: #0f172a;
  --fgs-client-gray-50: #0f172a;
  --fgs-client-gray-100: #020617;
  --fgs-surface: #0f172a;
  --fgs-surface-muted: #1e293b;
  --fgs-border: #334155;
  --fgs-text: #e2e8f0;
  --fgs-text-muted: #94a3b8;
  --fgs-card-bg: #0a1628;
  --fgs-card-border: rgb(100 116 139 / 0.38);
  --fgs-card-border-hover: rgb(147 197 253 / 0.55);
  --fgs-depth-1-bg: #0a1628;
  --fgs-depth-1-border: rgb(100 116 139 / 0.38);
  --fgs-depth-2-bg: #122038;
  --fgs-depth-2-border: rgb(148 163 184 / 0.4);
  --fgs-depth-3-bg: #1a2d4a;
  --fgs-depth-3-border: rgb(148 163 184 / 0.48);
  --fgs-depth-4-bg: #243754;
  --fgs-depth-4-border: rgb(186 196 210 / 0.38);
  --fgs-search-bg: #f8fafc;
  --fgs-search-border: #cbd5e1;
  --fgs-search-text: #0f172a;
  --fgs-client-primary: #2563eb;
  --navy-950: #020617;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --primary: #2563eb;
}

/* Theme 2: utilitários Tailwind «navy» → tons slate (fundos escuros + texto claro) */
html[data-fgs-theme="2"] .text-navy-900,
html[data-fgs-theme="2"] .text-navy-800 {
  color: #f1f5f9 !important;
}
html[data-fgs-theme="2"] .text-navy-950 {
  color: #e2e8f0 !important;
}
html[data-fgs-theme="2"] .text-navy-700 {
  color: #cbd5e1 !important;
}
html[data-fgs-theme="2"] .bg-navy-900 {
  background-color: #0f172a !important;
}
html[data-fgs-theme="2"] .bg-navy-800 {
  background-color: #1e293b !important;
}
html[data-fgs-theme="2"] .bg-navy-950 {
  background-color: #020617 !important;
}
html[data-fgs-theme="2"] .bg-navy-700\/80 {
  background-color: rgb(51 65 85 / 0.88) !important;
}
html[data-fgs-theme="2"] .hover\:bg-navy-800:hover {
  background-color: #334155 !important;
}
html[data-fgs-theme="2"] .hover\:bg-navy-900:hover {
  background-color: #1e293b !important;
}
html[data-fgs-theme="2"] .hover\:from-navy-700:hover {
  --tw-gradient-from: #334155 var(--tw-gradient-from-position) !important;
}
html[data-fgs-theme="2"] .hover\:to-navy-900:hover {
  --tw-gradient-to: #0f172a var(--tw-gradient-to-position) !important;
}
html[data-fgs-theme="2"] .from-navy-800 {
  --tw-gradient-from: #1e293b var(--tw-gradient-from-position) !important;
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-via, transparent), var(--tw-gradient-to) !important;
}
html[data-fgs-theme="2"] .to-navy-950 {
  --tw-gradient-to: #020617 var(--tw-gradient-to-position) !important;
}
html[data-fgs-theme="2"] .border-navy-800 {
  border-color: #1e293b !important;
}
html[data-fgs-theme="2"] .border-navy-900\/15 {
  border-color: rgb(15 23 42 / 0.15) !important;
}
html[data-fgs-theme="2"] .border-navy-900\/10 {
  border-color: rgb(15 23 42 / 0.1) !important;
}
html[data-fgs-theme="2"] .ring-navy-900\/10 {
  --tw-ring-color: rgb(15 23 42 / 0.1) !important;
}
html[data-fgs-theme="2"] .shadow-navy-900\/20 {
  --tw-shadow-color: #0f172a !important;
}
html[data-fgs-theme="2"] .shadow-navy-900\/25 {
  --tw-shadow-color: #0f172a !important;
}
html[data-fgs-theme="2"] body.text-slate-800,
html[data-fgs-theme="2"] body.fgs-painel-page {
  color: var(--fgs-text, #e2e8f0);
}

.fgs-app-bg {
  background-color: var(--fgs-page-bg) !important;
}

.fgs-header-gradient {
  background-image: linear-gradient(
    to right,
    var(--fgs-header-g1),
    var(--fgs-header-g2),
    var(--fgs-header-g3)
  ) !important;
  background-color: var(--fgs-header-g2);
  height: 110px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/** Rodapé global — mesmo degradê que o cabeçalho (temas 1 e 2). */
footer.fgs-footer-bar {
  background-image: linear-gradient(
    to right,
    var(--fgs-header-g1),
    var(--fgs-header-g2),
    var(--fgs-header-g3)
  ) !important;
  background-color: var(--fgs-header-g2);
}

header.fgs-header-gradient > :first-child {
  min-height: 62px;
  max-height: 62px;
  display: flex;
  align-items: center;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
header.fgs-header-gradient [data-fgs-nav-toolbar] {
  min-height: 46px;
  max-height: none;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  align-items: center;
  overflow: visible;
}
header.fgs-header-gradient > :first-child h1 {
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/**
 * Nav no header — alinhar páginas com links Tailwind (rounded-md bg-white/10)
 * ao Painel (index.html: .fgs-nav-tab + barra ciano).
 */
header.fgs-header-gradient [data-fgs-nav-toolbar] nav a.rounded-md {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid transparent !important;
  border-bottom: 3px solid transparent !important;
  border-radius: 0.5rem 0.5rem 0 0 !important;
  text-decoration: none !important;
  font-weight: 500 !important;
  color: rgba(255, 255, 255, 0.88) !important;
}
header.fgs-header-gradient [data-fgs-nav-toolbar] nav a.rounded-md:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}
header.fgs-header-gradient [data-fgs-nav-toolbar] nav span[aria-current='page'],
header.fgs-header-gradient [data-fgs-nav-toolbar] nav a.rounded-md[aria-current='page'] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid transparent !important;
  border-bottom: 3px solid #67e8f9 !important;
  border-radius: 0.5rem 0.5rem 0 0 !important;
  font-weight: 600 !important;
  color: #fff !important;
  box-shadow: none !important;
}
header.fgs-header-gradient [data-fgs-nav-toolbar] button#btnSair {
  background: transparent !important;
  color: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.42) !important;
  box-shadow: none !important;
}
header.fgs-header-gradient [data-fgs-nav-toolbar] button#btnSair:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.65) !important;
  color: #fff !important;
}
header.fgs-header-gradient button#btnPdvKiosk {
  background: rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  box-shadow: none !important;
}
header.fgs-header-gradient button#btnPdvKiosk:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.55) !important;
  color: #fff !important;
}
header.fgs-header-gradient button#btnPdvKiosk[aria-pressed='true'],
header.fgs-header-gradient button#btnPdvKiosk.bg-white\/20 {
  background: rgba(255, 255, 255, 0.22) !important;
  border-color: rgba(103, 232, 249, 0.65) !important;
}

.fgs-offcanvas-panel {
  background-image: linear-gradient(to bottom, var(--fgs-offcanvas-g1), var(--fgs-offcanvas-g2)) !important;
  background-color: var(--fgs-offcanvas-g2);
}

/**
 * Moldura lateral fina (1px) — mesma cor-base que o degradê do cabeçalho / rodapé (`--fgs-header-g3`).
 */
body {
  min-height: 100vh;
  box-sizing: border-box;
  border-inline: 1px solid var(--fgs-header-g3, #152a50);
}

/* Theme 2 — utilitários de cascata (camada explícita) */
html[data-fgs-theme="2"] .fgs-depth-1,
html[data-fgs-theme="2"] .fgs-cascade-1 {
  background-color: var(--fgs-depth-1-bg) !important;
  border: 1px solid var(--fgs-depth-1-border) !important;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.28);
}

html[data-fgs-theme="2"] .fgs-depth-2,
html[data-fgs-theme="2"] .fgs-cascade-2 {
  background-color: var(--fgs-depth-2-bg) !important;
  border: 1px solid var(--fgs-depth-2-border) !important;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.03);
}

html[data-fgs-theme="2"] .fgs-depth-3,
html[data-fgs-theme="2"] .fgs-cascade-3 {
  background-color: var(--fgs-depth-3-bg) !important;
  border: 1px solid var(--fgs-depth-3-border) !important;
}

html[data-fgs-theme="2"] .fgs-depth-4,
html[data-fgs-theme="2"] .fgs-cascade-4 {
  background-color: var(--fgs-depth-4-bg) !important;
  border: 1px solid var(--fgs-depth-4-border) !important;
}

/* Logótipo FGS — cabeçalhos internos do backoffice */
.fgs-brand-logo-header {
  flex-shrink: 0;
  object-fit: contain;
}

/* Tenant com logo: [FGS] | [logo] Nome (inject via fgs-tenant-logo.js) */
header.fgs-header-gradient img[data-fgs-brand-logo-img] {
  flex-shrink: 0;
}
