/* ============================================================
   FinTrack Pro — Main Stylesheet
   Colors: #2E5077 | #4DA1A9 | #79D7BE | #F6F4F0
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────── */
:root {
  --primary:      #2E5077;
  --primary-light:#3a6494;
  --accent:       #4DA1A9;
  --highlight:    #79D7BE;
  --danger:       #e74c6b;
  --warning:      #f5a623;
  --success:      #27ae88;
  --info:         #4DA1A9;

  /* Dark theme (default) */
  --bg:           #0d1821;
  --bg-card:      #152030;
  --bg-card2:     #1a2d40;
  --bg-input:     #1e3448;
  --bg-sidebar:   #0a1520;
  --border:       rgba(77,161,169,.18);
  --text:         #e8eef4;
  --text-muted:   #7a9bb5;
  --text-sidebar: #8fb3cc;
  --shadow:       0 4px 24px rgba(0,0,0,.45);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.3);

  /* Sidebar */
  --sidebar-w: 250px;
  --topbar-h:  62px;

  /* Transitions */
  --transition: .22s ease;
}

/* ── Light Theme ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #F6F4F0;
  --bg-card:   #ffffff;
  --bg-card2:  #f0ede8;
  --bg-input:  #ffffff;
  --bg-sidebar:#2E5077;
  --border:    rgba(46,80,119,.14);
  --text:      #1a2d3e;
  --text-muted:#5a7a92;
  --text-sidebar:#c8dcea;
  --shadow:    0 4px 24px rgba(46,80,119,.12);
  --shadow-sm: 0 2px 8px rgba(46,80,119,.08);
}

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

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: .925rem;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

h1,h2,h3,h4,h5,h6 { font-family: 'Outfit', sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--highlight); }
code { color: var(--highlight); background: var(--bg-card2); padding: .1em .4em; border-radius: 4px; }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.brand-icon {
  font-size: 1.6rem;
  color: var(--highlight);
}

.brand-text {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.brand-text .accent { color: var(--highlight); }

.sidebar-nav {
  padding: .75rem 0 2rem;
  flex: 1;
}

.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-sidebar);
  padding: 1rem 1.2rem .35rem;
  opacity: .6;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem 1.2rem;
  color: var(--text-sidebar);
  font-size: .895rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition), border-left var(--transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(77,161,169,.1);
  color: var(--highlight);
  border-left-color: var(--accent);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(77,161,169,.18) 0%, transparent 100%);
  color: var(--highlight);
  border-left-color: var(--highlight);
  font-weight: 600;
}

.nav-item i { font-size: 1rem; min-width: 1rem; }

/* ── Main Wrapper ─────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.page-content {
  padding: 1.5rem;
  max-width: 1600px;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.5rem;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  color: var(--text);
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  padding: 0;
}

.btn-icon:hover, .btn-user:hover {
  background: var(--bg-card2);
  color: var(--highlight);
  border-color: var(--accent);
}

.btn-user {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 .75rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

/* Search box */
.search-box {
  position: relative;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .75rem .45rem 2.1rem;
  width: 200px;
  font-size: .875rem;
  transition: width var(--transition), border-color var(--transition);
}

.search-input:focus {
  width: 260px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,161,169,.15);
  outline: none;
}

.search-icon {
  position: absolute;
  left: .65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: none;
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}

.search-results.show { display: block; }
.search-result-item {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover { background: var(--bg-card2); }
.search-result-item:last-child { border-bottom: none; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.card-body { padding: 1.25rem; }

/* ── Metric / Stat Cards ──────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--stat-color, var(--accent));
  opacity: .08;
  transform: translate(20px, -20px);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--stat-color, var(--accent));
  color: #fff;
  margin-bottom: .9rem;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-badge {
  font-size: .75rem;
  padding: .2em .55em;
  border-radius: 20px;
}

/* ── Bank Account Card ────────────────────────────────── */
.bank-card {
  background: linear-gradient(135deg, var(--bank-color, var(--primary)) 0%, var(--bank-color2, var(--accent)) 100%);
  border-radius: 16px;
  color: #fff;
  padding: 1.4rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.bank-card::after {
  content: '';
  position: absolute;
  bottom: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

.bank-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,.35); }

.bank-card .bank-name { font-size: .8rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.bank-card .bank-balance { font-family: 'Outfit', sans-serif; font-size: 1.8rem; font-weight: 700; margin: .4rem 0 .2rem; }
.bank-card .bank-account-no { font-size: .8rem; opacity: .7; }
.bank-card .bank-icon { position: absolute; top: 1rem; right: 1.2rem; font-size: 2rem; opacity: .3; }

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  transition: opacity var(--transition), transform var(--transition);
}

.btn-primary:hover { opacity: .9; transform: translateY(-1px); color: #fff; }

.btn-success {
  background: linear-gradient(135deg, #1d7a56, var(--success));
  border: none; color: #fff; font-weight: 600; border-radius: 8px;
}

.btn-danger {
  background: linear-gradient(135deg, #a0203a, var(--danger));
  border: none; color: #fff; font-weight: 600; border-radius: 8px;
}

.btn-outline-primary {
  border-color: var(--accent);
  color: var(--accent);
  border-radius: 8px;
}

.btn-outline-primary:hover {
  background: var(--accent);
  color: #fff;
}

.btn-login {
  padding: .7rem;
  font-size: 1rem;
  letter-spacing: .02em;
}

/* ── Forms ────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-input);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(77,161,169,.18);
}

.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: .875rem; font-weight: 500; color: var(--text-muted); margin-bottom: .35rem; }
.input-group-text { background: var(--bg-card2); border-color: var(--border); color: var(--text-muted); }

/* ── Tables ───────────────────────────────────────────── */
.table {
  color: var(--text);
  border-color: var(--border);
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
}

.table thead th {
  background: var(--bg-card2);
  border-color: var(--border);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: .75rem 1rem;
}

.table tbody td {
  border-color: var(--border);
  padding: .75rem 1rem;
  vertical-align: middle;
}

.table tbody tr:hover { background: rgba(77,161,169,.05); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: .3rem .6rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted); font-size: .85rem; }
.dataTables_wrapper .paginate_button { color: var(--text-muted) !important; border-radius: 6px !important; }
.dataTables_wrapper .paginate_button.current { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }

/* ── Badges ───────────────────────────────────────────── */
.badge { font-weight: 500; letter-spacing: .02em; }
.badge.bg-success { background: var(--success) !important; }
.badge.bg-danger  { background: var(--danger) !important; }
.badge.bg-warning { background: var(--warning) !important; color: #1a2535 !important; }

/* ── Alerts ───────────────────────────────────────────── */
.alert { border-radius: 10px; border: 1px solid var(--border); }
.alert-danger { background: rgba(231,76,107,.12); border-color: rgba(231,76,107,.3); color: #ff8aa0; }
.alert-success { background: rgba(39,174,136,.12); border-color: rgba(39,174,136,.3); color: #5de8b8; }
.alert-warning { background: rgba(245,166,35,.12); border-color: rgba(245,166,35,.3); color: #ffd080; }
.alert-sm { padding: .55rem .85rem; font-size: .875rem; }

/* ── Login Page ───────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-bg {
  position: fixed; inset: 0; z-index: -1;
  background: var(--bg);
}

.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .35;
}

.login-glow.g1 {
  width: 400px; height: 400px;
  background: var(--primary);
  top: -80px; left: -80px;
}

.login-glow.g2 {
  width: 350px; height: 350px;
  background: var(--accent);
  bottom: -60px; right: -60px;
}

.login-wrapper { width: 100%; max-width: 420px; padding: 1rem; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 70px; height: 70px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  margin: 0 auto 1.2rem;
}

.login-title { font-size: 1.9rem; font-weight: 800; color: var(--text); margin-bottom: .2rem; }
.login-title .accent { color: var(--highlight); }
.login-subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.login-hint { font-size: .8rem; color: var(--text-muted); }
.login-card .form-label { text-align: left; display: block; }

/* ── Sidebar Overlay (mobile) ─────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1040;
}

/* ── Mobile Responsive ────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-wrapper { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .page-content { padding: 1rem; }
  .stat-value { font-size: 1.3rem; }
  .search-input { width: 160px; }
  .search-input:focus { width: 200px; }
}

@media (max-width: 575.98px) {
  .page-content { padding: .75rem; }
  .stat-value { font-size: 1.15rem; }
  .bank-balance { font-size: 1.4rem !important; }
}

/* ── Dropdown (dark theme) ────────────────────────────── */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.dropdown-item {
  color: var(--text);
  font-size: .9rem;
  border-radius: 6px;
  margin: .15rem .25rem;
  padding: .45rem .85rem;
}

.dropdown-item:hover { background: var(--bg-card2); color: var(--highlight); }
.dropdown-divider { border-color: var(--border); }

/* ── Modal (dark theme) ───────────────────────────────── */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
}

.modal-header {
  border-bottom-color: var(--border);
  background: var(--bg-card2);
  border-radius: 16px 16px 0 0;
}

.modal-footer { border-top-color: var(--border); }
.btn-close { filter: invert(1) opacity(.6); }
[data-theme="light"] .btn-close { filter: none; }

/* ── Chart container ──────────────────────────────────── */
.chart-container { position: relative; }
canvas { max-width: 100%; }

/* ── Section heading ──────────────────────────────────── */
.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-title i { color: var(--accent); }

/* ── Nav Pills (tabs) ─────────────────────────────────── */
.nav-pills .nav-link {
  color: var(--text-muted);
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  padding: .4rem .9rem;
}

.nav-pills .nav-link.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

/* ── Progress bar ─────────────────────────────────────── */
.progress { background: var(--bg-card2); border-radius: 10px; height: 8px; }
.progress-bar { background: linear-gradient(90deg, var(--accent), var(--highlight)); }

/* ── Status indicator dot ─────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: .4rem;
}

.status-dot.active  { background: var(--success); }
.status-dot.overdue { background: var(--danger); animation: pulse 1.5s infinite; }
.status-dot.completed { background: var(--text-muted); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .3; }
}

/* ── Timeline (payment history) ───────────────────────── */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: .4rem; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-item::before { content: ''; position: absolute; left: -1.15rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg-card); }
.timeline-date { font-size: .78rem; color: var(--text-muted); }
.timeline-body { background: var(--bg-card2); border-radius: 8px; padding: .6rem .85rem; margin-top: .25rem; font-size: .875rem; }

/* ── Receipt print card & rows ────────────────────────── */
.receipt-card {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.print-row {
  display: flex;
  justify-content: space-between;
  padding: .4rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: .9rem;
}
.print-row:last-child { border-bottom: none; }
.print-row .label { color: var(--text-muted); font-weight: 500; }
.print-total { font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 700; text-align: center; margin-top: .75rem; }

/* ── Accent text ──────────────────────────────────────── */
.accent { color: var(--highlight); }
.text-accent { color: var(--accent); }
.text-income { color: var(--success); }
.text-expense { color: var(--danger); }

/* ── Page header ──────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h4 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
}

/* ── Overdue row highlight ───────────────────────────── */
tr.overdue-row { background: rgba(231,76,107,.06) !important; }
tr.overdue-row td { color: #ff8aa0; }

/* ── SweetAlert2 dark overrides ──────────────────────── */
.swal2-popup {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
}
.swal2-title { color: var(--text) !important; }
.swal2-content { color: var(--text-muted) !important; }
