/* GestorEasy v3 - Tema padrão */
:root {
  /* Paleta base */
  --color-black: #1c1c1c;
  --color-orange: #ff6a00;
  --color-olive: #556b2f;
  --color-white: #ffffff;

  /* Novas cores de destaque (Dashboard v2) */
  --color-revenue-blue: #1f6feb; /* Receitas */
  --color-expense-red: #dc2626;  /* Despesas */
  --color-neutral-gray: #eef2f7;
  --color-card-bg: #ffffff;
  --shadow-strong: 0 10px 30px rgba(0,0,0,0.12);

  /* Derivados e utilitários */
  --text-on-dark: var(--color-white);
  --text-on-light: var(--color-black);
  --border-muted: rgba(0,0,0,0.1);

  /* Gradientes padrão */
  --gradient-primary: linear-gradient(135deg, var(--color-orange) 0%, var(--color-olive) 100%);
  --gradient-warm: linear-gradient(135deg, #ff8c1a 0%, #ff6a00 60%, #ff3b00 100%);
  --gradient-olive: linear-gradient(135deg, #6a7b3b 0%, #556b2f 70%, #3f4f1f 100%);
}

html, body { height: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text-on-light);
  background: var(--color-white);
}

/* Navegação principal: padronização visual e ícones inline */
nav .nav { display:flex; gap: 8px; align-items:center; }
.nav .dropdown > button {
  background: transparent; border: none; color: var(--text-on-light);
  font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.nav .dropdown > button:hover { background: rgba(0,0,0,0.05); }
.nav .dropdown .dropdown-menu { padding: 8px 0; }
.nav .dropdown .dropdown-item { color: var(--text-on-light); padding: 8px 12px; display:block; text-decoration:none; }
.nav .dropdown .dropdown-item:hover { background: rgba(255,106,0,0.12); color: var(--color-orange); }
.menu-icon svg { width: 20px; height: 20px; margin-right: 8px; vertical-align: middle; color: var(--color-olive); }


/* Containers de fundo */
.bg-light { background: var(--color-white); color: var(--text-on-light); }
.bg-dark  { background: var(--color-black); color: var(--text-on-dark); }
.bg-gradient { background: var(--gradient-primary); color: var(--text-on-dark); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
/* Suporte a spans de coluna baseados em classes col-* (similar ao grid de 12 colunas)
   Mantém compatibilidade com o markup existente nas views */
.grid > .col-1 { grid-column: span 1; }
.grid > .col-2 { grid-column: span 2; }
.grid > .col-3 { grid-column: span 3; }
.grid > .col-4 { grid-column: span 4; }
.grid > .col-5 { grid-column: span 5; }
.grid > .col-6 { grid-column: span 6; }
.grid > .col-7 { grid-column: span 7; }
.grid > .col-8 { grid-column: span 8; }
.grid > .col-9 { grid-column: span 9; }
.grid > .col-10 { grid-column: span 10; }
.grid > .col-11 { grid-column: span 11; }
.grid > .col-12 { grid-column: span 12; }
.card { border-radius: 14px; padding: 24px; box-shadow: 0 6px 20px rgba(0,0,0,0.08); border: 1px solid var(--border-muted); }
.card.kpi { display:flex; flex-direction:column; gap:8px; }
.card.kpi .value { font-size:1.6rem; font-weight:800; }
.card.kpi .sub { font-size:0.9rem; opacity:0.75; }
.card.kpi .sub.delta-pos { color: #16a34a; opacity: 1; }
.card.kpi .sub.delta-neg { color: #dc2626; opacity: 1; }
.card.kpi .sub.delta-zero { color: #666; opacity: 0.85; }

/* Acentos por categoria */
.accent-revenue { border-left: 6px solid var(--color-revenue-blue); }
.accent-expense { border-left: 6px solid var(--color-expense-red); }
.title-revenue { color: var(--color-revenue-blue); }
.title-expense { color: var(--color-expense-red); }
/* Cores para valores conforme tipo */
.income { color: var(--color-revenue-blue); }
.expense { color: var(--color-expense-red); }
.card.kpi.accent-revenue .value { color: var(--color-revenue-blue); }
.card.kpi.accent-expense .value { color: var(--color-expense-red); }

/* Ícones inline para KPIs (SVG base) */
.kpi-icon { width:20px; height:20px; display:inline-block; vertical-align:middle; margin-right:6px; }
.kpi-row { display:flex; align-items:center; gap:8px; }

/* Tooltips simples (data-tip) */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -34px; white-space: nowrap; background:#111; color:#fff;
  padding:6px 8px; border-radius:6px; font-size:12px; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
[data-tip]:hover::before {
  content:''; position:absolute; left:50%; transform:translateX(-50%);
  bottom:-12px; border:6px solid transparent; border-top-color:#111;
}

/* Mini gráfico placeholder */
.mini-chart { height:48px; width:100%; background: linear-gradient(90deg, rgba(31,111,235,0.12), rgba(220,38,38,0.12)); border-radius:8px; }

/* Grids auxiliares sem inline-styles */
.grid.auto-fit { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.two-col { grid-template-columns: 1fr 1fr; }
.grid.three-col { grid-template-columns: 2fr 1fr 1fr; }
.grid.full { grid-template-columns: 1fr; }

.logo { display: inline-block; position: relative; height: 80px; }
.logo img { height: 100%; display: none; }

/* Alterna a variante da logo conforme o fundo */
.bg-light .logo .logo-dark { display: inline-block; }
.bg-dark .logo .logo-light { display: inline-block; }
.bg-gradient .logo .logo-light { display: inline-block; }

/* Componentes de exemplo */
.title { font-weight: 700; margin: 0 0 12px; }
.muted { opacity: 0.8; }

.btn { 
  display: inline-block; padding: 10px 16px; border-radius: 10px; text-decoration: none; font-weight: 600;
  background: var(--color-orange); color: var(--text-on-dark);
  font-size: 14px; line-height: 1.2; min-height: 40px;
}
.btn-olive { background: var(--color-olive); color: var(--text-on-dark); }
.btn-outline { background: transparent; border: 2px solid var(--color-olive); color: var(--color-olive); }

.swatch { display: flex; gap: 8px; margin-top: 12px; }
.swatch > div { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-muted); }
.swatch .c-black { background: var(--color-black); }
.swatch .c-orange { background: var(--color-orange); }
.swatch .c-olive { background: var(--color-olive); }
.swatch .c-white { background: var(--color-white); }

.footer { margin-top: 20px; font-size: 13px; }

/* Tabelas responsivas */
.table-responsive { width: 100%; overflow-x: auto; }
.table-responsive .table { min-width: 640px; }

/* Cabeçalhos de seção dentro do conteúdo */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Exibição do usuário logado no header */
.user-info {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 106, 0, 0.1);
  border: 1px solid rgba(255, 106, 0, 0.2);
  border-radius: 20px;
  margin: 0 8px;
}

.user-name {
  font-weight: 600;
  color: var(--color-orange);
  font-size: 14px;
}

.user-info::before {
  content: "👤";
  margin-right: 6px;
  font-size: 16px;
}

/* Linhas de formulário em grid responsivo */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
}

/* Abas (tabs) */
.tab-nav { display:flex; gap:0.5rem; border-bottom:1px solid var(--border-muted); margin-bottom:0.75rem; flex-wrap: wrap; }
.tab-btn { 
  background:#f9fafb; color:#333; border:1px solid var(--border-muted); border-bottom:none; padding:8px 12px; border-radius:8px 8px 0 0; cursor:pointer; font-weight:600;
}
.tab-btn.active { background:#fff; color:#111; border-color: var(--color-orange); }
.tab-panel { animation: fadeIn 0.12s ease-in; }
@keyframes fadeIn { from { opacity: 0.0; } to { opacity: 1.0; } }

/* Hierarquia e legibilidade */
.form-group label { font-weight:600; margin-bottom:4px; display:block; }
.form-group input, .form-group select, .form-group textarea { width:100%; padding:8px 10px; border:1px solid var(--border-muted); border-radius:8px; }
.hint { font-size:0.78rem; color:#666; }

/* Acessibilidade: foco visível em botões e links */
.btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.35);
}

/* Login: área da logo responsiva e centralizada */
.logo-wrap { 
  display: flex; align-items: center; justify-content: center; 
  height: 96px; margin: 0 auto 12px; 
}
.logo-wrap .logo-img { 
  max-width: 70%; max-height: 100%; width: auto; height: auto; 
  margin: auto; object-fit: contain; 
  transform-origin: center center; image-rendering: -webkit-optimize-contrast; 
}

/* Ajustes responsivos */
@media (max-width: 480px) {
  .logo-wrap { height: 72px; margin-bottom: 10px; }
  .logo-wrap .logo-img { transform: scale(0.9); }
}

@media (min-width: 768px) {
  .logo-wrap { height: 100px; }
  .logo-wrap .logo-img { transform: scale(1.0); }
}

@media (min-width: 1200px) {
  .logo-wrap { height: 112px; }
  .logo-wrap .logo-img { transform: scale(1.05); }
}

/* Tema escuro: override de tokens e ajustes visuais mínimos */
html[data-theme="dark"] {
  /* Superfície e texto */
  --color-white: #121212;
  --text-on-light: #e6e6e6;
  --border-muted: rgba(255,255,255,0.14);
}
html[data-theme="dark"] body {
  background: var(--color-white);
  color: var(--text-on-light);
}
html[data-theme="dark"] .card {
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  background: #121212;
}
html[data-theme="dark"] .tab-btn {
  background:#1f1f1f; color:#e6e6e6; border-color: rgba(255,255,255,0.12); border-bottom:none;
}
html[data-theme="dark"] .user-info {
  background: rgba(255, 106, 0, 0.15);
  border-color: rgba(255, 106, 0, 0.3);
}
html[data-theme="dark"] .user-name {
  color: #ff8c1a;
}
html[data-theme="dark"] .tab-btn.active { background:#121212; color:#ffffff; border-color: var(--color-orange); }
html[data-theme="dark"] .table th, html[data-theme="dark"] .table tbody tr:hover {
  background: #1e1e1e;
}
html[data-theme="dark"] .btn-outline { border-color: var(--color-olive); color: var(--color-olive); }

/* Ajuste de cores no dark mode */
html[data-theme="dark"] {
  --color-card-bg: #121212;
}
html[data-theme="dark"] .title-revenue { color: #7aa2ff; }
html[data-theme="dark"] .title-expense { color: #ff6b6b; }

/* Contraste e legibilidade no dark mode */
html[data-theme="dark"] header { background: #161616; border-bottom-color: rgba(255,255,255,0.12); }
html[data-theme="dark"] nav a { color: #cfd3d7; }
html[data-theme="dark"] nav a:hover { background: #1f1f1f; color: #ffffff; }
html[data-theme="dark"] nav a.active { background: var(--color-orange); color: #ffffff; }
html[data-theme="dark"] .brand { color: #a3c76d; }
html[data-theme="dark"] footer { background: #161616; border-top-color: rgba(255,255,255,0.12); color: #a8a8a8; }
html[data-theme="dark"] .table td, html[data-theme="dark"] .table th { color: #e6e6e6; border-bottom-color: rgba(255,255,255,0.14); }
html[data-theme="dark"] .form-group label { color: #f0f0f0; }
html[data-theme="dark"] .hint, html[data-theme="dark"] .muted { color: #bdbdbd; }
html[data-theme="dark"] .header .title, html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3 { color: #ffffff; }
html[data-theme="dark"] .loading { color: #d9d9d9; }
/* Preservar hierarquia por peso/tamanho já definidos; assegurar contraste 4.5:1 */
html[data-theme="dark"] body, html[data-theme="dark"] .card, html[data-theme="dark"] .table, html[data-theme="dark"] .form-group input, html[data-theme="dark"] .form-group select, html[data-theme="dark"] .form-group textarea {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Variantes de botões padronizadas */
.btn-primary { background: var(--color-orange); color: var(--text-on-dark); }
.btn-secondary { background: #f3f4f6; color: #333; border: 1px solid var(--border-muted); }
.btn-success { background: #16a34a; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-warning { background: #f59e0b; color: #111; }
.btn-sm { padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.2; min-height: 32px; }
.btn-lg { padding: 12px 18px; border-radius: 12px; font-size: 15px; line-height: 1.2; min-height: 44px; }

/* Badges de status */
.badge { display:inline-block; padding:4px 8px; border-radius:999px; font-weight:700; font-size:12px; }
.badge-success { background:#16a34a; color:#fff; }
.badge-danger { background:#dc2626; color:#fff; }
.badge-warning { background:#f59e0b; color:#111; }

/* Modais padrão com estados minimizar/maximizar */
.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.35); z-index: 1000; }
.modal-content { width: min(740px, 96vw); background: var(--color-card-bg); border-radius: 12px; box-shadow: var(--shadow-strong); border: 1px solid var(--border-muted); }
.modal-header { display:flex; align-items:center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); }
.modal-actions { display:flex; gap:8px; align-items:center; justify-content:flex-end; padding: 12px 16px; border-top: 1px solid var(--border-muted); }
.modal-body { padding: 12px 16px; }
.modal-close, .modal-min, .modal-max { background: transparent; border: none; font-size: 18px; cursor: pointer; padding: 6px; border-radius: 8px; }
.modal-close:hover, .modal-min:hover, .modal-max:hover { background: rgba(0,0,0,0.06); }
.modal-minimized .modal-content { width: 420px; }
.modal-minimized .modal-body, .modal-minimized .modal-actions { display: none; }
.modal-maximized .modal-content { width: 96vw; height: 96vh; display:flex; flex-direction:column; }
.modal-maximized .modal-body { flex:1; overflow:auto; }

/* Dark mode ajustes para modais e badges */
html[data-theme="dark"] .badge-success { background:#22c55e; color:#0b0b0b; }
html[data-theme="dark"] .badge-danger { background:#ef4444; color:#0b0b0b; }
html[data-theme="dark"] .badge-warning { background:#f59e0b; color:#121212; }
html[data-theme="dark"] .modal { background: rgba(0,0,0,0.55); }
html[data-theme="dark"] .modal-content { background:#121212; }
.alert { padding: 10px 14px; border-radius: 10px; margin: 8px 0; font-weight: 600; }
.alert-info { background: #e0f2fe; color: #084c61; border: 1px solid #93c5fd; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.alert-error { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
html[data-theme="dark"] .alert-info { background:#0b2545; color:#cfe8ff; border-color:#1d4ed8; }
html[data-theme="dark"] .alert-success { background:#052e1a; color:#caffd5; border-color:#22c55e; }
html[data-theme="dark"] .alert-error { background:#3c0d0d; color:#ffdddd; border-color:#ef4444; }
/* Overrides visuais para Flatpickr — consistência com design system */
.flatpickr-calendar { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; box-shadow: 0 10px 20px rgba(0,0,0,0.08); border: 1px solid var(--border-muted); }
.flatpickr-months .flatpickr-month { color: var(--text-on-light); }
.flatpickr-day { border-radius: 6px; }
.flatpickr-day.today { border: 1px solid var(--color-orange); }
.flatpickr-day.selected { background: var(--color-orange); border-color: var(--color-orange); color: #fff; }
.flatpickr-day:hover { background: #f3f4f6; }
.flatpickr-weekdays { color: #6b7280; }
.flatpickr-monthDropdown-months, .numInputWrapper input { color: var(--text-on-light); }
.flatpickr-time input { color: var(--text-on-light); }
.flatpickr-input[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(85, 107, 47, 0.15); border-color: var(--color-olive); }
/* Modais padrão (dialog.modal) */
dialog.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid #ddd;
  border-radius: .5rem;
  background: #fff;
  color: inherit;
  padding-top: 2rem; /* espaço para toolbar */
  max-width: 720px;
  max-height: 85vh;
  overflow: auto;
  z-index: 1000;
}
dialog.modal[open] { display: block; }
dialog.modal::backdrop { background: rgba(0,0,0,.35); }
.modal-toolbar {
  position: absolute;
  top: .5rem;
  right: .5rem;
  display: flex;
  gap: .25rem;
}
.modal-toolbar .btnSmall {
  border: 1px solid #ccc;
  background: #f8f8f8;
  color: #333;
  padding: .15rem .35rem;
  border-radius: .25rem;
  cursor: pointer;
}
dialog.modal.is-maximized {
  width: 90vw;
  height: 90vh;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
dialog.modal.is-minimized {
  min-width: 380px;
  width: auto;
  height: auto;
  padding-bottom: .5rem;
}

/* Autocomplete */
.autocomplete-list {
  position: absolute;
  top: calc(100% + .25rem);
  left: 0;
  right: 0;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: .25rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  z-index: 999;
}
.autocomplete-list .item {
  padding: .4rem .5rem;
  cursor: pointer;
}
.autocomplete-list .item:hover { background: #f3f3f3; }
.autocomplete-list .item.muted { color: var(--muted); cursor: default; }