/* =====================================================
   FinançaFamília — Premium Dashboard CSS
   Paleta: Azul profundo + verde esmeralda + cinza neutro
   ===================================================== */

:root {
  --primary:        #1a56db;
  --primary-dark:   #1341b5;
  --primary-light:  #e8f0fe;
  --secondary:      #0e9f6e;
  --secondary-light:#d5f5ed;
  --danger:         #e02424;
  --danger-light:   #fde8e8;
  --warning:        #e3a008;
  --warning-light:  #fdf6b2;
  --info:           #0694a2;
  --info-light:     #d5f5f6;

  --bg:             #f0f4f8;
  --bg-card:        #ffffff;
  --bg-sidebar:     #0f172a;
  --bg-sidebar2:    #1e293b;

  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --text-sidebar:   #cbd5e1;
  --text-sidebar-active: #ffffff;

  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 40px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);

  --sidebar-w:      260px;
  --sidebar-collapsed: 70px;
  --topbar-h:       64px;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --radius-xl:      24px;

  --font-main:      'Plus Jakarta Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --transition:     all .22s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg:             #0f172a;
  --bg-card:        #1e293b;
  --bg-sidebar:     #020817;
  --bg-sidebar2:    #0f172a;
  --text:           #f1f5f9;
  --text-muted:     #94a3b8;
  --text-light:     #64748b;
  --border:         #334155;
  --border-light:   #1e293b;
  --shadow:         0 4px 16px rgba(0,0,0,.3);
  --primary-light:  #1e3a8a;
  --secondary-light:#064e3b;
  --danger-light:   #7f1d1d;
  --warning-light:  #78350f;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

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

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .25s cubic-bezier(.4,0,.2,1), transform .25s;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-h);
}

.brand-logo {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(26,86,219,.4);
}

.brand-text { flex: 1; overflow: hidden; }
.brand-name {
  display: block;
  font-size: 15px; font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-sidebar);
  white-space: nowrap;
}

.sidebar-toggle-btn {
  background: none; border: none;
  color: var(--text-sidebar);
  cursor: pointer;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name  { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.user-role  { display: block; font-size: 11px; color: var(--text-sidebar); white-space: nowrap; }

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 10px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,86,219,.4);
}
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.nav-logout { margin-top: auto; color: #f87171 !important; }
.nav-logout:hover { background: rgba(248,113,113,.1) !important; }

/* Collapsed sidebar */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .sidebar-toggle-btn,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-badge { display: none; }

.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 20px 0; }
.sidebar.collapsed .sidebar-user  { justify-content: center; padding: 14px 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px; }
.sidebar.collapsed .nav-icon { width: auto; }

/* ─── Main Layout ─── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.main-wrapper.collapsed { margin-left: var(--sidebar-collapsed); }

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-menu-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  width: 40px; height: 40px;
  display: none; /* escondido por padrão no desktop */
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-size: 18px;
  flex-shrink: 0;
}
.topbar-menu-btn:hover { background: var(--border-light); color: var(--text); }

.topbar-title h1 {
  font-size: 18px; font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.topbar-subtitle {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-date {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 5px 12px;
  border-radius: 99px;
  font-weight: 500;
}

.topbar-theme-btn, .topbar-settings {
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-size: 15px;
}
.topbar-theme-btn:hover, .topbar-settings:hover {
  background: var(--border-light);
  color: var(--text);
}

/* ─── Page Content ─── */
.page-content { padding: 24px; flex: 1; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: none;
}
.card-header h5, .card-header h6 {
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--primary));
}

.stat-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
  background: var(--card-icon-bg, var(--primary-light));
  color: var(--card-icon-color, var(--primary));
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.2;
}
.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.green { --card-accent: var(--secondary); --card-icon-bg: var(--secondary-light); --card-icon-color: var(--secondary); }
.stat-card.red   { --card-accent: var(--danger);    --card-icon-bg: var(--danger-light);    --card-icon-color: var(--danger); }
.stat-card.orange{ --card-accent: var(--warning);   --card-icon-bg: var(--warning-light);   --card-icon-color: var(--warning); }
.stat-card.teal  { --card-accent: var(--info);      --card-icon-bg: var(--info-light);      --card-icon-color: var(--info); }

/* ─── Tables ─── */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table {
  font-size: 13.5px;
  color: var(--text);
  --bs-table-bg: var(--bg-card);
  --bs-table-striped-bg: var(--border-light);
  --bs-table-hover-bg: var(--primary-light);
  --bs-table-border-color: var(--border);
  margin: 0;
}
.table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--border-light);
  border: none;
  padding: 10px 14px;
}
.table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  border-color: var(--border);
}

/* ─── Badges ─── */
.badge-status {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: .02em;
}
.badge-pago      { background: var(--secondary-light); color: var(--secondary); }
.badge-pendente  { background: var(--warning-light);   color: var(--warning); }
.badge-vencido   { background: var(--danger-light);    color: var(--danger); }
.badge-receita   { background: var(--secondary-light); color: var(--secondary); }
.badge-despesa   { background: var(--danger-light);    color: var(--danger); }
.badge-transferencia { background: var(--info-light);  color: var(--info); }

/* ─── Forms ─── */
.form-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 12px;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
  background: var(--bg-card);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-light); }
.input-group-text {
  background: var(--border-light);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

/* ─── Buttons ─── */
.btn {
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 8px 16px;
  transition: var(--transition);
  border: none;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary   { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(26,86,219,.3); }
.btn-primary:hover   { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,.4); }
.btn-success   { background: var(--secondary); color: #fff; box-shadow: 0 2px 8px rgba(14,159,110,.25); }
.btn-success:hover   { background: #057a55; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover    { background: #c81e1e; }
.btn-outline-secondary { border: 1.5px solid var(--border); color: var(--text-muted); background: transparent; }
.btn-outline-secondary:hover { background: var(--border-light); color: var(--text); }
.btn-outline-primary   { border: 1.5px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary-light); }

/* ─── Progress ─── */
.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--border);
}
.progress-bar {
  border-radius: 99px;
  background: var(--primary);
}

/* ─── Charts ─── */
.chart-container { position: relative; }

/* ─── Alerts ─── */
.alert { border: none; border-radius: var(--radius); font-size: 13.5px; }
.alert-success { background: var(--secondary-light); color: var(--secondary); }
.alert-danger  { background: var(--danger-light);    color: var(--danger); }
.alert-info    { background: var(--info-light);      color: var(--info); }
.alert-warning { background: var(--warning-light);   color: var(--warning); }
.btn-close { filter: none; }

/* ─── Modals ─── */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}
.modal-header .modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }
.btn-close { color: var(--text-muted); }

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(26,86,219,.4);
}
.login-title { font-size: 22px; font-weight: 800; color: var(--text); text-align: center; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ─── Section Headers ─── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.section-header h2 { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }

/* ─── Meta Progress Card ─── */
.meta-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: var(--transition);
}
.meta-card:hover { box-shadow: var(--shadow); }
.meta-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.meta-card-title  { font-size: 14px; font-weight: 700; color: var(--text); }
.meta-card-pct    { font-size: 20px; font-weight: 800; color: var(--primary); font-family: var(--font-mono); }
.meta-card-values { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ─── Sidebar Overlay (mobile) ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 1050;
  cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* ─── Responsive Mobile ─── */
@media (max-width: 991.98px) {
  /* Sidebar fica escondida fora da tela */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w) !important;
    transform: translateX(-110%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 1100;
    box-shadow: none;
  }

  /* Quando aberta via JS */
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, .35);
  }

  /* Conteúdo principal ocupa tela toda */
  .main-wrapper {
    margin-left: 0 !important;
  }

  /* Botão hambúrguer visível */
  .topbar-menu-btn {
    display: flex !important;
  }

  .page-content { padding: 16px; }

  /* Esconder botão de recolher sidebar no mobile */
  .sidebar-toggle-btn { display: none !important; }
}

@media (max-width: 575.98px) {
  .topbar { padding: 0 14px; }
  .topbar-date { display: none; }
  .page-content { padding: 12px; }
  .sidebar { width: 280px !important; }
}

/* ─── Number Formatting ─── */
.valor-positivo { color: var(--secondary); font-family: var(--font-mono); font-weight: 600; }
.valor-negativo { color: var(--danger);    font-family: var(--font-mono); font-weight: 600; }
.valor-neutro   { color: var(--text-muted);font-family: var(--font-mono); font-weight: 600; }
.valor-mono     { font-family: var(--font-mono); font-weight: 600; }

/* ─── Balance Sheet ─── */
.balanco-table th { background: var(--primary-light); color: var(--primary); }
.balanco-group th { background: var(--border-light); }
.balanco-total    { font-weight: 800; background: var(--primary); color: #fff !important; }

/* ─── Utility ─── */
.rounded-pill { border-radius: 99px !important; }
.text-money   { font-family: var(--font-mono); font-weight: 600; }
.bg-card      { background: var(--bg-card) !important; }
.gap-2 { gap: 8px; }

/* ─── Spinner ─── */
.spinner-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 14px; display: block; opacity: .4; }
.empty-state h6 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ─── Print ─── */
@media print {
  .sidebar, .topbar, .btn, .page-content .alert { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ─── Mobile: sidebar nunca colapsa ─── */
@media (max-width: 991.98px) {
  /* Anula TODOS os efeitos da classe .collapsed no mobile */
  .sidebar.collapsed {
    width: var(--sidebar-w) !important;
  }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .brand-sub,
  .sidebar.collapsed .user-info,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .nav-badge {
    display: revert !important;
  }
  .sidebar.collapsed .sidebar-brand {
    justify-content: flex-start !important;
    padding: 20px 16px !important;
  }
  .sidebar.collapsed .sidebar-user {
    justify-content: flex-start !important;
    padding: 14px 16px !important;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start !important;
    padding: 9px 10px !important;
  }
  .sidebar.collapsed .nav-icon {
    width: 18px !important;
  }
  /* Overlay deve ficar acima de tudo */
  .sidebar-overlay {
    z-index: 1099 !important;
  }
  .sidebar {
    z-index: 1100 !important;
  }
}
