/* ============================================================
   FINANZAS PERSONALES - Estilos principales
   Tema: Fintech moderno (inspirado en Nubank/Ualá)
   ============================================================ */

:root {
  --primary:   #2563eb;
  --primary-light: #dbeafe;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #06b6d4;
  --dark:      #1f2937;
  --muted:     #6b7280;
  --sidebar-w: 260px;
  --sidebar-bg: #1e1e2e;
  --topbar-h:  64px;
  --radius:    12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07),0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08),0 4px 6px rgba(0,0,0,.05);
  --font:      'Inter', system-ui, sans-serif;
}

/* Dark mode */
[data-bs-theme="dark"] {
  --bs-body-bg: #111827;
  --bs-body-color: #e5e7eb;
  --bs-card-bg: #1f2937;
  --bs-border-color: #374151;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: #f8fafc;
  color: #1f2937;
}

[data-bs-theme="dark"] body { background: #111827; }

/* ─── Layout ─── */
.wrapper { min-height: 100vh; overflow-x: hidden; }

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin .3s ease;
  display: flex;
  flex-direction: column;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-brand i { color: var(--primary); font-size: 1.3rem; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-user .avatar-lg {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  flex-shrink: 0;
}

.sidebar-user .fw-semibold { color: #fff; }
.sidebar-user .text-muted  { color: rgba(255,255,255,.5) !important; }

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav .nav-label {
  padding: 8px 20px 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: 0;
  transition: all .2s;
  font-size: .86rem;
  font-weight: 500;
  position: relative;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  color: #fff;
  background: rgba(255,255,255,.08);
}

.sidebar-nav li a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.sidebar-nav li a i { width: 18px; text-align: center; font-size: .9rem; }

.sidebar-nav .badge-pill {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-score {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}

.sidebar-score .fw-medium { color: rgba(255,255,255,.8); font-size: .8rem; }
.sidebar-score .fw-bold   { font-size: .85rem; }
.sidebar-score .text-muted { color: rgba(255,255,255,.4) !important; }

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

[data-bs-theme="dark"] .topbar {
  background: #1f2937;
  border-color: #374151;
}

.topbar .btn-link { color: var(--dark); }
[data-bs-theme="dark"] .topbar .btn-link { color: #e5e7eb; }

/* Notification badge */
.badge-dot {
  position: absolute;
  top: -2px; right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
}

/* Avatar pequeño */
.avatar-sm {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

/* Notif dropdown */
.notif-dropdown { border: none; box-shadow: var(--shadow-lg); }
.notif-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

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

/* ─── KPI Cards ─── */
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-income   { border-color: var(--success); background: linear-gradient(135deg,#fff,#ecfdf5); }
.kpi-expense  { border-color: var(--danger);  background: linear-gradient(135deg,#fff,#fef2f2); }
.kpi-balance  { border-color: var(--primary); background: linear-gradient(135deg,#fff,#eff6ff); }
.kpi-projection{ border-color: var(--info);   background: linear-gradient(135deg,#fff,#ecfeff); }

.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 12px;
  background: rgba(255,255,255,.7);
}

.kpi-income   .kpi-icon { color: var(--success); }
.kpi-expense  .kpi-icon { color: var(--danger);  }
.kpi-balance  .kpi-icon { color: var(--primary); }
.kpi-projection .kpi-icon { color: var(--info);  }

.kpi-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.kpi-value { font-size: 1.4rem; font-weight: 700; color: var(--dark); margin-bottom: 4px; }
.kpi-sub   { font-size: .75rem; }

[data-bs-theme="dark"] .kpi-card { background: #1f2937; }
[data-bs-theme="dark"] .kpi-income    { background: linear-gradient(135deg,#1f2937,#052e16); }
[data-bs-theme="dark"] .kpi-expense   { background: linear-gradient(135deg,#1f2937,#2d1414); }
[data-bs-theme="dark"] .kpi-balance   { background: linear-gradient(135deg,#1f2937,#1e3a5f); }
[data-bs-theme="dark"] .kpi-projection{ background: linear-gradient(135deg,#1f2937,#0c3441); }
[data-bs-theme="dark"] .kpi-value { color: #f9fafb; }

/* ─── Cards ─── */
.card {
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

[data-bs-theme="dark"] .card {
  background: #1f2937;
  border-color: #374151;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #e5e7eb;
  padding: 14px 20px;
}

[data-bs-theme="dark"] .card-header { border-color: #374151; }

/* ─── Auth pages ─── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-wrapper { width: 100%; max-width: 420px; }

.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand i { font-size: 2.5rem; margin-bottom: 8px; display: block; }

.demo-hint {
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .8rem;
  color: #1d4ed8;
}

/* ─── Tarjeta de crédito 3D ─── */
.credit-card-3d {
  border-radius: 16px;
  padding: 22px;
  color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.1);
  position: relative;
  overflow: hidden;
  min-height: 160px;
}

.credit-card-3d::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}

.credit-card-3d::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -30px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}

.cc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.cc-number  { font-size: 1.05rem; letter-spacing: .18em; margin-bottom: 20px; opacity: .9; }
.cc-footer  { display: flex; justify-content: space-between; gap: 12px; }
.cc-label   { font-size: .6rem; opacity: .7; text-transform: uppercase; letter-spacing: .05em; }
.cc-value   { font-size: .82rem; font-weight: 600; }

/* Credit card widget (pequeño) */
.credit-card-widget {
  background: var(--primary-light);
  border-radius: 10px;
  padding: 12px;
  border-left: 3px solid var(--card-color, var(--primary));
}

/* ─── Categoría badges ─── */
.cat-badge, .cat-dot {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; flex-shrink: 0;
}

/* ─── Estadísticas mini ─── */
.stat-mini {
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .85rem;
}

/* ─── Alert icon ─── */
.alert-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Metas ─── */
.meta-item { position: relative; }
.meta-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Factura card ─── */
.factura-card { border-width: 1px 1px 1px 4px !important; }

/* ─── Color swatches ─── */
.color-swatch {
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid rgba(0,0,0,.1);
  cursor: pointer;
  transition: transform .15s;
}
.color-swatch:hover { transform: scale(1.2); }

/* ─── Icon selector metas ─── */
/* Scope padding reset only to icon-opt containers; preserves Bootstrap's
   default padding-left:1.5em on regular radio/checkbox form-checks */
.form-check:has(.icon-opt) { padding: 0; }
.icon-opt {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid #e5e7eb;
  color: var(--muted);
  transition: all .2s;
}

.form-check-input:checked ~ .form-check-label.icon-opt {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ─── Tables ─── */
.table { margin-bottom: 0; }
.table > thead { background: #f9fafb; }
.table > thead th { font-size: .75rem; font-weight: 600; text-transform: uppercase;
                    letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid #e5e7eb; }
.table-hover tbody tr:hover { background: #f9fafb; }
[data-bs-theme="dark"] .table > thead { background: #111827; }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background: #374151; }

/* ─── Buttons ─── */
.btn { border-radius: 8px; font-weight: 500; font-size: .85rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-success { background: var(--success); border-color: var(--success); }

/* ─── Forms ─── */
.form-control, .form-select {
  border-radius: 8px;
  border-color: #d1d5db;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.input-group-text { border-color: #d1d5db; background: #f9fafb; }

/* ─── Responsive / Mobile ─── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .kpi-value { font-size: 1.1rem; }
  .credit-card-3d { min-height: 140px; }
  /* Botones de tarjetas de facturas: permitir wrap en pantallas estrechas */
  .factura-card .card-body .d-flex.gap-1 { flex-wrap: wrap; }
  /* Labels de radio/checkbox: evitar truncado por overflow del card */
  .form-check-label { white-space: nowrap; }
}

/* ─── Animaciones ─── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card, .kpi-card { animation: fadeInUp .4s ease both; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ─── Misc ─── */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Overlay para móvil sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }
