/*
 * Mujuni Payroll — theme layer on top of Bootstrap 5.3.
 *
 * Bootstrap ships its palette as CSS custom properties, so the smart-blue brand
 * is applied by re-pointing those variables rather than by overriding rules.
 * Everything below that is either the frosted-glass surface treatment or a
 * component Bootstrap does not provide (stat tiles, the sidebar, skeletons).
 */

:root {
  /* Smart Blue palette */
  --sb-50:  #ebf0fa;
  --sb-100: #d6e2f5;
  --sb-200: #adc5eb;
  --sb-300: #85a8e0;
  --sb-400: #5c8bd6;
  --sb-500: #336ecc;
  --sb-600: #2958a3;
  --sb-700: #1f427a;
  --sb-800: #142c52;
  --sb-900: #0a1629;
  --sb-950: #070f1d;

  --sidebar-width: 16rem;
  --sidebar-width-collapsed: 5rem;
  --topbar-height: 4.5rem;

  --brand-gradient: linear-gradient(135deg, var(--sb-600), var(--sb-700));
  --page-gradient: linear-gradient(135deg, var(--sb-50), var(--sb-100) 45%, var(--sb-200));

  /* Bootstrap overrides */
  --bs-primary: #2958a3;
  --bs-primary-rgb: 41, 88, 163;
  --bs-link-color: #2958a3;
  --bs-link-color-rgb: 41, 88, 163;
  --bs-link-hover-color: #1f427a;
  --bs-body-color: #0a1629;
  --bs-body-bg: #ebf0fa;
  --bs-border-color: rgba(41, 88, 163, .2);
  --bs-border-radius: .75rem;
  --bs-border-radius-sm: .5rem;
  --bs-border-radius-lg: 1rem;
  --bs-border-radius-xl: 1.25rem;
  --bs-font-sans-serif: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-focus-ring-color: rgba(41, 88, 163, .25);
}

.btn-primary {
  --bs-btn-bg: #2958a3;
  --bs-btn-border-color: #2958a3;
  --bs-btn-hover-bg: #1f427a;
  --bs-btn-hover-border-color: #1f427a;
  --bs-btn-active-bg: #142c52;
  --bs-btn-active-border-color: #142c52;
  --bs-btn-disabled-bg: #2958a3;
  --bs-btn-disabled-border-color: #2958a3;
}

.btn-outline-primary {
  --bs-btn-color: #2958a3;
  --bs-btn-border-color: rgba(41, 88, 163, .45);
  --bs-btn-hover-bg: #2958a3;
  --bs-btn-hover-border-color: #2958a3;
  --bs-btn-active-bg: #1f427a;
}

body {
  min-height: 100vh;
  background: var(--page-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ── Frosted surfaces ─────────────────────────────────────── */

.glass {
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .45);
  box-shadow: 0 10px 30px -18px rgba(10, 22, 41, .55);
}

.glass-dark {
  background: rgba(41, 88, 163, .12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(41, 88, 163, .2);
}

.card.glass { border-radius: 1rem; }

.text-brand      { color: var(--sb-600) !important; }
.text-brand-dark { color: var(--sb-900) !important; }
.text-brand-muted{ color: var(--sb-700) !important; }
.bg-brand        { background: var(--sb-600) !important; }
.bg-brand-gradient { background: var(--brand-gradient) !important; }

/* ── Sidebar ──────────────────────────────────────────────── */

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  z-index: 1045;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(41, 88, 163, .2);
  background: rgba(235, 240, 250, .82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: width .25s ease, transform .25s ease;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(41, 88, 163, .18);
  min-height: var(--topbar-height);
}

.app-sidebar__logo {
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--sb-600);
  display: grid;
  place-items: center;
  padding: .35rem;
  box-shadow: 0 6px 16px -8px rgba(10, 22, 41, .8);
}

.app-sidebar__logo img { width: 100%; height: 100%; object-fit: contain; }

.app-sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem .75rem 0;
  scrollbar-width: thin;
}

.app-sidebar__group-label {
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(41, 88, 163, .7);
  padding: .75rem .75rem .25rem;
  margin: 0;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: .75rem;
  height: 2.5rem;
  padding: 0 .75rem;
  margin-bottom: .125rem;
  border-radius: .75rem;
  color: var(--sb-900);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

.app-sidebar__link i { font-size: 1.05rem; flex: 0 0 1.25rem; text-align: center; }
.app-sidebar__link:hover { background: rgba(214, 226, 245, .75); color: var(--sb-900); }

.app-sidebar__link.active {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(31, 66, 122, .9);
}

.app-sidebar__footer {
  padding: .75rem;
  border-top: 1px solid rgba(41, 88, 163, .18);
}

/* Collapsed state (desktop) */
.sidebar-collapsed .app-sidebar { width: var(--sidebar-width-collapsed); }
.sidebar-collapsed .app-sidebar .app-sidebar__label,
.sidebar-collapsed .app-sidebar .app-sidebar__group-label { display: none; }
.sidebar-collapsed .app-sidebar__link { justify-content: center; padding: 0; }
.sidebar-collapsed .app-sidebar__brand { justify-content: center; padding-inline: .5rem; }
.sidebar-collapsed .app-main { margin-left: var(--sidebar-width-collapsed); }

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left .25s ease;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid rgba(41, 88, 163, .18);
  box-shadow: 0 2px 12px -8px rgba(10, 22, 41, .5);
}

.app-content { padding: 1.75rem 1.5rem 3rem; }

.avatar-circle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .8rem;
  flex: 0 0 auto;
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main, .sidebar-collapsed .app-main { margin-left: 0; }
  .app-content { padding: 1.25rem 1rem 3rem; }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 41, .45);
  z-index: 1040;
  display: none;
}
.sidebar-open .sidebar-backdrop { display: block; }
@media (min-width: 992px) { .sidebar-backdrop { display: none !important; } }

/* ── Page header ──────────────────────────────────────────── */

.page-header {
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--sb-900); margin: 0 0 .25rem; }
.page-header p  { color: var(--sb-700); margin: 0; }

/* ── Stat tiles ───────────────────────────────────────────── */

.stat-card { border: 1px solid rgba(41, 88, 163, .18); border-radius: 1rem; height: 100%; }
.stat-card .stat-title { font-size: .8125rem; font-weight: 500; color: var(--sb-700); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--sb-900); line-height: 1.2; }

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .75rem;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.1rem;
  flex: 0 0 auto;
}

.grad-1 { background: linear-gradient(135deg, #2958a3, #1f427a); }
.grad-2 { background: linear-gradient(135deg, #5c8bd6, #2958a3); }
.grad-3 { background: linear-gradient(135deg, #adc5eb, #5c8bd6); }
.grad-4 { background: linear-gradient(135deg, #1f427a, #142c52); }

/* ── Tables ───────────────────────────────────────────────── */

.table-wrap {
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(41, 88, 163, .18);
  background: rgba(255, 255, 255, .8);
}

.table-wrap > .table-responsive { max-height: 68vh; }

.table.table-app { margin: 0; --bs-table-bg: transparent; }

.table.table-app > thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sb-100);
  color: var(--sb-800);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid rgba(41, 88, 163, .25);
}

.table.table-app > tbody td { vertical-align: middle; font-size: .875rem; }
.table.table-app > tbody tr:hover > * { background: rgba(214, 226, 245, .5); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Forms ────────────────────────────────────────────────── */

.form-label { font-weight: 600; font-size: .8125rem; color: var(--sb-800); }
.form-control, .form-select { border-color: rgba(41, 88, 163, .25); }
.form-control:focus, .form-select:focus {
  border-color: var(--sb-400);
  box-shadow: 0 0 0 .25rem rgba(41, 88, 163, .15);
}

.form-section-title {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sb-600);
  padding-bottom: .5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(41, 88, 163, .2);
}

/* ── Feedback: toasts, spinners, skeletons ────────────────── */

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: min(24rem, calc(100vw - 2rem));
}

.app-toast { border: 0; border-radius: .75rem; box-shadow: 0 12px 30px -12px rgba(10, 22, 41, .6); }
.app-toast .toast-body { display: flex; gap: .625rem; align-items: flex-start; }
.app-toast .bi { font-size: 1.1rem; line-height: 1.4; flex: 0 0 auto; }

.overlay-spinner {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  place-items: center;
  background: rgba(235, 240, 250, .72);
  backdrop-filter: blur(3px);
}
.overlay-spinner.show { display: grid; }

.spinner-brand {
  width: 3rem;
  height: 3rem;
  border: 4px solid var(--sb-600);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--sb-100) 25%, #e8eefb 37%, var(--sb-100) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: .5rem;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--sb-700); }
.empty-state .bi { font-size: 2.5rem; color: var(--sb-300); display: block; margin-bottom: .75rem; }

/* Buttons keep their width while a spinner replaces the label. */
.btn .btn-spinner { display: none; }
.btn.is-busy .btn-spinner { display: inline-block; }
.btn.is-busy .btn-label { opacity: .65; }

/* ── Login ────────────────────────────────────────────────── */

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

.login-pane {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  background: var(--page-gradient);
}

.login-pane__art { position: absolute; inset: 0; pointer-events: none; }

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 27rem;
  background: #fff;
  border-radius: 1.25rem;
  padding: 2rem;
  border: 1px solid var(--sb-100);
  box-shadow: 0 30px 60px -30px rgba(10, 22, 41, .55);
}

.login-aside {
  flex: 1 1 50%;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, var(--sb-600), var(--sb-700) 55%, var(--sb-800));
}
@media (min-width: 992px) { .login-aside { display: flex; } }

.login-aside__logo {
  width: 6rem;
  height: 6rem;
  margin: 0 auto 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.lockout-dial {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  border: 4px solid #fca5a5;
  background: #fef2f2;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: #dc2626;
}

/* ── Print ────────────────────────────────────────────────── */

@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
  body { background: #fff; }
}
