:root {
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --heading: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, Consolas, monospace;

  font: 15px/145% var(--sans);
  letter-spacing: 0.15px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* TEMA CLARO (LIGHT MODE) */
html.light, body.light, .theme-light {
  color-scheme: light;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border-card: #e2e8f0;
  --border-input: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-accent: #2563eb;
  background-color: var(--bg-page);
  color: var(--text-main);
}

/* TEMA ESCURO (DARK MODE) */
html.dark, body.dark, .theme-dark {
  color-scheme: dark;
  --bg-page: #0b1120;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border-card: #334155;
  --border-input: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-accent: #38bdf8;
  background-color: var(--bg-page);
  color: var(--text-main);
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  /* Garante scroll natural horizontal e vertical sem criar múltiplos contextos aninhados */
  overflow-x: auto;
  overflow-y: auto;
  /* Previne recarregamento acidental por gesto (pull-to-refresh) na raiz do documento em tablets/totens (MDM) */
  overscroll-behavior-y: none;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  /* body com overflow visible permite que eventos de rolagem (wheel/scroll) subam fluidamente para o container html */
  overflow: visible;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ==========================================================================
   BLINDAGEM CONTRA SWIPE-REFRESH NATIVO DO ANDROID (MODO QUIOSQUE)
   Suprime 100% de overscroll, rolagem vertical e pull-to-refresh nativo
   mantendo a rolagem das telas administrativas de RH intacta.
   ========================================================================== */
html.kiosk-mode-active,
body.kiosk-mode-active,
body.kiosk-mode-active #root {
  overflow: hidden !important;
  height: 100% !important;
  min-height: 100% !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
  scrollbar-width: none !important;
  -webkit-overflow-scrolling: auto !important;
  background-color: #060b18 !important;
}

html.kiosk-mode-active::-webkit-scrollbar,
body.kiosk-mode-active::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

html:hover {
  scrollbar-color: rgba(100, 116, 139, 0.6) transparent;
}

.theme-dark html:hover,
.dark html:hover {
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

/* ==========================================================================
   BARRA DE ROLAGEM MINIMALISTA E DISCRETA (AUTO-OCULTÁVEL VERTICAL E HORIZONTAL)
   Suporte ergonômico a Chrome, Edge, Safari, Firefox e Opera
   ========================================================================== */

/* Padrão W3C (Firefox e navegadores modernos) */
.custom-scrollbar-x,
.custom-scrollbar-v,
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.2s ease;
  -webkit-overflow-scrolling: touch;
}

.custom-scrollbar-x {
  overflow: auto;
}

.custom-scrollbar-v {
  overflow-y: auto;
}

.custom-scrollbar {
  overflow: auto;
}

/* Revelação ao passar o cursor sobre a área ou interagir */
.custom-scrollbar-x:hover,
.custom-scrollbar-x:focus-within,
.custom-scrollbar-x:active,
.custom-scrollbar-v:hover,
.custom-scrollbar-v:focus-within,
.custom-scrollbar-v:active,
.custom-scrollbar:hover,
.custom-scrollbar:focus-within,
.custom-scrollbar:active {
  scrollbar-color: rgba(100, 116, 139, 0.6) transparent;
}

.theme-dark .custom-scrollbar-x:hover,
.theme-dark .custom-scrollbar-x:focus-within,
.theme-dark .custom-scrollbar-x:active,
.dark .custom-scrollbar-x:hover,
.theme-dark .custom-scrollbar-v:hover,
.theme-dark .custom-scrollbar-v:focus-within,
.theme-dark .custom-scrollbar-v:active,
.dark .custom-scrollbar-v:hover,
.theme-dark .custom-scrollbar:hover,
.theme-dark .custom-scrollbar:focus-within,
.theme-dark .custom-scrollbar:active,
.dark .custom-scrollbar:hover {
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

/* Scrollbar Minimalista para Webkit (Chrome, Edge, Safari, Brave, Opera) */
.custom-scrollbar-x::-webkit-scrollbar,
.custom-scrollbar-v::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar,
body::-webkit-scrollbar,
html::-webkit-scrollbar {
  width: 7px;
  height: 7px;
  background-color: transparent;
}

.custom-scrollbar-x::-webkit-scrollbar-track,
.custom-scrollbar-v::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
html::-webkit-scrollbar-track {
  background-color: transparent;
}

/* Em repouso: barra 100% invisível (auto-ocultada) */
.custom-scrollbar-x::-webkit-scrollbar-thumb,
.custom-scrollbar-v::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
html::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 9999px;
  transition: background-color 0.2s ease;
}

/* Ao passar o mouse sobre a área: revela suavemente o thumb */
.custom-scrollbar-x:hover::-webkit-scrollbar-thumb,
.custom-scrollbar-x:focus-within::-webkit-scrollbar-thumb,
.custom-scrollbar-x:active::-webkit-scrollbar-thumb,
.custom-scrollbar-v:hover::-webkit-scrollbar-thumb,
.custom-scrollbar-v:focus-within::-webkit-scrollbar-thumb,
.custom-scrollbar-v:active::-webkit-scrollbar-thumb,
.custom-scrollbar:hover::-webkit-scrollbar-thumb,
.custom-scrollbar:focus-within::-webkit-scrollbar-thumb,
.custom-scrollbar:active::-webkit-scrollbar-thumb,
body:hover::-webkit-scrollbar-thumb,
html:hover::-webkit-scrollbar-thumb {
  background-color: rgba(100, 116, 139, 0.6);
}

.custom-scrollbar-x::-webkit-scrollbar-thumb:hover,
.custom-scrollbar-v::-webkit-scrollbar-thumb:hover,
.custom-scrollbar::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
html::-webkit-scrollbar-thumb:hover {
  background-color: rgba(71, 85, 105, 0.9) !important;
}

/* Suporte a Tema Escuro */
.theme-dark .custom-scrollbar-x:hover::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar-x:focus-within::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar-x:active::-webkit-scrollbar-thumb,
.dark .custom-scrollbar-x:hover::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar-v:hover::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar-v:focus-within::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar-v:active::-webkit-scrollbar-thumb,
.dark .custom-scrollbar-v:hover::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar:hover::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar:focus-within::-webkit-scrollbar-thumb,
.theme-dark .custom-scrollbar:active::-webkit-scrollbar-thumb,
.dark .custom-scrollbar:hover::-webkit-scrollbar-thumb,
.theme-dark body:hover::-webkit-scrollbar-thumb,
.theme-dark html:hover::-webkit-scrollbar-thumb,
.dark body:hover::-webkit-scrollbar-thumb,
.dark html:hover::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.45);
}

.theme-dark .custom-scrollbar-x::-webkit-scrollbar-thumb:hover,
.dark .custom-scrollbar-x::-webkit-scrollbar-thumb:hover,
.theme-dark .custom-scrollbar-v::-webkit-scrollbar-thumb:hover,
.dark .custom-scrollbar-v::-webkit-scrollbar-thumb:hover,
.theme-dark .custom-scrollbar::-webkit-scrollbar-thumb:hover,
.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover,
.theme-dark body::-webkit-scrollbar-thumb:hover,
.theme-dark html::-webkit-scrollbar-thumb:hover,
.dark body::-webkit-scrollbar-thumb:hover,
.dark html::-webkit-scrollbar-thumb:hover {
  background-color: rgba(148, 163, 184, 0.75) !important;
}

#root {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* REGRA DE OURO GLOBAL DE CONTRASTE: INPUTS, SELECTS E TEXTAREAS */
select, input, textarea {
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Formulários em containers claros forçam paridade de cores para evitar glitches de dark mode */
.theme-light select,
.theme-light input,
.theme-light textarea,
.folha-a4 select,
.folha-a4 input,
#espelho-modal-wrapper select,
#espelho-modal-wrapper input {
  color-scheme: light !important;
  color: #0f172a !important;
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
}

.theme-light select option,
#espelho-modal-wrapper select option {
  color: #0f172a !important;
  background-color: #ffffff !important;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--heading);
  font-weight: 700;
  margin: 0;
}

p {
  margin: 0;
}
