/* ═══════════════════════════════════════════════════════════
   Budget-X — Custom Styles (Expanded)
   Complementary to Tailwind CSS
   ═══════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }
.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ── Navigation Links ───────────────────────────────────── */
.nav-link { color: #64748b; }
.nav-link:hover { background: #f1f5f9; color: #334155; }
.dark .nav-link { color: #94a3b8; }
.dark .nav-link:hover { background: #1e293b; color: #e2e8f0; }
.nav-link.active { background: #eef2ff; color: #4f46e5; }
.dark .nav-link.active { background: rgba(99, 102, 241, 0.15); color: #818cf8; }

/* ── Type Buttons (Modal) ───────────────────────────────── */
.type-btn { border-color: #e2e8f0; color: #64748b; background: transparent; }
.type-btn:hover { border-color: #c7d2fe; color: #4f46e5; background: #f5f3ff; }
.dark .type-btn { border-color: #334155; color: #94a3b8; }
.dark .type-btn:hover { border-color: #6366f1; color: #a5b4fc; background: rgba(99,102,241,0.1); }
.type-btn.selected { border-color: #6366f1; color: #4f46e5; background: #eef2ff; }
.dark .type-btn.selected { border-color: #818cf8; color: #a5b4fc; background: rgba(99,102,241,0.15); }

/* ── Modal Animations ───────────────────────────────────── */
#modal.active, #confirmModal.active { display: flex; }
#modal .modal-box, #confirmModal .modal-box { animation: modalSlideUp 0.25s ease-out; }
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Toast ──────────────────────────────────────────────── */
.toast { pointer-events: auto; animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(24px); } }

/* ── Badges ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; line-height: 1.25rem; }
.badge-ingreso         { background: #dcfce7; color: #166534; }
.badge-gasto           { background: #fee2e2; color: #991b1b; }
.badge-transferencia   { background: #dbeafe; color: #1e40af; }
.badge-pago_deuda      { background: #fef9c3; color: #854d0e; }
.badge-aporte_ahorro   { background: #e0e7ff; color: #3730a3; }
.badge-retiro_ahorro   { background: #fce7f3; color: #9d174d; }
.badge-aporte_inversion{ background: #ccfbf1; color: #115e59; }
.badge-retiro_inversion{ background: #fef3c7; color: #92400e; }

.dark .badge-ingreso         { background: rgba(34,197,94,0.15); color: #4ade80; }
.dark .badge-gasto           { background: rgba(239,68,68,0.15); color: #f87171; }
.dark .badge-transferencia   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.dark .badge-pago_deuda      { background: rgba(234,179,8,0.15); color: #facc15; }
.dark .badge-aporte_ahorro   { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.dark .badge-retiro_ahorro   { background: rgba(236,72,153,0.15); color: #f472b6; }
.dark .badge-aporte_inversion{ background: rgba(20,184,166,0.15); color: #2dd4bf; }
.dark .badge-retiro_inversion{ background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ── Cards ──────────────────────────────────────────────── */
.kpi-card, .account-card, .entity-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-card:hover, .account-card:hover, .entity-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(0,0,0,0.08);
}
.dark .kpi-card:hover, .dark .account-card:hover, .dark .entity-card:hover {
  box-shadow: 0 8px 25px -5px rgba(0,0,0,0.3);
}

/* ── Chart Container ────────────────────────────────────── */
.chart-container { position: relative; width: 100%; max-height: 320px; }
.chart-container-tall { position: relative; width: 100%; max-height: 400px; }

/* ── Input Styles ───────────────────────────────────────── */
.input-field {
  width: 100%; padding: 0.5rem 0.75rem; border-radius: 0.75rem;
  border: 1px solid #e2e8f0; background: #fff; color: #1e293b;
  font-size: 0.875rem; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-field:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.dark .input-field { border-color: #334155; background: #0f172a; color: #e2e8f0; }
.dark .input-field:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,0.15); }

/* ── Table ──────────────────────────────────────────────── */
.history-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.history-table th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc; padding: 0.75rem 1rem; text-align: left;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #64748b; border-bottom: 1px solid #e2e8f0;
}
.dark .history-table th { background: #0f172a; color: #94a3b8; border-bottom-color: #1e293b; }
.history-table td { padding: 0.75rem 1rem; font-size: 0.875rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.dark .history-table td { border-bottom-color: #1e293b; }
.history-table tbody tr { transition: background 0.1s; }
.history-table tbody tr:hover { background: #f8fafc; }
.dark .history-table tbody tr:hover { background: #1e293b; }

/* ── Empty State ────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; color: #94a3b8; }

/* ── FAB Pulse ──────────────────────────────────────────── */
#fab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 9999px;
  border: 2px solid rgba(99,102,241,0.4);
  animation: fabPulse 2s ease-out infinite; pointer-events: none;
}
@keyframes fabPulse { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }

/* ── Progress Bar ───────────────────────────────────────── */
.progress-track { width: 100%; height: 8px; border-radius: 9999px; background: #e2e8f0; overflow: hidden; }
.dark .progress-track { background: #1e293b; }
.progress-fill { height: 100%; border-radius: 9999px; transition: width 0.5s ease; }
.progress-fill.green   { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-fill.brand   { background: linear-gradient(90deg, #6366f1, #4f46e5); }
.progress-fill.amber   { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-fill.red     { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-fill.cyan    { background: linear-gradient(90deg, #06b6d4, #0891b2); }

/* ── Budget bar colors ──────────────────────────────────── */
.budget-ok    { background: linear-gradient(90deg, #22c55e, #16a34a); }
.budget-warn  { background: linear-gradient(90deg, #f59e0b, #d97706); }
.budget-over  { background: linear-gradient(90deg, #ef4444, #dc2626); }

/* ── Filter Pills ───────────────────────────────────────── */
.filter-pill {
  padding: 0.375rem 0.875rem; border-radius: 9999px; font-size: 0.8125rem;
  font-weight: 500; border: 1px solid #e2e8f0; color: #64748b; background: transparent;
  cursor: pointer; transition: all 0.15s;
}
.filter-pill:hover { background: #f1f5f9; color: #334155; }
.filter-pill.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.dark .filter-pill { border-color: #334155; color: #94a3b8; }
.dark .filter-pill:hover { background: #1e293b; color: #e2e8f0; }
.dark .filter-pill.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .history-table th, .history-table td { padding: 0.5rem 0.625rem; font-size: 0.8125rem; }
  #fab { bottom: 1.25rem; right: 1.25rem; width: 3rem; height: 3rem; }
  #fab i { width: 1.5rem; height: 1.5rem; }
  #toastContainer { bottom: 5rem; right: 1rem; left: 1rem; }
  .modal-box { border-radius: 1rem; max-height: 95vh; }
  .kpi-card { padding: 1rem; }
}

/* ── Tag Pills ──────────────────────────────────────────── */
.tag-pill { cursor: default; transition: opacity 0.15s; }
.tag-pill:hover { opacity: 0.85; }
.tag-pill button { cursor: pointer; font-weight: 700; }

/* ── Health Score Ring ───────────────────────────────────── */
.stroke-emerald-500 { stroke: #22c55e; }
.stroke-blue-500 { stroke: #3b82f6; }
.stroke-amber-500 { stroke: #f59e0b; }
.stroke-red-500 { stroke: #ef4444; }

/* ── Envelope allocation bar ────────────────────────────── */
.h-6 > div { transition: width 0.5s ease; }

/* ── Checkbox Styling ───────────────────────────────────── */
.env-cat-check {
  width: 1rem; height: 1rem; border-radius: 0.25rem; cursor: pointer;
  accent-color: #6366f1;
}
