/* ================================================================
   BankSim – Custom Stylesheet
   Companion to Bootstrap 5 + Bootstrap Icons
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ----------------------------------------------------------------
   Root Variables
   ---------------------------------------------------------------- */
:root {
  --font:           'Inter', system-ui, -apple-system, sans-serif;

  /* Brand colours */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;

  /* Sidebar */
  --sb-width:         260px;
  --sb-bg:            #0f172a;
  --sb-header-bg:     #1e293b;
  --sb-text:          #94a3b8;
  --sb-text-hover:    #e2e8f0;
  --sb-active-bg:     rgba(37,99,235,.16);
  --sb-active-text:   #60a5fa;
  --sb-active-bar:    #3b82f6;
  --sb-hover-bg:      rgba(255,255,255,.045);
  --sb-border:        rgba(255,255,255,.07);

  /* Surfaces */
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-muted:     #64748b;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 25px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  /* Radii */
  --r-sm:   0.375rem;
  --r:      0.75rem;
  --r-lg:   1rem;
  --r-xl:   1.25rem;

  /* Topbar */
  --topbar-h: 60px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ================================================================
   SIDEBAR LAYOUT  (Superuser)
   ================================================================ */
.sb-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar panel --- */
.sb-sidebar {
  width: var(--sb-width);
  flex-shrink: 0;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.sb-sidebar::-webkit-scrollbar { width: 3px; }
.sb-sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* Brand */
.sb-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  background: var(--sb-header-bg);
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  text-decoration: none;
}
.sb-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.sb-brand-name  { font-size: 1rem; font-weight: 700; color: #f1f5f9; letter-spacing: -.01em; }
.sb-brand-sub   { font-size: .68rem; color: var(--sb-text); margin-top: -1px; }

/* User chip */
.sb-user {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem; color: #fff; flex-shrink: 0;
}
.sb-user-name {
  font-size: .825rem; font-weight: 600; color: #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-user-role {
  font-size: .68rem; color: var(--sb-text);
  text-transform: uppercase; letter-spacing: .06em;
}

/* Nav */
.sb-nav { flex: 1; padding: .5rem 0; }
.sb-nav-label {
  font-size: .66rem; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: .08em;
  padding: .85rem 1.25rem .3rem;
}
.sb-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .575rem 1.25rem;
  color: var(--sb-text);
  font-size: .845rem; font-weight: 500;
  transition: all .15s ease;
  border-left: 3px solid transparent;
  margin: .05rem 0;
  text-decoration: none;
}
.sb-link:hover { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.sb-link.active {
  background: var(--sb-active-bg); color: var(--sb-active-text);
  border-left-color: var(--sb-active-bar);
}
.sb-link i { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }
.sb-link .badge { margin-left: auto; font-size: .65rem; }

/* Footer */
.sb-footer {
  padding: .5rem 0;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-link-danger { color: #f87171 !important; }
.sb-link-danger:hover { background: rgba(220,38,38,.12) !important; color: #fca5a5 !important; }

/* Overlay */
.sb-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.52); z-index: 1039;
  opacity: 0; transition: opacity .28s ease;
}
.sb-overlay.open { display: block; opacity: 1; }

/* Main content */
.sb-main {
  flex: 1; margin-left: var(--sb-width);
  min-width: 0; display: flex; flex-direction: column; min-height: 100vh;
}

/* Topbar */
.sb-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: .875rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.sb-topbar-toggle {
  display: none;
  background: none; border: 1px solid var(--border);
  font-size: 1.2rem; color: var(--text-muted);
  cursor: pointer; padding: .3rem .45rem;
  border-radius: var(--r-sm); line-height: 1;
  transition: background .15s;
}
.sb-topbar-toggle:hover { background: var(--bg); }
.sb-topbar-title { font-size: .9375rem; font-weight: 600; color: var(--text); margin: 0; }

/* Page content */
.sb-content { flex: 1; padding: 1.5rem; }

/* ================================================================
   HORIZONTAL NAVBAR  (Admin / Manager / Consumer)
   ================================================================ */
.app-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 0 1.25rem;
  min-height: 60px;
}
.app-navbar .navbar-brand {
  font-weight: 700; font-size: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.app-navbar .brand-pill {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; color: #fff;
}
.app-navbar .nav-link {
  font-size: .845rem; font-weight: 500;
  color: var(--text-muted) !important;
  padding: .35rem .7rem !important;
  border-radius: var(--r-sm);
  transition: all .15s;
  display: flex; align-items: center; gap: .35rem;
}
.app-navbar .nav-link:hover { background: var(--bg); color: var(--text) !important; }
.app-navbar .nav-link.active {
  background: var(--primary-light) !important; color: var(--primary) !important;
}

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; flex-wrap: wrap;
  gap: .75rem; margin-bottom: 1.5rem;
}
.page-header h2, .page-header h3 {
  margin: 0; font-weight: 700; color: var(--text);
  font-size: 1.3rem; letter-spacing: -.02em;
}
.page-header p { font-size: .845rem; color: var(--text-muted); margin: .2rem 0 0; }

/* ================================================================
   STAT CARDS
   ================================================================ */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1.25rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.stat-value { font-size: 1.55rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; font-weight: 500; }

/* ================================================================
   CARDS (Bootstrap overrides)
   ================================================================ */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow) !important;
}
.card-header {
  border-radius: var(--r) var(--r) 0 0 !important;
  font-weight: 600; font-size: .9rem;
  border-bottom: 1px solid var(--border) !important;
}

/* ================================================================
   TABLES
   ================================================================ */
.table th {
  font-size: .74rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .055em;
  color: var(--text-muted); background: #f8fafc !important;
}
.table td { font-size: .875rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc !important; }

/* ================================================================
   FORMS
   ================================================================ */
.form-label { font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.form-control, .form-select {
  border-color: var(--border); font-size: .875rem;
  border-radius: var(--r-sm) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn { font-weight: 500; border-radius: var(--r-sm) !important; font-size: .875rem; }
.btn-sm { font-size: .8rem !important; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ================================================================
   BADGES
   ================================================================ */
.badge { font-weight: 500; font-size: .72rem; border-radius: 999px !important; padding: .3em .65em; }

/* ================================================================
   AUTH PAGE  (Login / Register)
   ================================================================ */
body.auth-page {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #312e81 100%);
  min-height: 100vh; display: flex; align-items: center; padding: 1rem;
}
.auth-wrap { width: 100%; max-width: 420px; margin: auto; }
.auth-card {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.auth-header {
  background: linear-gradient(135deg, #1e3a5f, #2563eb 70%, #4f46e5);
  padding: 2rem 2rem 1.75rem; text-align: center; color: #fff;
}
.auth-logo {
  width: 60px; height: 60px;
  background: rgba(255,255,255,.18);
  border-radius: var(--r); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1rem; border: 2px solid rgba(255,255,255,.25);
}
.auth-body { padding: 1.75rem 2rem 2rem; }
.auth-footer { padding: 1rem 2rem; background: #f8fafc; border-top: 1px solid var(--border); text-align: center; }
.auth-divider {
  display: flex; align-items: center; gap: .75rem;
  color: var(--text-muted); font-size: .8rem; margin: 1rem 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ================================================================
   CONSUMER – Balance Card & Quick Actions
   ================================================================ */
.balance-card {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #4f46e5 100%);
  border-radius: var(--r-lg); padding: 1.5rem 1.75rem;
  color: #fff; position: relative; overflow: hidden;
  box-shadow: 0 8px 24px rgba(37,99,235,.35);
}
.balance-card::before, .balance-card::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.balance-card::before { width: 140px; height: 140px; top: -40px; right: -30px; }
.balance-card::after  { width: 200px; height: 200px; bottom: -80px; right: 20px; }
.balance-label  { font-size: .75rem; opacity: .8; text-transform: uppercase; letter-spacing: .08em; }
.balance-amount { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: .3rem 0 0; }
.balance-currency { font-size: .85rem; opacity: .75; }

.quick-action {
  display: flex; flex-direction: column; align-items: center;
  gap: .5rem; padding: .875rem .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text);
  font-size: .775rem; font-weight: 500;
  transition: all .15s; text-align: center; text-decoration: none;
}
.quick-action:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-light); transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.quick-action i { font-size: 1.4rem; }

/* Loan status pill */
.loan-status { display: inline-flex; align-items: center; gap: .4rem; }
.loan-status::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; opacity: .7;
}

/* ================================================================
   ROLE-SPECIFIC THEME OVERRIDES
   ================================================================ */
/* Admin – blue-navy */
.theme-admin .app-navbar .brand-pill { background: #1d4ed8; }
.theme-admin .app-navbar .nav-link.active { background: #dbeafe !important; color: #1d4ed8 !important; }

/* Manager – violet */
.theme-manager .app-navbar .brand-pill { background: #7c3aed; }
.theme-manager .app-navbar .nav-link.active { background: #ede9fe !important; color: #7c3aed !important; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 767.98px) {
  .sb-sidebar { transform: translateX(-100%); }
  .sb-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sb-main { margin-left: 0; }
  .sb-topbar-toggle { display: flex; }
  .sb-content { padding: 1rem; }
  .balance-amount { font-size: 1.6rem; }
  .stat-value { font-size: 1.3rem; }
  .page-header { flex-direction: column; }
}
@media (min-width: 768px) {
  .sb-overlay { display: none !important; }
}
@media (max-width: 575px) {
  .auth-body { padding: 1.25rem 1.25rem 1.5rem; }
  .auth-header { padding: 1.5rem 1.25rem; }
}
