/* =============================================
   MINHAS CONTAS — CSS Principal
   Design: Moderno, Responsivo, Mobile-first
   ============================================= */

:root {
  --primary: #4361ee;
  --primary-dark: #3251d4;
  --primary-light: #eef0fd;
  --success: #2ec4b6;
  --danger: #e63946;
  --warning: #f4a261;
  --info: #457b9d;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f4f6fb;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: #4361ee;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --text: #1e293b;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(67,97,238,0.06);
  --shadow-hover: 0 4px 20px rgba(67,97,238,0.15);
  --radius: 14px;
  --font: 'Nunito', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --transition: 0.2s ease;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: white;
  box-shadow: 0 4px 12px rgba(67,97,238,0.4);
}
.brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--sidebar-text);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}
.user-avatar-placeholder {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.user-name { font-size: 0.85rem; font-weight: 700; color: white; }
.user-email { font-size: 0.7rem; color: var(--sidebar-text); }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.35);
  padding: 0 8px;
  margin-bottom: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item i { font-size: 1rem; min-width: 20px; text-align: center; }
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(67,97,238,0.4);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- OVERLAY ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* ---- TOPBAR ---- */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.btn-menu {
  background: none; border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background var(--transition);
}
.btn-menu:hover { background: var(--bg); }

.topbar-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---- MESSAGES ---- */
.messages-container { padding: 16px 20px 0; }

/* ---- CONTENT ---- */
.main-content { padding: 20px; max-width: 1400px; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 700;
}

/* ---- STAT CARDS ---- */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 12px;
}
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: rgba(46,196,182,0.12); color: var(--success); }
.stat-icon.danger { background: rgba(230,57,70,0.1); color: var(--danger); }
.stat-icon.warning { background: rgba(244,162,97,0.12); color: var(--warning); }

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  color: var(--text);
}
.stat-value.danger { color: var(--danger); }
.stat-value.success { color: var(--success); }
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- TRANSACTION LIST ---- */
.transacao-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: all var(--transition);
}
.transacao-item:last-child { border-bottom: none; }
.transacao-item:hover { background: var(--bg); border-radius: 10px; padding-left: 10px; padding-right: 10px; margin: 0 -10px; }

.transacao-icone {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.transacao-icone.pagar { background: rgba(230,57,70,0.1); color: var(--danger); }
.transacao-icone.receber { background: rgba(46,196,182,0.1); color: var(--success); }

.transacao-info { flex: 1; min-width: 0; }
.transacao-desc {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.transacao-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.transacao-valor {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.transacao-valor.pagar { color: var(--danger); }
.transacao-valor.receber { color: var(--success); }

/* ---- BADGES STATUS ---- */
.badge-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-pendente { background: rgba(244,162,97,0.15); color: #c17a3d; }
.badge-pago { background: rgba(46,196,182,0.15); color: #1a9e94; }
.badge-atrasado { background: rgba(230,57,70,0.12); color: var(--danger); }
.badge-cancelado { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ---- FORMA PAGAMENTO BADGES ---- */
.badge-forma {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* ---- BUTTONS ---- */
.btn {
  font-family: var(--font);
  font-weight: 700;
  border-radius: 10px;
  transition: all var(--transition);
}
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); }

.btn-icon {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  transition: all var(--transition);
  text-decoration: none;
  font-size: 0.9rem;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(230,57,70,0.08); }

/* ---- FORMS ---- */
.form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-family: var(--font);
  transition: all var(--transition);
  padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.15);
}
.form-label {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

/* ---- TABLES ---- */
.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-modern th {
  background: var(--bg);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table-modern td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.88rem;
}
.table-modern tr:hover td { background: var(--primary-light); }
.table-modern tr:last-child td { border-bottom: none; }

/* ---- PROGRESS BARS ---- */
.progress {
  height: 8px;
  border-radius: 10px;
  background: var(--border);
}
.progress-bar { border-radius: 10px; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
}
.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- MONTH NAVIGATOR ---- */
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
}
.month-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all var(--transition);
}
.month-nav a:hover { background: var(--primary-light); color: var(--primary); }
.month-nav .current {
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 150px;
  text-align: center;
  color: var(--text);
}

/* ---- CHART CONTAINER ---- */
.chart-container {
  position: relative;
  height: 220px;
}

/* ---- AUTH PAGES ---- */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: white;
  box-shadow: 0 8px 24px rgba(67,97,238,0.4);
  margin-bottom: 12px;
}
.auth-title { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-subtitle { font-size: 0.88rem; color: var(--text-muted); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: 0.3; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; margin: 16px 0 8px; color: var(--text); }
.empty-state p { font-size: 0.88rem; }

/* ---- FILTER BAR ---- */
.filter-bar {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

/* ============================================================
   DESKTOP — sidebar always visible
   ============================================================ */
@media (min-width: 992px) {
  .sidebar { transform: translateX(0); }
  .main-wrapper { margin-left: var(--sidebar-w); }
  .sidebar-overlay { display: none !important; }
  #menuBtn { display: none; }
  .bottom-nav { display: none !important; }
}

/* ============================================================
   TABLET / MOBILE (< 992px) — sidebar hidden, bottom nav shown
   ============================================================ */
@media (max-width: 991px) {
  /* Topbar */
  .topbar { padding: 0 12px; height: 52px; }
  .topbar-title { font-size: .95rem; font-weight: 800; }

  /* Main content — espaço para a bottom nav */
  .main-content { padding: 12px 12px 90px; }
  .main-wrapper { margin-left: 0 !important; }

  /* Auth */
  .auth-card { padding: 24px 20px; }

  /* Page header empilha verticalmente */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h1 { font-size: 1.25rem; }
  .page-header .d-flex { width: 100%; }

  /* Stat cards — 2 por linha, mais compactos */
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.2rem; }
  .stat-label { font-size: .7rem; }
  .stat-sub { font-size: .68rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }

  /* Cards */
  .card { border-radius: 12px; }

  /* Month nav */
  .month-nav .current { min-width: 80px; font-size: .8rem; }

  /* Tabelas — scroll horizontal */
  .table-responsive-mobile {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }
  .table-modern th { font-size: .68rem; padding: 10px 12px; white-space: nowrap; }
  .table-modern td { font-size: .8rem; padding: 10px 12px; }

  /* Oculta colunas menos importantes no mobile */
  .col-hide-mobile { display: none !important; }

  /* Formulários */
  .form-label { font-size: .85rem; margin-bottom: 4px; }
  .form-control, .form-select { font-size: .9rem; padding: 8px 12px; }
  .btn { font-size: .85rem; }
}

/* ============================================================
   SMALL MOBILE (< 576px)
   ============================================================ */
@media (max-width: 576px) {
  .main-content { padding: 10px 10px 90px; }
  .topbar { padding: 0 10px; }
  .page-header h1 { font-size: 1.1rem; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.05rem; }
  .card-body { padding: 14px !important; }
  .btn-icon { width: 32px; height: 32px; font-size: .82rem; }
}

/* ============================================================
   BOTTOM NAVIGATION BAR (mobile only)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);           /* sólido, sem transparência */
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  padding: 4px 0 env(safe-area-inset-bottom, 4px);
  min-height: 60px;
}

@media (max-width: 991px) {
  .bottom-nav { display: flex; }
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition: color .15s;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav-item.active,
.bottom-nav-item:active {
  color: var(--primary);
}

/* Botão central destacado (+) */
.bottom-nav-fab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.bottom-nav-fab-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4361ee, #2ec4b6);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(67,97,238,.4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
  margin-top: -10px;
}
.bottom-nav-fab-btn:active { transform: scale(.93); }

/* FAB dropdown menu */
.fab-menu {
  display: none;
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 1001;
  min-width: 200px;
}
.fab-menu.open { display: block; animation: fadeIn .15s ease; }
.fab-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
}
.fab-menu a:hover { background: var(--surface-hover); }
.fab-menu a i { font-size: 1.1rem; }

/* ---- PROGRESS BAR RELATÓRIO ---- */
.progress-report {
  height: 6px;
  border-radius: 10px;
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
}
.progress-report-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s ease;
}
.progress-report-bar.success { background: var(--success); }
.progress-report-bar.danger  { background: var(--danger); }
.progress-report-bar.primary { background: var(--primary); }

/* ---- STAT CARD PERCENT ---- */
.stat-percent {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- ACTION COLUMN IN REPORTS ---- */
.action-col { width: 80px; white-space: nowrap; }

/* ---- CONTA BADGE ---- */
.badge-conta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(69,123,157,0.12);
  color: #457b9d;
  font-weight: 700;
}

/* ---- REPORT DONUT CHART CONTAINER ---- */
.donut-container {
  position: relative;
  height: 180px;
  margin-bottom: 12px;
}

/* ---- HIGHLIGHT ROWS ---- */
.table-modern tr.row-atrasado td { background: rgba(230,57,70,0.04); }
.table-modern tr.row-pago td { opacity: 0.75; }

/* ---- SALDO ACUMULADO BADGE ---- */
.saldo-acum-pos { color: var(--success); font-weight: 800; }
.saldo-acum-neg { color: var(--danger); font-weight: 800; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ---- UTILITIES ---- */
.font-mono { font-family: var(--font-mono); }
.text-primary-custom { color: var(--primary) !important; }
.text-success-custom { color: var(--success) !important; }
.text-danger-custom { color: var(--danger) !important; }
.bg-primary-light { background: var(--primary-light); }
.fw-800 { font-weight: 800; }

/* ---- LOADING ---- */
.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- ANIMATIONS ---- */
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * {
  animation: fadeIn 0.35s ease forwards;
  opacity: 0;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }
