/* =========================================================
   PayLeap — Custom Design System
   ========================================================= */

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

/* ── Variables ──────────────────────────────────────────── */
:root {
  --tb-h: 56px;
  --bg: #f5f5f4;
  --card: #fff;
  --accent: #f97316;
  --accent-h: #ea580c;
  --accent-soft: rgba(249,115,22,.12);
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --nav-bg: #0d0d0d;
  --sh-sm: 0 1px 3px rgba(0,0,0,.07),0 1px 2px rgba(0,0,0,.04);
  --sh-md: 0 4px 12px rgba(0,0,0,.08),0 2px 4px rgba(0,0,0,.04);
  --sh-lg: 0 10px 24px rgba(0,0,0,.1),0 4px 8px rgba(0,0,0,.05);
  --r: 10px;
}

/* ── Reset ──────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.55;
  margin: 0;
}

/* ── Loading progress bar ───────────────────────────────── */
#nbar {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 0%; opacity: 0;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  z-index: 9999;
  transition: width .4s ease, opacity .3s ease;
  border-radius: 0 2px 2px 0;
}

/* ── Loading cursor ─────────────────────────────────────── */
body.is-loading,
body.is-loading * { cursor: wait !important }

/* ── Top Navigation Ribbon ──────────────────────────────── */
.topnav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--tb-h);
  background: var(--nav-bg);
  display: flex; align-items: center;
  padding: 0 16px;
  z-index: 1050;
  box-shadow: 0 2px 16px rgba(0,0,0,.4);
  gap: 0;
}

.tn-brand {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 700; font-size: .97rem; letter-spacing: -.2px;
  text-decoration: none; white-space: nowrap;
  padding-right: 18px; margin-right: 10px;
  border-right: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.tn-brand:hover { color: #fff }
.tn-brand i { color: var(--accent); font-size: 1.25rem }

.tn-links {
  display: flex; align-items: center; flex: 1; gap: 1px;
  overflow: visible;
}

.tn-links > a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 7px;
  color: rgba(255,255,255,.58);
  text-decoration: none; font-size: .81rem; font-weight: 500;
  white-space: nowrap; transition: all .14s ease; flex-shrink: 0;
}
.tn-links > a i { font-size: .8rem }
.tn-links > a:hover { background: rgba(255,255,255,.08); color: #fff }
.tn-links > a.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 10px rgba(249,115,22,.45);
}

/* ── Dropdown ───────────────────────────────────────────── */
.tn-dropdown { position: relative; flex-shrink: 0 }
.tn-drop-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 7px;
  color: rgba(255,255,255,.58); background: none; border: none;
  font-size: .81rem; font-weight: 500; cursor: pointer; font-family: inherit;
  white-space: nowrap; transition: all .14s ease;
}
.tn-drop-btn i { font-size: .8rem }
.tn-drop-btn .tn-caret { font-size: .58rem; margin-left: 1px; opacity: .7 }
.tn-drop-btn:hover { background: rgba(255,255,255,.08); color: #fff }
.tn-drop-btn.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 10px rgba(249,115,22,.45);
}

.tn-drop-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff; border-radius: var(--r);
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  border: 1px solid var(--border);
  padding: 5px; min-width: 190px;
  display: none; flex-direction: column;
  z-index: 1060; list-style: none; margin: 0;
}
/* Open on hover OR keyboard focus */
.tn-dropdown:hover .tn-drop-menu,
.tn-dropdown:focus-within .tn-drop-menu { display: flex }

.tn-item {
  display: flex !important; align-items: center; gap: 9px;
  padding: 8px 12px !important; border-radius: 7px !important;
  color: var(--text) !important; font-size: .83rem !important; font-weight: 500 !important;
  text-decoration: none; transition: background .1s; white-space: nowrap;
}
.tn-item:hover, .tn-item:focus { background: var(--accent-soft) !important; color: var(--accent) !important }
.tn-item i { color: var(--muted); font-size: .82rem; min-width: 16px }

/* ── Right side of topnav ───────────────────────────────── */
.tn-right {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto; flex-shrink: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(255,255,255,.1);
}
.role-chip {
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 9px; border-radius: 999px;
  font-size: .65rem; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  border: 1px solid rgba(249,115,22,.25);
}
.tn-username { font-size: .82rem; font-weight: 600; color: rgba(255,255,255,.85) }
.tn-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px;
  color: rgba(255,255,255,.48); text-decoration: none; font-size: 1rem;
  border: 1px solid rgba(255,255,255,.14);
  transition: all .14s ease;
}
.tn-logout:hover { background: rgba(239,68,68,.18); color: #fca5a5; border-color: rgba(239,68,68,.3) }

/* ── Main wrapper ───────────────────────────────────────── */
.main-wrap {
  padding-top: var(--tb-h);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Page content ───────────────────────────────────────── */
.page-content { flex: 1; padding: 22px 26px }

/* ── Cards ──────────────────────────────────────────────── */
.card { border: none !important; border-radius: var(--r) !important; box-shadow: var(--sh-sm); transition: box-shadow .15s ease }
.card:hover { box-shadow: var(--sh-md) }
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 12px 18px !important;
  font-weight: 600; font-size: .84rem; color: var(--text);
}
.card-body { padding: 16px 18px !important }
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--border) !important;
  padding: 11px 18px !important;
}

/* ── Gradient KPI cards ─────────────────────────────────── */
.kpi-g {
  position: relative; overflow: hidden;
  border-radius: var(--r) !important; border: none !important;
  color: #fff;
}
.kpi-g .card-body { padding: 18px !important }
.kpi-g::after {
  content: ''; position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.12);
  pointer-events: none;
}
.kpi-g .kpi-label { font-size: .74rem; font-weight: 500; opacity: .88; margin-bottom: 3px }
.kpi-g .kpi-val { font-size: 1.35rem; font-weight: 700; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.kpi-g .kpi-icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 2.2rem; opacity: .18 }
.kpi-g .kpi-sub { font-size: .7rem; opacity: .72; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }

.g-green  { background: linear-gradient(135deg, #059669, #34d399) }
.g-red    { background: linear-gradient(135deg, #dc2626, #f87171) }
.g-amber  { background: linear-gradient(135deg, #b45309, #fbbf24) }
.g-indigo { background: linear-gradient(135deg, #4338ca, #818cf8) }
.g-orange { background: linear-gradient(135deg, #c2410c, #fb923c) }
.g-teal   { background: linear-gradient(135deg, #0e7490, #22d3ee) }
.g-purple { background: linear-gradient(135deg, #6d28d9, #a78bfa) }

/* ── Tables ─────────────────────────────────────────────── */
.table { font-size: .875rem; --bs-table-border-color: var(--border) }
.table thead th {
  font-size: .69rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
  border-bottom-width: 1px !important;
  padding: 9px 14px !important; white-space: nowrap;
  background: #f8f9fb;
}
.table tbody td { padding: 9px 14px !important; vertical-align: middle; border-color: var(--border) }
.table-hover tbody tr { transition: background .1s }
.table-hover tbody tr:hover { background: #fff8f4 !important }
.table-light { --bs-table-bg: #f8f9fb }

/* ── Badges ─────────────────────────────────────────────── */
.badge { border-radius: 999px !important; font-weight: 500 !important; padding: 3px 9px !important; font-size: .7rem !important; letter-spacing: .2px }

/* ── Buttons ────────────────────────────────────────────── */
.btn { border-radius: 7px !important; font-weight: 500 !important; font-size: .875rem !important; transition: all .14s ease !important }
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--sh-md) }
.btn:active { transform: none !important }
.btn-primary { background: var(--accent) !important; border-color: var(--accent) !important }
.btn-primary:hover { background: var(--accent-h) !important; border-color: var(--accent-h) !important }
.btn-sm { font-size: .77rem !important; padding: 4px 10px !important }
.btn-lg { font-size: .95rem !important }

/* ── Forms ──────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 7px !important; border-color: #d1d5db !important;
  font-size: .875rem !important; transition: all .14s ease !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(249,115,22,.15) !important;
}
.form-control-sm, .form-select-sm { font-size: .8rem !important }
.form-label { font-size: .78rem; font-weight: 600; color: #374151; margin-bottom: 4px }
.form-text { font-size: .74rem; color: var(--muted) }

/* ── Alerts ─────────────────────────────────────────────── */
.alert { border-radius: var(--r) !important; border: none !important; font-size: .875rem }
.alert-success { background: #ecfdf5; color: #065f46 }
.alert-danger  { background: #fef2f2; color: #991b1b }
.alert-warning { background: #fffbeb; color: #92400e }
.alert-info    { background: #eff6ff; color: #1e40af }

/* ── List group ─────────────────────────────────────────── */
.list-group-item { border-color: var(--border) !important; padding: 10px 16px !important; font-size: .875rem }

/* ── Modal ──────────────────────────────────────────────── */
.modal-content { border: none !important; border-radius: 14px !important; box-shadow: var(--sh-lg) }
.modal-header  { border-bottom: 1px solid var(--border) !important; padding: 14px 20px !important }
.modal-body    { padding: 18px 20px !important }
.modal-footer  { border-top: 1px solid var(--border) !important; padding: 12px 20px !important }

/* ── Accordion ──────────────────────────────────────────── */
.accordion-item { border-radius: var(--r) !important; border: 1px solid var(--border) !important; margin-bottom: 8px; overflow: hidden }
.accordion-button { font-weight: 500 !important; font-size: .9rem !important }
.accordion-button:not(.collapsed) { background: rgba(249,115,22,.06) !important; color: var(--accent) !important; box-shadow: none !important }
.accordion-button:focus { box-shadow: none !important }

/* ── Progress ───────────────────────────────────────────── */
.progress { border-radius: 999px; overflow: hidden }

/* ── Nav tabs ───────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid var(--border) }
.nav-tabs .nav-link { border: none; color: var(--muted); font-weight: 500; font-size: .86rem; padding: 8px 16px; border-radius: 0 }
.nav-tabs .nav-link:hover { color: var(--accent); background: none }
.nav-tabs .nav-link.active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -2px; background: none }

/* ── Dashboard layout (no-scroll) ───────────────────────── */
body.dash-body { overflow: hidden; height: 100vh }
body.dash-body .main-wrap { height: 100vh; overflow: hidden; padding-top: var(--tb-h) }
.dash-content {
  overflow: hidden; display: flex; flex-direction: column; gap: 10px;
  padding: 13px 22px !important;
}
.kpi-row { flex: 0 0 auto }
.charts-grid {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}
.chart-cell { min-height: 0; display: flex; flex-direction: column }
.chart-cell .card-header { flex: 0 0 auto; padding: 7px 13px !important; font-size: .76rem }
.chart-cell .card-body   { flex: 1 1 auto; min-height: 0; position: relative; padding: 7px !important }
.txn-cell .table-responsive { flex: 1 1 auto; min-height: 0; overflow: hidden }
.txn-cell table { font-size: .76rem }

/* ── Page headings ──────────────────────────────────────── */
h3 { font-weight: 700; font-size: 1.2rem; letter-spacing: -.3px }

/* ── Payslip print ──────────────────────────────────────── */
.payslip-card { background: #fff }

/* ── Responsive (mobile) ────────────────────────────────── */
@media (max-width: 768px) {
  .tn-links { gap: 0 }
  .tn-links > a, .tn-drop-btn { padding: 6px 8px; font-size: .76rem }
  .tn-username { display: none }
  .page-content { padding: 14px 16px }
  .charts-grid { grid-template-columns: 1fr; grid-template-rows: none }
  body.dash-body { overflow: auto; height: auto }
  body.dash-body .main-wrap { height: auto; overflow: auto }
  .dash-content { overflow: auto }
}

/* ── Print ──────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important }
  .topnav { display: none !important }
  .main-wrap { padding-top: 0 !important }
  .page-content { padding: 0 !important }
  body { background: #fff }
  .payslip-card { box-shadow: none !important }
}
