/* ==========================================================================
   IndexaContábil — Minimalist Dashboard Design System (Dark & Light)
   Tokens Semânticos: Primária #ffa800 | Secundária #1f3b9b
   ========================================================================== */

/* --- TEMA LIGHT (Padrão quando [data-theme="light"]) --- */
:root, [data-theme="light"], .theme-light {
  /* Canvas & Superfícies */
  --bg-canvas: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-hover: #f3f4f6;
  --border-color: #e5e7eb;
  --border-subtle: #f0f2f5;

  /* Tipografia */
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;

  /* Cores de Marca & Ação */
  --color-primary: #ffa800;
  --color-primary-hover: #ffb72b;
  --color-primary-active: #e69700;
  --color-primary-text: #1a1a1a;
  --color-primary-shadow: rgba(255, 168, 0, 0.28);

  --color-secondary: #1f3b9b;
  --color-secondary-hover: #294cbd;
  --color-secondary-active: #172c75;
  --color-secondary-text: #ffffff;
  --color-secondary-shadow: rgba(31, 59, 155, 0.25);

  /* Inputs & Formulários */
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --input-text: #1f2937;
  --input-placeholder: #9ca3af;
  --input-focus-border: #ffa800;
  --input-focus-ring: rgba(255, 168, 0, 0.22);

  /* Tabelas */
  --table-header-bg: #f8f9fa;
  --table-header-text: #6b7280;
  --table-row-hover: rgba(243, 244, 246, 0.7);
  --table-border: #e5e7eb;

  /* Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-item-hover: #f3f4f6;
  --sidebar-item-active: #ffa800;
  --sidebar-item-active-text: #1a1a1a;

  /* Header */
  --header-bg: #ffffff;
  --header-border: #e5e7eb;

  /* Badges */
  --badge-bg-default: #f3f4f6;
  --badge-text-default: #4b5563;
}

/* --- TEMA DARK (Padrão ativo via [data-theme="dark"] ou .dark) --- */
[data-theme="dark"], .dark {
  /* Canvas & Superfícies */
  --bg-canvas: #1f1f1f;
  --bg-surface: #282828;
  --bg-surface-elevated: #2d2d2d;
  --bg-surface-hover: #333333;
  --border-color: #383838;
  --border-subtle: #2e2e2e;

  /* Tipografia */
  --text-main: #e0e0e0;
  --text-muted: #a0a0a0;
  --text-subtle: #707070;

  /* Cores de Marca & Ação */
  --color-primary: #ffa800;
  --color-primary-hover: #ffb72b;
  --color-primary-active: #e69700;
  --color-primary-text: #1a1a1a;
  --color-primary-shadow: rgba(255, 168, 0, 0.32);

  --color-secondary: #1f3b9b;
  --color-secondary-hover: #294cbd;
  --color-secondary-active: #172c75;
  --color-secondary-text: #ffffff;
  --color-secondary-shadow: rgba(31, 59, 155, 0.35);

  /* Inputs & Formulários */
  --input-bg: #2d2d2d;
  --input-border: #383838;
  --input-text: #e0e0e0;
  --input-placeholder: #707070;
  --input-focus-border: #ffa800;
  --input-focus-ring: rgba(255, 168, 0, 0.25);

  /* Tabelas */
  --table-header-bg: #242424;
  --table-header-text: #a0a0a0;
  --table-row-hover: rgba(45, 45, 45, 0.65);
  --table-border: #383838;

  /* Sidebar */
  --sidebar-bg: #242424;
  --sidebar-border: #383838;
  --sidebar-item-hover: #2d2d2d;
  --sidebar-item-active: #ffa800;
  --sidebar-item-active-text: #1a1a1a;

  /* Header */
  --header-bg: #282828;
  --header-border: #383838;

  /* Badges */
  --badge-bg-default: #2d2d2d;
  --badge-text-default: #a0a0a0;
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Scrollbar Minimalista --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Classes Utilitárias de Tokens Semânticos
   ========================================================================== */
.bg-canvas          { background-color: var(--bg-canvas) !important; }
.bg-surface         { background-color: var(--bg-surface) !important; }
.bg-surface-elevated{ background-color: var(--bg-surface-elevated) !important; }
.border-theme       { border-color: var(--border-color) !important; }
.border-subtle      { border-color: var(--border-subtle) !important; }
.text-main          { color: var(--text-main) !important; }
.text-muted         { color: var(--text-muted) !important; }
.text-subtle        { color: var(--text-subtle) !important; }

/* ==========================================================================
   Componentes de Interface (Cards, Botões, Tabelas, Inputs)
   ========================================================================== */

/* --- Cards & Painéis --- */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  padding: 24px;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  border-color: var(--border-color);
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
  .card {
    padding: 16px;
    border-radius: 12px;
  }
}

/* --- Botão Primário (#ffa800) --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 20px;
  border-radius: 10px;
  background-color: var(--color-primary);
  color: var(--color-primary-text) !important;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 10px var(--color-primary-shadow);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--color-primary-shadow);
  filter: brightness(1.04);
}
.btn-primary:active {
  background-color: var(--color-primary-active);
  transform: translateY(0) scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Botão Secundário (#1f3b9b) --- */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 10px;
  background-color: var(--color-secondary);
  color: var(--color-secondary-text) !important;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 8px var(--color-secondary-shadow);
  transition: all 0.18s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover {
  background-color: var(--color-secondary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--color-secondary-shadow);
}
.btn-secondary:active {
  background-color: var(--color-secondary-active);
  transform: translateY(0) scale(0.98);
}
.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- Botão Outline / Neutro --- */
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 10px;
  background-color: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-outline:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

/* --- Botão Perigo --- */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 10px;
  background-color: #ef4444;
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
  transition: all 0.18s ease;
}
.btn-danger:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
}
.btn-danger:active {
  transform: translateY(0) scale(0.98);
}

/* --- Botão de Ícone --- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--text-muted);
}
.btn-icon:hover {
  background-color: var(--bg-surface-hover);
  color: var(--color-primary);
}

/* --- Formulários & Inputs --- */
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--input-text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.18s ease;
  outline: none;
}
.form-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
}
.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.form-input::placeholder {
  color: var(--input-placeholder);
}

/* --- Sidebar Navigation --- */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
}
.sidebar-nav-item:hover {
  background-color: var(--sidebar-item-hover);
  color: var(--text-main);
  transform: translateX(2px);
}
.sidebar-nav-item.active {
  background-color: var(--sidebar-item-active);
  color: var(--sidebar-item-active-text) !important;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--color-primary-shadow);
}
.sidebar-nav-item.active svg {
  color: var(--sidebar-item-active-text);
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-primary {
  background-color: rgba(255, 168, 0, 0.15);
  color: #ffa800;
  border: 1px solid rgba(255, 168, 0, 0.35);
}
.badge-secondary {
  background-color: rgba(31, 59, 155, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(31, 59, 155, 0.35);
}
.badge-green {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-gray {
  background-color: var(--badge-bg-default);
  color: var(--badge-text-default);
  border: 1px solid var(--border-color);
}
.badge-amber {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-red {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --- Tabelas Otimizadas --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 11px;
  font-weight: 700;
  color: var(--table-header-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--table-header-bg);
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--table-border);
  vertical-align: middle;
  color: var(--text-main);
  font-size: 13px;
}
.data-table tr:hover td {
  background-color: var(--table-row-hover);
}
.data-table tr:last-child td {
  border-bottom: none;
}

/* --- Theme Toggle Switch Button --- */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background-color: var(--bg-surface-hover);
}

/* --- Animações --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-fade-in  { animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-slide-in { animation: slideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.animate-spin     { animation: spin 0.8s linear infinite; }

/* ==========================================================================
   Garantia de Contraste e Acessibilidade (Dark Mode Auto-Adapters)
   Evita que classes estáticas legadas fiquem invisíveis no modo escuro
   ========================================================================== */
[data-theme="dark"] .bg-white,
.dark .bg-white {
  background-color: var(--bg-surface) !important;
}

[data-theme="dark"] .bg-slate-50,
.dark .bg-slate-50,
[data-theme="dark"] .bg-slate-100,
.dark .bg-slate-100 {
  background-color: var(--bg-surface-elevated) !important;
}

[data-theme="dark"] .border-slate-100,
.dark .border-slate-100,
[data-theme="dark"] .border-slate-200,
.dark .border-slate-200,
[data-theme="dark"] .border-slate-300,
.dark .border-slate-300 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .divide-slate-100 > * + *,
.dark .divide-slate-100 > * + *,
[data-theme="dark"] .divide-slate-200 > * + *,
.dark .divide-slate-200 > * + * {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .text-slate-800,
.dark .text-slate-800,
[data-theme="dark"] .text-slate-900,
.dark .text-slate-900,
[data-theme="dark"] .text-slate-700,
.dark .text-slate-700 {
  color: var(--text-main) !important;
}

[data-theme="dark"] .text-slate-600,
.dark .text-slate-600,
[data-theme="dark"] .text-slate-500,
.dark .text-slate-500,
[data-theme="dark"] .text-slate-400,
.dark .text-slate-400 {
  color: var(--text-muted) !important;
}

[data-theme="dark"] .bg-blue-50,
.dark .bg-blue-50 {
  background-color: rgba(31, 59, 155, 0.15) !important;
}

[data-theme="dark"] .bg-emerald-50,
.dark .bg-emerald-50,
[data-theme="dark"] .bg-green-50,
.dark .bg-green-50 {
  background-color: rgba(16, 185, 129, 0.15) !important;
}

[data-theme="dark"] .bg-red-50,
.dark .bg-red-50,
[data-theme="dark"] .bg-rose-50,
.dark .bg-rose-50 {
  background-color: rgba(239, 68, 68, 0.15) !important;
}

[data-theme="dark"] .bg-amber-50,
.dark .bg-amber-50,
[data-theme="dark"] .bg-yellow-50,
.dark .bg-yellow-50 {
  background-color: rgba(245, 158, 11, 0.15) !important;
}

[data-theme="dark"] .bg-purple-50,
.dark .bg-purple-50,
[data-theme="dark"] .bg-violet-50,
.dark .bg-violet-50 {
  background-color: rgba(139, 92, 246, 0.15) !important;
}

[data-theme="dark"] select option,
.dark select option {
  background-color: #282828 !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .hover\:bg-slate-50:hover,
.dark .hover\:bg-slate-50:hover,
[data-theme="dark"] .hover\:bg-slate-50\/60:hover,
.dark .hover\:bg-slate-50\/60:hover,
[data-theme="dark"] .hover\:bg-slate-100:hover,
.dark .hover\:bg-slate-100:hover {
  background-color: var(--table-row-hover) !important;
}

[data-theme="dark"] tr:hover td {
  background-color: var(--table-row-hover);
}

/* ==========================================================================
   Global Toast Notification System (Flutuante Top-Right)
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  pointer-events: none;
  max-width: 24rem;
  width: calc(100vw - 2.5rem);
}

.toast-item {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.875rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(120%);
  opacity: 0;
}

.toast-item.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-item.hide {
  transform: translateX(120%);
  opacity: 0;
  margin-bottom: -3.5rem;
}

/* Tipos de Toast */
.toast-success {
  background-color: #ffffff;
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #10b981;
}
[data-theme="dark"] .toast-success,
.dark .toast-success {
  background-color: #1c2722;
  border-color: rgba(16, 185, 129, 0.45);
}

.toast-error {
  background-color: #ffffff;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
}
[data-theme="dark"] .toast-error,
.dark .toast-error {
  background-color: #2c1b1c;
  border-color: rgba(239, 68, 68, 0.45);
}

.toast-warning {
  background-color: #ffffff;
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}
[data-theme="dark"] .toast-warning,
.dark .toast-warning {
  background-color: #2b2214;
  border-color: rgba(245, 158, 11, 0.45);
}

.toast-info {
  background-color: #ffffff;
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #3b82f6;
}
[data-theme="dark"] .toast-info,
.dark .toast-info {
  background-color: #182333;
  border-color: rgba(59, 130, 246, 0.45);
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
}

.toast-message {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
  margin-top: 0.125rem;
  word-break: break-word;
}

.toast-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.375rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
  background: transparent;
  border: none;
  padding: 0;
  margin-top: -0.125rem;
  margin-right: -0.25rem;
  font-size: 1.125rem;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-main);
  background-color: rgba(128, 128, 128, 0.15);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  width: 100%;
  background: currentColor;
  opacity: 0.4;
  transform-origin: left;
}


