/* ==========================================================================
   NWallet - Design System Refinements & Bespoke Component Engine
   - Menus Suspensos (Custom Dropdowns / Selects)
   - Check Box (Universal Custom Checkboxes)
   - Calendário & Agenda Financeira (Refinamentos Visuais)
   - Data e Hora (Pickers customizados)
   - Scroll 100% Invisível Global
   - Emojis substituídos por Ícones SVG
   - Tooltips Originais do Sistema (Substituindo padrão do navegador)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Universal Invisible Scroll Engine (Global across all screens & viewports)
   -------------------------------------------------------------------------- */
html, body, #root, *, *::before, *::after {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

*::-webkit-scrollbar,
html::-webkit-scrollbar,
body::-webkit-scrollbar,
#root::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

/* --------------------------------------------------------------------------
   2. Menus Suspensos (Bespoke Select Dropdown Components)
   -------------------------------------------------------------------------- */
select,
.nf-field select,
.nw-entry-panel select,
#root select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-color: rgba(255, 255, 255, 0.045) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2381c784' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px 16px !important;
  padding-left: 14px !important;
  padding-right: 42px !important;
  min-height: 44px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 14px !important;
  color: #f4f7fb !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease !important;
  outline: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
  color-scheme: dark !important;
}

select:hover,
.nf-field select:hover,
.nw-entry-panel select:hover,
#root select:hover {
  border-color: rgba(129, 199, 132, 0.5) !important;
  background-color: rgba(129, 199, 132, 0.06) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) !important;
}

select:focus,
select:focus-visible,
.nf-field select:focus,
.nw-entry-panel select:focus,
#root select:focus {
  border-color: #52b753 !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 0 0 3px rgba(82, 183, 83, 0.28) !important;
  outline: none !important;
}

select option {
  background-color: #0d121d !important;
  color: #f4f7fb !important;
  padding: 12px 14px !important;
  font-size: 14px !important;
}

select option:checked,
select option:hover {
  background-color: #1a2538 !important;
  color: #81c784 !important;
}

/* Light Theme Dropdown Menus */
.nf-theme[data-theme="light"] select,
[data-theme="light"] select {
  background-color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23287b34' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  border-color: rgba(12, 51, 29, 0.2) !important;
  color: #173d27 !important;
  color-scheme: light !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

.nf-theme[data-theme="light"] select option,
[data-theme="light"] select option {
  background-color: #ffffff !important;
  color: #173d27 !important;
}

/* --------------------------------------------------------------------------
   3. Check Box (Universal Custom Checkboxes)
   -------------------------------------------------------------------------- */
input[type="checkbox"],
.nw-checkbox {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  border-radius: 7px !important;
  background-color: rgba(255, 255, 255, 0.05) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.22) !important;
  cursor: pointer !important;
  position: relative !important;
  display: inline-grid !important;
  place-content: center !important;
  vertical-align: middle !important;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) !important;
  outline: none !important;
  margin: 0 !important;
}

input[type="checkbox"]:hover,
.nw-checkbox:hover {
  border-color: rgba(82, 183, 83, 0.6) !important;
  background-color: rgba(82, 183, 83, 0.08) !important;
  box-shadow: 0 0 10px rgba(82, 183, 83, 0.2) !important;
}

input[type="checkbox"]:checked,
.nw-checkbox.checked {
  background-color: #52b753 !important;
  border-color: #52b753 !important;
  box-shadow: 0 2px 10px rgba(82, 183, 83, 0.45) !important;
}

input[type="checkbox"]:checked::after,
.nw-checkbox.checked::after {
  content: "" !important;
  width: 5px !important;
  height: 10px !important;
  border: solid #05080d !important;
  border-width: 0 2.5px 2.5px 0 !important;
  transform: rotate(45deg) translate(-0.5px, -1px) !important;
  display: block !important;
}

input[type="checkbox"]:indeterminate::after {
  content: "" !important;
  width: 10px !important;
  height: 2.5px !important;
  background-color: #05080d !important;
  border-radius: 1px !important;
  display: block !important;
}

input[type="checkbox"]:focus-visible,
.nw-checkbox:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(82, 183, 83, 0.35) !important;
  border-color: #52b753 !important;
}

input[type="checkbox"]:disabled,
.nw-checkbox.disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
}

/* --------------------------------------------------------------------------
   4. Data e Hora (Date, Time, Month Picker Inputs)
   -------------------------------------------------------------------------- */
input[type="date"],
input[type="time"],
input[type="month"],
input[type="datetime-local"] {
  min-height: 44px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 14px !important;
  background-color: rgba(255, 255, 255, 0.045) !important;
  color: #f4f7fb !important;
  padding: 10px 14px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color-scheme: dark !important;
  transition: all 0.2s ease !important;
  outline: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

input[type="date"]:hover,
input[type="time"]:hover,
input[type="month"]:hover,
input[type="datetime-local"]:hover {
  border-color: rgba(129, 199, 132, 0.5) !important;
  background-color: rgba(129, 199, 132, 0.06) !important;
}

input[type="date"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
input[type="datetime-local"]:focus {
  border-color: #52b753 !important;
  box-shadow: 0 0 0 3px rgba(82, 183, 83, 0.28) !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Custom Calendar & Time Picker Indicator Icons */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer !important;
  opacity: 0.78 !important;
  filter: invert(0.85) sepia(1) saturate(5) hue-rotate(85deg) !important;
  padding: 4px !important;
  border-radius: 6px !important;
  transition: opacity 0.15s ease, transform 0.15s ease !important;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1 !important;
  transform: scale(1.15) !important;
}

/* Light Mode Date & Time */
.nf-theme[data-theme="light"] input[type="date"],
.nf-theme[data-theme="light"] input[type="time"],
.nf-theme[data-theme="light"] input[type="month"],
[data-theme="light"] input[type="date"],
[data-theme="light"] input[type="time"],
[data-theme="light"] input[type="month"] {
  background-color: #ffffff !important;
  border-color: rgba(12, 51, 29, 0.2) !important;
  color: #173d27 !important;
  color-scheme: light !important;
}

.nf-theme[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
.nf-theme[data-theme="light"] input[type="time"]::-webkit-calendar-picker-indicator,
.nf-theme[data-theme="light"] input[type="month"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="light"] input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(0.35) sepia(1) saturate(5) hue-rotate(85deg) !important;
}

/* --------------------------------------------------------------------------
   5. Calendário & Agenda Financeira (Refinamentos Visuais)
   -------------------------------------------------------------------------- */
[data-selected="true"] {
  box-shadow: 0 10px 25px -4px rgba(82, 183, 83, 0.45), 0 0 0 2px #52b753 !important;
}

/* --------------------------------------------------------------------------
   6. Original System Tooltip Engine (Substituindo padrão do navegador)
   -------------------------------------------------------------------------- */
.nw-system-tooltip {
  position: fixed !important;
  z-index: 999999 !important;
  pointer-events: none !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.96);
  transform-origin: center bottom;
  transition: opacity 0.14s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.14s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.14s ease !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  max-width: 290px !important;
  padding: 6px 12px !important;
  border-radius: 10px !important;
  background: rgba(13, 18, 29, 0.94) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-top-color: rgba(129, 199, 132, 0.45) !important;
  color: #f4f7fb !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  letter-spacing: 0.02em !important;
  text-align: center !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(82, 183, 83, 0.15) !important;
  will-change: transform, opacity !important;
}

.nw-system-tooltip.nw-tooltip-visible {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
}

.nw-system-tooltip.nw-tooltip-bottom {
  transform: translateY(-4px) scale(0.96);
  transform-origin: center top;
}
.nw-system-tooltip.nw-tooltip-bottom.nw-tooltip-visible {
  transform: translateY(0) scale(1) !important;
}

.nw-tooltip-arrow {
  position: absolute !important;
  width: 8px !important;
  height: 8px !important;
  background: rgba(13, 18, 29, 0.94) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  transform: rotate(45deg) !important;
  pointer-events: none !important;
}

.nw-system-tooltip:not(.nw-tooltip-bottom) .nw-tooltip-arrow {
  bottom: -5px !important;
  border-top: none !important;
  border-left: none !important;
}

.nw-system-tooltip.nw-tooltip-bottom .nw-tooltip-arrow {
  top: -5px !important;
  border-bottom: none !important;
  border-right: none !important;
  border-top-color: rgba(129, 199, 132, 0.45) !important;
}

/* Light mode tooltips */
.nf-theme[data-theme="light"] ~ .nw-system-tooltip,
[data-theme="light"] .nw-system-tooltip {
  background: rgba(255, 255, 255, 0.96) !important;
  color: #173d27 !important;
  border-color: rgba(12, 51, 29, 0.15) !important;
  border-top-color: #52b753 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(82, 183, 83, 0.2) !important;
}

.nf-theme[data-theme="light"] ~ .nw-system-tooltip .nw-tooltip-arrow,
[data-theme="light"] .nw-system-tooltip .nw-tooltip-arrow {
  background: rgba(255, 255, 255, 0.96) !important;
  border-color: rgba(12, 51, 29, 0.15) !important;
}

/* --------------------------------------------------------------------------
   7. Inline SVG Icons (Substituição de Emojis)
   -------------------------------------------------------------------------- */
.nw-icon-replaced {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  vertical-align: -0.15em !important;
  line-height: 1 !important;
  margin: 0 0.15em !important;
}

.nw-icon-replaced svg {
  width: 1.15em !important;
  height: 1.15em !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

/* --------------------------------------------------------------------------
   8. Existing Layout, Focus & Responsive Refinements
   -------------------------------------------------------------------------- */
#root button:focus-visible,
#root [role="button"]:focus-visible { outline: 2px solid #81c784; outline-offset: 4px; }
#root input:focus-visible,
#root select:focus-visible,
#root textarea:focus-visible { outline: 2px solid #81c784; outline-offset: 4px; border-radius: 6px; }
.nw-amount-expense { color: #f29a9a !important; }
.nw-amount-income { color: #81c784 !important; }

@media (min-width: 768px) {
  .desktop-shell [class~="md:grid-cols-2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-shell [class~="md:grid-cols-4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desktop-container { padding-bottom: 3rem !important; }
  .desktop-grid { gap: 1.5rem !important; }
  .desktop-grid > div,
  .desktop-card > [class~="grid"] > div { min-width: 0; }
  .desktop-card [class~="text-zinc-400"],
  .desktop-card [class~="text-gray-400"] { color: #a6afbd; }
  .desktop-card [class~="text-white/40"] { color: #9ba5b4; }
  .desktop-card [class~="text-[9px]"] { font-size: 10px; }
  .desktop-topbar nav button,
  .desktop-topbar > div:last-child > button { min-height: 42px; }
  .desktop-topbar > div:last-child > div { max-width: 160px; min-height: 42px; }
  .desktop-topbar > div:last-child > div > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}

@media (min-width: 1200px) {
  .desktop-shell [class~="md:grid-cols-4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 1099px) {
  .desktop-topbar { flex-wrap: wrap; gap: 14px; padding: 16px 24px !important; }
  .desktop-topbar > nav { order: 3; flex-basis: 100%; justify-content: center; }
  .desktop-topbar nav button { flex: 1; justify-content: center; padding-left: 12px; padding-right: 12px; }
  .desktop-container { padding: 24px 24px 48px !important; }
  .desktop-grid > div:last-child { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* Keep the existing entry sheet, with readable labels and bounded scrolling */
.nw-entry-panel { max-height: calc(100dvh - 24px); }
.nw-entry-panel > div:has(> form) { min-height: 0; overscroll-behavior: contain; }
.nw-entry-panel label { font-size: 11px; opacity: .76; letter-spacing: .09em; }
.nw-entry-panel input::placeholder { opacity: .5; }
.nw-entry-panel form input,
.nw-entry-panel form select { min-height: 44px; }
.nw-entry-panel form input[type="number"] { font-variant-numeric: tabular-nums; font-size: clamp(40px, 12vw, 56px) !important; }
.nw-entry-panel form button { min-height: 40px; }
.nw-entry-panel [data-nw-close] { min-width: 40px; min-height: 40px; }
.nw-entry-panel form [class~="grid-cols-2"] { gap: 20px; }
.nw-entry-panel form[class~="space-y-10"] > :not(:first-child) { margin-top: 28px; }

@media (min-width: 768px) {
  .nw-entry-overlay { position: fixed !important; inset: 0 !important; align-items: center !important; padding: 24px; }
  .nw-entry-panel { width: min(520px, 100%) !important; max-width: 520px !important; height: min(810px, calc(100dvh - 48px)) !important; border-radius: 32px !important; border: 1px solid rgba(255,255,255,.1); }
}

@media (max-width: 767px) {
  #root header h1 { min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
  #root header > div { min-width: 0; }
  #root header > button { flex-shrink: 0; }
  #root #notif-btn,
  #root #add-card { min-width: 40px; min-height: 40px; }
  #root #expense-action,
  #root #income-action,
  #root #import-action { min-height: 72px; }
  #root [class~="text-gray-400"] { color: #9ba5b4; }
  .nw-mobile-dock { width: calc(100% - 32px) !important; max-width: 350px !important; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important; }
  .nw-mobile-dock > div { height: 56px; }
  .nw-mobile-dock button[data-nav-label] { height: 54px; flex-direction: column; gap: 3px; }
  .nw-mobile-dock button[data-nav-label]::after { content: attr(data-nav-label); font-size: 9px; line-height: 12px; font-weight: 600; letter-spacing: .01em; position: relative; z-index: 1; }
  .nw-mobile-dock button[aria-current="page"]::after { color: #81c784; }
  .nw-mobile-dock button[aria-current="page"] > .absolute { width: 36px; height: 36px; top: 2px; }
  .nw-mobile-dock button[data-nav-label]::after { white-space: nowrap; }
  #root svg[viewBox="0 0 280 140"] { max-width: calc(100vw - 48px); height: auto; }
  .nw-entry-panel { height: min(90dvh, 850px) !important; }
  .nw-entry-panel > div:has(> form) { padding-left: 24px; padding-right: 24px; padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 359px) {
  #root header h1 { font-size: 15px; }
  .nw-mobile-dock { width: calc(100% - 24px) !important; }
  .nw-entry-panel > div:has(> form) { padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  #root *, #root *::before, #root *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
