/* ============================================================
   FinanceiroGEO — Dark Mode Premium CSS
   ============================================================ */

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

:root {
  --bg-base:        #070d1a;
  --bg-surface:     #0d1526;
  --bg-card:        #111e35;
  --bg-card-hover:  #162240;
  --bg-input:       #0d1a30;
  --border:         rgba(255,255,255,0.07);
  --border-focus:   rgba(0,212,165,0.5);

  --green:          #00d4a5;
  --green-dim:      rgba(0,212,165,0.12);
  --green-glow:     0 0 20px rgba(0,212,165,0.25);

  --blue:           #3b82f6;
  --blue-dim:       rgba(59,130,246,0.12);

  --orange:         #f97316;
  --orange-dim:     rgba(249,115,22,0.12);

  --red:            #ef4444;
  --red-dim:        rgba(239,68,68,0.12);

  --yellow:         #f59e0b;
  --yellow-dim:     rgba(245,158,11,0.12);

  --purple:         #9333ea;
  --purple-dim:     rgba(147,51,234,0.12);

  --text-primary:   #f0f6ff;
  --text-secondary: #8b9dc3;
  --text-muted:     #4a5a7a;

  --sidebar-w:      250px;
  --sidebar-collapsed: 68px;
  --topbar-h:       64px;

  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;

  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --shadow-card:    0 2px 12px rgba(0,0,0,0.3);

  --transition:     0.2s ease;
  --transition-slow:0.35s cubic-bezier(0.4,0,0.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-details,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0 14px; }
.sidebar.collapsed .sidebar-toggle-btn { transform: rotate(180deg); }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .user-info { justify-content: center; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.logo-icon { font-size: 24px; flex-shrink: 0; }
.logo-text  { font-size: 18px; font-weight: 800; color: var(--green); letter-spacing: -0.5px; white-space: nowrap; }

.sidebar-toggle-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color var(--transition), transform var(--transition-slow);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--green); }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--transition);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--green-dim);
  color: var(--green);
}

.nav-item.active {
  background: var(--green-dim);
  color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.nav-icon { font-size: 18px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { flex: 1; }

.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; truncate: clip; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

.logout-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: color var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--red); }

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title h1 { font-size: 18px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

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

/* --- Cards Grid --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card:hover {
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.card-green::before  { background: var(--green); }
.card-blue::before   { background: var(--blue); }
.card-red::before    { background: var(--red); }
.card-orange::before { background: var(--orange); }
.card-yellow::before { background: var(--yellow); }
.card-purple::before { background: var(--purple); }

.card-icon {
  font-size: 28px;
  margin-bottom: 12px;
  display: block;
}

.card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.card-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }
.card-value.neutral  { color: var(--text-primary); }
.card-value.blue     { color: var(--blue); }

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Section Header --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Charts --- */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* --- Tables --- */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  background: var(--bg-surface);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* --- Badges / Pills --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green   { background: var(--green-dim);  color: var(--green); }
.badge-red     { background: var(--red-dim);    color: var(--red); }
.badge-yellow  { background: var(--yellow-dim); color: var(--yellow); }
.badge-blue    { background: var(--blue-dim);   color: var(--blue); }
.badge-orange  { background: var(--orange-dim); color: var(--orange); }
.badge-purple  { background: var(--purple-dim); color: var(--purple); }
.badge-gray    { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* --- Forms & Inputs --- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}

.form-select option { background: var(--bg-card); }
.form-textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #07120a;
}
.btn-primary:hover {
  background: #00f0ba;
  box-shadow: var(--green-glow);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid transparent;
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-blue {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid transparent;
}
.btn-blue:hover { background: var(--blue); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* --- Alerts --- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border-left: 4px solid;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--red-dim);    border-color: var(--red);    color: #fca5a5; }
.alert-warning { background: var(--yellow-dim); border-color: var(--yellow); color: #fcd34d; }
.alert-success { background: var(--green-dim);  border-color: var(--green);  color: #6ee7b7; }
.alert-info    { background: var(--blue-dim);   border-color: var(--blue);   color: #93c5fd; }

/* --- Modal --- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--red); }

.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* --- Progress Bar --- */
.progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3   { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p    { font-size: 13px; }

/* --- Filters row --- */
.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filters-row .form-control,
.filters-row .form-select { max-width: 180px; }

/* --- Tipo icons --- */
.tipo-entrada { color: var(--green); font-weight: 700; }
.tipo-saida   { color: var(--red);   font-weight: 700; }

/* --- Value colors --- */
.val-positive { color: var(--green); font-weight: 600; }
.val-negative { color: var(--red);   font-weight: 600; }
.val-neutral  { color: var(--text-primary); }

/* --- Action buttons --- */
.action-btns { display: flex; gap: 6px; }
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
}
.btn-icon:hover.edit { border-color: var(--blue); color: var(--blue); }
.btn-icon:hover.delete { border-color: var(--red); color: var(--red); }
.btn-icon:hover.pay { border-color: var(--green); color: var(--green); }

/* --- Pendência item --- */
.pend-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: all var(--transition);
}
.pend-item:hover { border-right-color: rgba(255,255,255,0.1); }
.pend-item.urgente   { border-left-color: var(--red); }
.pend-item.parcial   { border-left-color: var(--yellow); }
.pend-item.pendente  { border-left-color: var(--orange); }

.pend-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pend-title  { font-size: 15px; font-weight: 700; }
.pend-meta   { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.pend-values { display: flex; gap: 24px; flex-wrap: wrap; }
.pend-val    { display: flex; flex-direction: column; }
.pend-val-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 2px; }
.pend-val-num   { font-size: 16px; font-weight: 700; }

/* --- Pagamentos Histórico --- */
.hist-list { list-style: none; }
.hist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.hist-item:last-child { border-bottom: none; }

/* --- Empréstimos --- */
.emp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.emp-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  flex-shrink: 0;
}

/* --- Calendário --- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  min-height: 80px;
  font-size: 12px;
}
.cal-day.today { border-color: var(--green); }
.cal-day.other-month { opacity: 0.35; }
.cal-day-num { font-weight: 700; margin-bottom: 4px; font-size: 13px; }
.cal-event {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.entrada { background: var(--green-dim); color: var(--green); }
.cal-event.saida   { background: var(--red-dim);   color: var(--red); }

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-big { font-size: 48px; }
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--green); margin-top: 8px; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open .logo-text,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .user-details { display: flex !important; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar.mobile-open .sidebar-logo { justify-content: flex-start; padding: 20px 18px; }
  .sidebar.mobile-open .user-info { justify-content: flex-start; }

  .main-content { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .charts-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .filters-row .form-control,
  .filters-row .form-select { max-width: 100%; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}

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

@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.pulse-alert { animation: pulse-red 2s infinite; }

/* --- Misc utils --- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; gap: 10px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Tip / Saldo devedor highlight */
.saldo-devedor-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}
