/* ================================================================
   HFMS — Home Finance Management System
   Custom stylesheet — Bootstrap 5 base, no build step
   ================================================================ */

/* ── Root Variables ────────────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --topbar-height: 0px;
  --card-radius: 12px;
  --body-bg: #f1f5f9;
  --kpi-radius: 10px;
}

/* ── Layout ────────────────────────────────────────────────────── */
body {
  background: var(--body-bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
}

.wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
}
.sidebar-brand .brand-sub {
  font-size: .7rem;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #475569;
  font-weight: 600;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav .nav-link i {
  font-size: 1rem;
  width: 18px;
  flex-shrink: 0;
}
.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: rgba(59,130,246,0.18);
  color: var(--sidebar-active);
  font-weight: 600;
  border-right: 3px solid var(--sidebar-active);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: .8rem;
}
.sidebar-footer .user-name {
  color: #e2e8f0;
  font-weight: 500;
}
.sidebar-footer .logout-link {
  color: #64748b;
  text-decoration: none;
  font-size: .75rem;
}
.sidebar-footer .logout-link:hover { color: #ef4444; }

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

/* ── Page Header ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}
.page-header h1 i { opacity: .7; margin-right: 6px; }

/* ── KPI Cards ─────────────────────────────────────────────────── */
.kpi-card {
  border-radius: var(--kpi-radius);
  padding: 18px 20px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #fff;
  height: 100%;
}
.kpi-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #64748b;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.kpi-sub {
  font-size: .72rem;
  margin-top: 4px;
}

/* KPI colour variants */
.kpi-primary { border-top: 3px solid #3b82f6; }
.kpi-success { border-top: 3px solid #22c55e; }
.kpi-danger  { border-top: 3px solid #ef4444; }
.kpi-warning { border-top: 3px solid #f59e0b; }
.kpi-info    { border-top: 3px solid #06b6d4; }

/* Mini KPI inside cards */
.kpi-mini-label { font-size: .65rem; text-transform: uppercase; color: #94a3b8; letter-spacing: .06em; }
.kpi-mini       { font-size: 1rem; font-weight: 700; color: #0f172a; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: .875rem;
  color: #374151;
  padding: 12px 16px;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}
.card-body { background: #fff; border-radius: inherit; }
.card-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 var(--card-radius) var(--card-radius) !important;
  padding: 10px 16px;
}

/* ── Account Cards ─────────────────────────────────────────────── */
.account-card {
  display: block;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 5px solid #3b82f6;
  border-radius: var(--card-radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .1s;
}
.account-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.account-name   { font-weight: 600; font-size: .875rem; color: #1e293b; }
.account-type   { text-transform: capitalize; }
.account-balance { font-size: 1.25rem; font-weight: 700; margin-top: 8px; color: #0f172a; }

.account-card-full {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  padding: 16px;
  height: 100%;
}

/* ── Transactions Table ────────────────────────────────────────── */
.tx-table td, .tx-table th {
  vertical-align: middle;
  padding: 10px 12px;
}
.tx-table tbody tr:hover { background: #f8fafc; }

/* color dot */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* ── Flash Messages ────────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.flash-msg {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.flash-success { background: #dcfce7; color: #166534; border-left: 4px solid #22c55e; }
.flash-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.flash-warning { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }
.flash-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}
.empty-state i {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  opacity: .4;
}

/* ── Progress bars ─────────────────────────────────────────────── */
.progress { border-radius: 100px; background: #f1f5f9; }
.progress-bar { border-radius: 100px; }

/* ── Badges / Buttons ──────────────────────────────────────────── */
.badge { font-weight: 500; }
.btn-xs { padding: 2px 6px; font-size: .75rem; }

/* ── Modals ────────────────────────────────────────────────────── */
.modal-content { border-radius: var(--card-radius); border: none; }
.modal-header { border-bottom: 1px solid #e2e8f0; }
.modal-footer { border-top: 1px solid #e2e8f0; }

/* ── Table sticky head ─────────────────────────────────────────── */
.sticky-top th { position: sticky; top: 0; z-index: 1; }

/* ── Responsive: mobile sidebar ───────────────────────────────── */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .mobile-menu-btn {
    display: block !important;
  }
  .kpi-value { font-size: 1.25rem; }
}

/* ── Mobile menu button (hidden on desktop) ────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1050;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
}

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

/* ── Loan progress ─────────────────────────────────────────────── */
.table-success td { background: rgba(34,197,94,0.06) !important; }
.table-danger  td { background: rgba(239,68,68,0.06)  !important; }
.table-warning td { background: rgba(245,158,11,0.06) !important; }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination .page-link {
  border-color: #e2e8f0;
  color: #374151;
  font-size: .8rem;
}
.pagination .page-item.active .page-link {
  background: #3b82f6;
  border-color: #3b82f6;
}

/* ── Scrollbar (webkit) ────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
