/* CSS principal do projeto */
/* Variáveis de tema (claro/escuro) e utilitários sem necessidade de build Tailwind */

:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
  --radius: 0.5rem;
  /* Opacidade do overlay dos modais; ajustar por tema */
  --overlay-opacity: 0.45;

  /* Cores semânticas para estados */
  --positive: 142.1 76.2% 36.3%; /* green-600 */
  --negative: 0 84.2% 60.2%; /* red-600 */
  --warning: 43.3 95.5% 75.1%; /* amber-300 */
  --warning-bg: 45 93.3% 96.1%; /* amber-50 */
  --warning-foreground: 35.5 83.6% 41.6%; /* amber-800 */
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 222.2 84% 5.5%;
  --card-foreground: 210 40% 98%;
  --popover: 222.2 84% 5.5%;
  --popover-foreground: 210 40% 98%;
  --primary: 217.2 91.2% 59.8%;
  /* Garantir contraste adequado (texto branco sobre botão primário) */
  --primary-foreground: 210 40% 98%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 210 40% 98%;
  --border: 217.2 32.6% 24%;
  --input: 217.2 32.6% 24%;
  --ring: 212.7 26.8% 83.9%;
  /* Overlay ligeiramente mais forte no modo escuro */
  --overlay-opacity: 0.6;

  /* Cores semânticas para estados */
  --positive: 139.6 65.5% 55.5%; /* green-400 */
  --negative: 0 89.8% 71.2%; /* red-400 */
  --warning: 39.3 94.9% 49.2%; /* amber-700 */
  --warning-bg: 39.3 94.9% 49.2% / 0.2; /* amber-700 com alpha */
  --warning-foreground: 43.3 95.5% 75.1%; /* amber-300 */
}

body { font-family: 'Inter', sans-serif; }

/* Cabeçalho global: fundo claro e texto legível */
header {
  background: hsl(0 0% 100%); /* branco */
  color: hsl(var(--foreground)); /* texto legível em cabeçalho claro */
  border-bottom: 1px solid hsl(var(--border));
  /* separação sutil do conteúdo */
  box-shadow: 0 1px 0 rgba(16,24,40,0.03);
  /* mantém contexto de empilhamento para modais acima */
  position: sticky;
  top: 0;
  z-index: 30;
}

/* Em modo escuro, o cabeçalho usa a cor do card mas mantém bom contraste */
.dark header {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
}

/* Variação do cabeçalho para a página inicial */
.header-home { background: hsl(0 0% 100%); border-bottom: 1px solid hsl(var(--border)); }
.header-home h1, .header-home #main-header-title { color: hsl(var(--foreground)); }

/* Sombra ligeiramente mais forte na variação home */
.header-home { box-shadow: 0 1px 0 rgba(16,24,40,0.04); }

/* Utilitários semânticos de superfície e texto (derivados de tokens) */
.bg-surface { background: hsl(var(--card)); }
.bg-subtle { background: hsl(var(--muted) / 0.35); }
.bg-elevated { background: hsl(var(--card)); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.08); }
.text-default { color: hsl(var(--foreground)); }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-subtle { color: hsl(var(--muted-foreground) / 0.75); }
.border-default { border-color: hsl(var(--border)); }
.card-base { background: hsl(var(--card)); border:1px solid hsl(var(--border)); border-radius: var(--radius); }
.card-interactive { transition: all .18s ease; }
.card-interactive:hover { border-color: hsl(var(--primary)); background: hsl(var(--accent) / 0.35); }
.divider { height:1px; background: hsl(var(--border)); width:100%; }
.heading-hero { font-weight:700; letter-spacing:-0.025em; }
@media (min-width:768px){ .heading-hero { font-size:2.5rem; line-height:1.15; } }
@media (min-width:1024px){ .heading-hero { font-size:3rem; } }
.prose-tight { max-width:65ch; }

/* Ajustes finos do modo escuro para novos utilitários */
.dark .card-interactive:hover { background: hsl(var(--accent) / 0.25); }

/* Utilitários para estados semânticos */
.text-positive { color: hsl(var(--positive)); }
.text-negative { color: hsl(var(--negative)); }
.alert-warning {
  padding: 0.5rem;
  border-radius: var(--radius);
  background-color: hsl(var(--warning-bg));
  border: 1px solid hsl(var(--warning));
  color: hsl(var(--warning-foreground));
}
.alert-warning ul {
  font-size: 0.75rem;
  line-height: 1rem;
  list-style-position: inside;
}

/* Inputs base */
.input { display:block; height:2.5rem; width:100%; border:1px solid hsl(var(--input)); background:hsl(var(--background)); border-radius:0.5rem; padding:0.5rem 0.75rem; font-size:0.875rem; line-height:1.25rem; color:hsl(var(--foreground)); }
.input:focus-visible { outline:2px solid hsl(var(--ring)); outline-offset:2px; }
.input:disabled { opacity:.5; cursor:not-allowed; }
.input.input-error { border-color: rgb(239 68 68); box-shadow: 0 0 0 2px rgba(239,68,68,.15); }

/* Switch */
.switch { position:relative; display:inline-flex; height:1.5rem; width:2.75rem; cursor:pointer; border-radius:9999px; background: hsl(var(--input)); border:2px solid transparent; transition: background .2s ease; appearance:none; }
.switch::before { content:''; position:absolute; left:4px; top:50%; transform:translateY(-50%); width:1.25rem; height:1.25rem; background:#fff; border-radius:9999px; box-shadow:0 1px 2px rgba(0,0,0,.3); transition: transform .2s ease; }
.switch:checked { background:hsl(var(--primary)); }
.switch:checked::before { transform: translateY(-50%) translateX(1rem); }

/* Animação de aparição (fade-in) */
@keyframes fadeIn { from { opacity:0; transform:translateY(10px);} to { opacity:1; transform:translateY(0);} }
.animate-fade-in { animation: fadeIn .5s ease-out forwards; }

/* Utilitários de modal que seguem os tokens do tema */
/* CSS principal do projeto */
/* Variáveis de tema (claro/escuro) e utilitários — instruções rápidas */

/* Força o empilhamento do modal sobre o cabeçalho e outros elementos */
#app-modal-root { position: fixed; inset: 0; z-index: 9990; }
#app-modal-root .modal-backdrop { z-index: 9990; }
/* Cartão do modal fica acima do backdrop */
#app-modal-root #app-modal-card { z-index: 9999; }
/* Garante que o conteúdo do modal se alinhe com o preenchimento do cabeçalho */
#app-modal-content { padding-left: 1.5rem; padding-right: 1.5rem; }

/* Skeleton Loader */
.skeleton { position:relative; overflow:hidden; background-color:hsl(var(--muted) / 0.55); border-radius:0.375rem; }
.skeleton::after { content:''; position:absolute; inset:0; background:linear-gradient(90deg, transparent, hsl(var(--muted) / 0.9), transparent); animation: skeleton-shimmer 1.2s infinite; }
@keyframes skeleton-shimmer { 0% { transform:translateX(-100%);} 100% { transform:translateX(100%);} }

/* Valores monetários */
.valor-monetario { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-variant-numeric: tabular-nums; text-align:right; display:inline-block; min-width:90px; }

/* Totalizadores */
.totalizador { font-size:1.05rem; font-weight:600; letter-spacing:-0.5px; }
@media (min-width:768px){ .totalizador { font-size:1.2rem; } }

/* Blocos de seção */
.section-block { border-radius:0.5rem; padding:0.75rem 0.85rem; background: hsl(var(--muted) / 0.4); border:1px solid hsl(var(--border)); }

/* Utilitário para Gráfico de Donut */
.donut-chart { width:10rem; height:10rem; position:relative; margin:0.5rem auto 0 auto; }
.donut-legend-item { display:flex; align-items:center; justify-content:space-between; font-size:11px; gap:0.5rem; }
.donut-legend-color { width:0.75rem; height:0.75rem; border-radius:0.125rem; display:inline-block; }

/* Container auxiliar de alinhamento para linhas */
.row-pair { display:flex; justify-content:space-between; gap:0.75rem; font-size:0.7rem; line-height:1rem; }
@media (min-width:768px){ .row-pair { font-size:0.8rem; } }
.row-pair > span:first-child { flex:1 1 auto; }
.row-pair > span:last-child { flex:0 0 auto; }

/* Estado Vazio */
.empty-state { text-align:center; padding:1.5rem 1rem; font-size:0.85rem; color:hsl(var(--muted-foreground)); }
.empty-state .icon { display:inline-flex; width:2.5rem; height:2.5rem; border-radius:9999px; align-items:center; justify-content:center; background:hsl(var(--muted) / 0.6); color:hsl(var(--foreground)); margin-bottom:0.5rem; }

/* Botões */
.btn { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  gap: 0.5rem; 
  border-radius: 0.5rem; 
  font-size: 0.875rem; 
  padding: 0.5rem 1rem; 
  transition: all 0.15s ease; 
  cursor: pointer; 
  border: 1px solid transparent; 
  text-decoration: none; 
  white-space: nowrap;
}

.btn:disabled { 
  opacity: 0.5; 
  cursor: not-allowed; 
}

.btn-primary { 
  background: hsl(var(--primary)); 
  color: hsl(var(--primary-foreground)); 
  border-color: hsl(var(--primary)); 
}

.btn-primary:hover:not(:disabled) { 
  background: hsl(var(--primary) / 0.9); 
  border-color: hsl(var(--primary) / 0.9); 
}

.btn-secondary { 
  background: hsl(var(--secondary)); 
  color: hsl(var(--secondary-foreground)); 
  border-color: hsl(var(--border)); 
}

.btn-secondary:hover:not(:disabled) { 
  background: hsl(var(--secondary) / 0.8); 
  border-color: hsl(var(--border)); 
}

/* Container de botões para ações */
.button-actions { 
  display: flex; 
  justify-content: flex-end; 
  align-items: center; 
  gap: 0.5rem; 
  margin-top: 1.5rem; 
}

/* Efeitos de hover para os cards da calculadora */
.calculator-card {
  transition: all 0.2s ease;
}

.calculator-card:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  transform: translateY(-1px);
}

/* Estilos específicos da página inicial */
.home-welcome {
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--secondary)) 100%);
}

/* Destaque do resultado da calculadora rápida */
.quick-result-highlight {
  background: linear-gradient(135deg, hsl(var(--accent) / 0.5) 0%, hsl(var(--accent)) 100%);
  border: 1px solid hsl(var(--border));
}

/* Comportamento da sidebar em dispositivos móveis */
@media (max-width: 639px) {
  #main-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 80%;
    max-width: 18rem;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
    display: flex !important;
    background: hsl(var(--card));
    box-shadow: 2px 0 12px rgba(0,0,0,.2);
  }
  #main-sidebar[data-open="1"] {
    transform: translateX(0);
  }
  #mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 40;
  }
}

/* Estilos para <details>/<summary> da sidebar */
#sidebar-nav-list { overflow-y: auto; }
#sidebar-nav-list details { margin-top: .5rem; }
#sidebar-nav-list summary { user-select: none; }
#sidebar-nav-list summary::-webkit-details-marker { display: none; }
#sidebar-nav-list details[open] > summary .chevron { transform: rotate(180deg); }
#sidebar-nav-list summary .chevron { transition: transform .2s ease; }
#sidebar-nav-list details > div { padding-left: .25rem; }

/* This targets common Tailwind utility classes used in the HTML
   and scopes the increase so it only affects elements inside
   `#calculator-panels-container`. We add slightly larger values
   for p-4, p-6, p-8 and their directional variants. */
   
#calculator-panels-container :where(.p-4, .px-4, .py-4) {
  padding-bottom: calc(1rem * 1.3) !important;
  padding-left: calc(1rem * 1.3) !important;
  padding-right: calc(1rem * 1.3) !important;
}
#calculator-panels-container :where(.p-6, .px-6, .py-6) {
  padding-bottom: calc(1.5rem * 1.3) !important;
  padding-left: calc(1.5rem * 1.3) !important;
  padding-right: calc(1.5rem * 1.3) !important;
}
#calculator-panels-container :where(.p-8, .px-8, .py-8) {
  padding-bottom: calc(2rem * 1.3) !important;
  padding-left: calc(2rem * 1.3) !important;
  padding-right: calc(2rem * 1.3) !important;
}

/* Also increase padding for container utility and card-base inside calculators */
#calculator-panels-container .container,
#calculator-panels-container .card-base {
  padding: calc(1rem * 1.3) !important;
}

