/* Central Financeira Pessoal Adair - Custom Styles */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; margin: 0; overflow-x: hidden; }

/* Dark mode */
.dark { color-scheme: dark; }
.dark body { background: #0f172a; color: #e2e8f0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #4f46e5; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: #6366f1; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
#sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
  background: #f1f5f9;
}
.dark #main-content { background: #0f172a; }
#main-content.expanded { margin-left: 0; }

/* Navigation items */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: #a5b4fc;
  cursor: pointer;
  border-radius: 8px;
  margin: 2px 8px;
  transition: all 0.2s;
  font-size: 14px;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(99,102,241,0.5); color: #fff; font-weight: 600; }
.nav-item i { width: 20px; text-align: center; }

.nav-group-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #6366f1; padding: 8px 16px 4px; letter-spacing: 0.1em;
}

/* Cards */
.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}
.dark .stat-card { background: #1e293b; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}
.dark .card { background: #1e293b; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { background: #f8fafc; color: #64748b; font-weight: 600; padding: 12px 16px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #e2e8f0; }
.dark .data-table th { background: #0f172a; color: #94a3b8; border-color: #334155; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.dark .data-table td { border-color: #334155; color: #cbd5e1; }
.data-table tr:hover td { background: #f8fafc; }
.dark .data-table tr:hover td { background: #0f172a; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #3730a3; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-ghost { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #f8fafc; }
.dark .btn-ghost { color: #94a3b8; border-color: #475569; }
.dark .btn-ghost:hover { background: #334155; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.dark .form-label { color: #94a3b8; }
.form-input {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; color: #111827; background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.dark .form-input { background: #0f172a; border-color: #475569; color: #e2e8f0; }
.dark .form-input:focus { border-color: #6366f1; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease;
}
.dark .modal { background: #1e293b; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid #e2e8f0; }
.dark .modal-header { border-color: #334155; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; gap: 8px; justify-content: flex-end; }
.dark .modal-footer { border-color: #334155; }

/* Badges / Chips */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }
.dark .badge-success { background: #064e3b; color: #6ee7b7; }
.dark .badge-danger { background: #7f1d1d; color: #fca5a5; }
.dark .badge-warning { background: #78350f; color: #fcd34d; }
.dark .badge-info { background: #1e3a5f; color: #93c5fd; }
.dark .badge-gray { background: #334155; color: #94a3b8; }

/* Progress bar */
.progress-bar { background: #e2e8f0; border-radius: 99px; overflow: hidden; height: 8px; }
.dark .progress-bar { background: #334155; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }

/* Alert / Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: 10px;
  background: #1e293b; color: #fff;
  font-size: 14px; font-weight: 500;
  z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: toastIn 0.3s ease;
  max-width: 350px;
  display: flex; align-items: center; gap: 10px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }

/* Tabs */
.tab-list { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.dark .tab-list { background: #0f172a; }
.tab-btn { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: #64748b; transition: all 0.2s; }
.tab-btn.active { background: #fff; color: #4f46e5; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; }
.dark .tab-btn { color: #94a3b8; }
.dark .tab-btn.active { background: #1e293b; color: #818cf8; }

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px; border-radius: 8px; cursor: pointer; font-size: 12px; transition: background 0.2s; }
.calendar-day:hover { background: #f1f5f9; }
.dark .calendar-day:hover { background: #334155; }
.calendar-day.today { background: #4f46e5; color: #fff; }
.calendar-day.has-events::after { content: ''; width: 5px; height: 5px; background: #ef4444; border-radius: 50%; margin-top: 2px; }
.calendar-day.other-month { opacity: 0.3; }

/* Charts container */
.chart-container { position: relative; height: 280px; }

/* Login page */
#login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
}
.login-card {
  background: #fff; border-radius: 24px; padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.dark .login-card { background: #1e293b; }

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.slide-in { animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

/* ============================================
   RESPONSIVO — TABLET (768px – 1024px)
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-width: 220px; }
  .page-header { padding: 16px 16px 0; }
  #topbar { padding: 10px 16px; }
}

/* ============================================
   RESPONSIVO — MOBILE (até 768px)
   ============================================ */
@media (max-width: 768px) {

  /* --- Sidebar: escondida por padrão, desliza ao abrir --- */
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    z-index: 300;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  /* --- Overlay escuro atrás da sidebar --- */
  #sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 299;
    backdrop-filter: blur(2px);
  }
  #sidebar-overlay.active { display: block; }

  /* --- Conteúdo principal: sem margem lateral --- */
  #main-content {
    margin-left: 0 !important;
  }

  /* --- Topbar: compacto --- */
  #topbar {
    padding: 10px 12px;
  }

  /* --- Page header: padding menor --- */
  .page-header {
    padding: 14px 12px 0;
    margin-bottom: 14px;
  }
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }

  /* --- Conteúdo das páginas: reduz padding lateral --- */
  #page-content .px-6 { padding-left: 12px !important; padding-right: 12px !important; }
  #page-content .p-6  { padding: 12px !important; }
  #page-content .py-6 { padding-top: 12px !important; padding-bottom: 12px !important; }
  #page-content .px-4 { padding-left: 10px !important; padding-right: 10px !important; }
  #page-content .pb-6 { padding-bottom: 12px !important; }

  /* --- Cards stat: fonte menor --- */
  .stat-card { padding: 14px; border-radius: 12px; }
  .stat-card:hover { transform: none; }  /* desativa hover no touch */

  /* --- Tabelas: scroll horizontal forçado --- */
  .overflow-x-auto { -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 10px; }

  /* --- Botões: área de toque maior --- */
  .btn { min-height: 40px; padding: 8px 14px; }
  .btn-sm { min-height: 36px; padding: 6px 10px; font-size: 12px; }
  .btn-icon { min-width: 40px; min-height: 40px; padding: 8px; }

  /* --- Inputs: tamanho mínimo 16px evita zoom automático no iOS/Android --- */
  .form-input, .form-select, select, input, textarea {
    font-size: 16px !important;
    min-height: 44px;
  }
  input[type="checkbox"], input[type="radio"] {
    min-height: auto;
  }
  .form-label { font-size: 14px; }

  /* --- Modal: ocupa tela toda no mobile --- */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    margin: 0;
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-footer { padding: 12px 16px; flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* --- Toast: centralizado no topo --- */
  .toast {
    bottom: auto;
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: 100%;
    font-size: 13px;
  }

  /* --- Login card --- */
  .login-card {
    padding: 24px 20px;
    border-radius: 16px;
    margin: 12px;
  }

  /* --- Calendário: células menores --- */
  .calendar-day { font-size: 11px; padding: 2px; }

  /* --- Gráficos: altura reduzida --- */
  .chart-container { height: 200px; }

  /* --- FAB: sobe por causa do toast --- */
  .fab { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 20px; }

  /* --- Grids: ajuste de colunas no mobile --- */
  /* stat cards: 2 colunas */
  .grid.grid-cols-2.xl\:grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }
  /* seção de 3 colunas vira 1 coluna */
  .grid.grid-cols-1.xl\:grid-cols-3 { grid-template-columns: 1fr !important; }
  .grid.grid-cols-1.md\:grid-cols-2 { grid-template-columns: 1fr !important; }
  /* inputs lado a lado viram coluna única */
  .grid.grid-cols-2 { grid-template-columns: 1fr !important; }
  .grid.grid-cols-3 { grid-template-columns: 1fr !important; }

  /* --- Empty state compacto --- */
  .empty-state { padding: 40px 16px; }
  .empty-state i { font-size: 36px; }

  /* --- Nav items maiores para toque --- */
  .nav-item { padding: 13px 16px; font-size: 15px; }
  .nav-item i { width: 22px; }

  /* --- Badges --- */
  .badge { font-size: 10px; }

  /* --- Tabs --- */
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .tab-list { overflow-x: auto; flex-wrap: nowrap; }
}

/* ============================================
   DASHBOARD — layout fixo (Tailwind CDN não
   processa classes em JS dinâmico)
   ============================================ */

/* Grid 3 colunas no dashboard */
@media (min-width: 1280px) {
  .dashboard-grid-3 {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 1.25rem;
  }
  .dashboard-col-2 {
    grid-column: span 2 !important;
  }
  .dashboard-grid-bar {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    gap: 1.25rem;
  }
}

@media (max-width: 1279px) {
  .dashboard-grid-3 { display: flex; flex-direction: column; gap: 1rem; }
  .dashboard-grid-bar { display: flex; flex-direction: column; gap: 1rem; }
}

/* Topbar */
#topbar {
  background: #fff; border-bottom: 1px solid #e2e8f0;
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.dark #topbar { background: #1e293b; border-color: #334155; }

/* Page header */
.page-header { padding: 24px 24px 0; margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; color: #1e293b; }
.dark .page-title { color: #f1f5f9; }
.page-subtitle { color: #64748b; font-size: 14px; margin-top: 4px; }

/* Money display */
.money-positive { color: #10b981; font-weight: 700; }
.money-negative { color: #ef4444; font-weight: 700; }
.money-neutral { color: #64748b; font-weight: 600; }

/* Sidebar logo */
.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}

/* Alert dot */
.alert-dot {
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  position: absolute;
  top: -2px; right: -2px;
}

/* Category color dot */
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Summary boxes */
.summary-box { border-radius: 12px; padding: 16px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 24px; color: #94a3b8; }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* Floating action button */
.fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; background: #4f46e5; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 4px 12px rgba(79,70,229,0.4); cursor: pointer; z-index: 100; transition: transform 0.2s; }
.fab:hover { transform: scale(1.1); }
