/*
  Snap 51 Tracker — shared design system
  Built on top of stock Bootstrap 5.3 (CDN). Overrides Bootstrap's CSS
  variables so every component (buttons, links, badges, forms, focus
  rings...) automatically inherits the brand palette.
*/

:root {
  --bp-primary: #14477a;
  --bp-primary-dark: #0d2f52;
  --bp-primary-light: #1f6bb3;
  --bp-accent: #c8952a;
  --bp-surface: #ffffff;
  --bp-bg: #f2f5f9;
  --bp-border: #e3e8ef;
  --bp-text: #29323d;
  --bp-text-muted: #6b7686;
  --bp-radius-sm: .5rem;
  --bp-radius: .75rem;
  --bp-radius-lg: 1rem;
  --bp-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --bp-shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --bp-shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

  --bs-primary: var(--bp-primary);
  --bs-primary-rgb: 20, 71, 122;
  --bs-link-color: var(--bp-primary);
  --bs-link-color-rgb: 20, 71, 122;
  --bs-link-hover-color: var(--bp-primary-dark);
  --bs-link-hover-color-rgb: 13, 47, 82;
  --bs-body-bg: var(--bp-bg);
  --bs-body-color: var(--bp-text);
  --bs-border-color: var(--bp-border);
  --bs-border-radius: var(--bp-radius-sm);
  --bs-border-radius-lg: var(--bp-radius);
  --bs-border-radius-sm: .375rem;
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--bp-bg);
  color: var(--bp-text);
}

a {
  text-decoration: none;
}

::selection {
  background: rgba(20, 71, 122, .18);
}

/* ---------- Utility polish ---------- */

.shadow-soft { box-shadow: var(--bp-shadow-sm) !important; }
.shadow-soft-lg { box-shadow: var(--bp-shadow) !important; }

.text-accent { color: var(--bp-accent) !important; }
.bg-accent { background-color: var(--bp-accent) !important; }

.btn {
  font-weight: 500;
  border-radius: var(--bp-radius-sm);
}
.btn-sm { border-radius: .45rem; }

.btn-primary {
  --bs-btn-bg: var(--bp-primary);
  --bs-btn-border-color: var(--bp-primary);
  --bs-btn-hover-bg: var(--bp-primary-dark);
  --bs-btn-hover-border-color: var(--bp-primary-dark);
  --bs-btn-active-bg: var(--bp-primary-dark);
  --bs-btn-active-border-color: var(--bp-primary-dark);
  box-shadow: var(--bp-shadow-sm);
}

.btn-accent {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bp-accent);
  --bs-btn-border-color: var(--bp-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #a97918;
  --bs-btn-hover-border-color: #a97918;
}

.card {
  border: 1px solid var(--bp-border);
  border-radius: var(--bp-radius);
  box-shadow: var(--bp-shadow-sm);
}

.card-header {
  background-color: var(--bp-surface);
  border-bottom: 1px solid var(--bp-border);
  font-weight: 600;
  color: var(--bp-text);
  padding: 1rem 1.25rem;
}

.card-header .bi { color: var(--bp-primary); }

/* Selective colored top accent for key cards — not applied globally so nested
   cards (e.g. inside modals) stay plain. */
.card-accent-top { border-top: 3px solid var(--bp-accent); }

.form-label {
  font-weight: 500;
  font-size: .875rem;
  color: var(--bp-text);
  margin-bottom: .35rem;
}

.form-control, .form-select {
  border-color: var(--bp-border);
  padding-top: .5rem;
  padding-bottom: .5rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--bp-primary-light);
  box-shadow: 0 0 0 .2rem rgba(20, 71, 122, .15);
}

.table {
  --bs-table-color: var(--bp-text);
  vertical-align: middle;
}

.table > thead {
  background-color: #eef2f7;
}

.table > thead th, .table > thead td {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--bp-text-muted);
  font-weight: 700;
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table-responsive {
  border-radius: var(--bp-radius);
}

.badge {
  font-weight: 600;
  letter-spacing: .01em;
  padding: .4em .65em;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bp-text-muted);
}
.empty-state .bi { font-size: 2.25rem; color: var(--bp-border); display: block; margin-bottom: .5rem; }

/* ---------- App shell (wl_admin) ---------- */

.app-shell { min-height: 100vh; }

.app-sidebar {
  --bp-sidebar-w: 300px;
  width: var(--bp-sidebar-w);
  flex: 0 0 var(--bp-sidebar-w);
  background: linear-gradient(180deg, var(--bp-primary-dark), var(--bp-primary) 75%);
  color: #eaf1f8;
}

.app-sidebar .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }

.sidebar-brand {
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-brand img { height: 46px; width: auto; object-fit: contain; background: #fff; border-radius: .4rem; padding: 4px; }

.sidebar-nav { padding: 1rem .9rem 1.25rem; }
.sidebar-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(234, 241, 248, .45);
  padding: 1.1rem .85rem .5rem;
}
.sidebar-section-label:first-child { padding-top: .35rem; }
.sidebar-nav .menu-item + .menu-item { margin-top: .25rem; }
.sidebar-nav .nav-link {
  color: rgba(234, 241, 248, .82);
  border-radius: var(--bp-radius-sm);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav .nav-link .bi { font-size: 1.35rem; width: 1.35rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-nav .menu-item.open .nav-link {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--bp-accent);
}

.sidebar-footer {
  padding: 1.1rem 1.5rem;
  color: rgba(234, 241, 248, .55);
  font-size: .78rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.app-main { min-width: 0; }

.app-topbar {
  background: var(--bp-surface);
  border-bottom: 1px solid var(--bp-border);
  padding: .65rem 1.25rem;
}

.app-topbar #header-title {
  font-weight: 600;
  color: var(--bp-text);
}

.app-topbar .avatar-btn img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border: 2px solid var(--bp-border);
}

.app-content { padding: 1.5rem; }

.app-footer {
  padding: 1rem 1.25rem;
  color: var(--bp-text-muted);
  font-size: .825rem;
  border-top: 1px solid var(--bp-border);
  background: var(--bp-surface);
}

@media (max-width: 991.98px) {
  .app-content { padding: 1rem; }
}

/* Preloader / progress overlay (kept from legacy behaviour, restyled) */
#preloader, #pre_progress_bar {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(242, 245, 249, .85);
  backdrop-filter: blur(2px);
  z-index: 1080;
}
#loader { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#progress_bar { position: absolute; top: 50%; left: 5%; width: 90%; transform: translateY(-50%); }
#progress_bar .title { text-align: center; margin-bottom: .75rem; }

/* ---------- Auth pages (login / 404) ---------- */

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

.auth-aside {
  background: radial-gradient(circle at 20% 20%, var(--bp-primary-light), var(--bp-primary-dark) 65%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, rgba(200,149,42,.25), transparent 60%);
}
.auth-aside .content { position: relative; z-index: 1; }
.auth-aside img.brand-logo { height: 46px; background: #fff; padding: 6px; border-radius: .5rem; }

.auth-card {
  border: none;
  border-radius: var(--bp-radius-lg);
  box-shadow: var(--bp-shadow-lg);
}

.auth-card .form-control { background: #fbfcfe; }

#captchaCanvas {
  border: 1px solid var(--bp-border);
  border-radius: var(--bp-radius-sm);
  background: #fbfcfe;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--bp-primary);
  line-height: 1;
}

@media (max-width: 991.98px) {
  .auth-aside { display: none !important; }
}

/* ---------- Toasts & confirm modal ---------- */

.toast { box-shadow: var(--bp-shadow-lg); }

#confirmModal .modal-content {
  border: none;
  border-radius: var(--bp-radius-lg);
  box-shadow: var(--bp-shadow-lg);
}
#confirmModal .confirm-icon {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 71, 122, .1);
  color: var(--bp-primary);
  font-size: 1.5rem;
}

/* ---------- Dashboard stat tiles (colorful gradient cards) ---------- */

.stat-tile {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--bp-radius);
  color: #fff;
  box-shadow: var(--bp-shadow);
}
.stat-tile::after {
  content: "";
  position: absolute;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  right: -1.5rem;
  bottom: -1.75rem;
  background: rgba(255, 255, 255, .12);
}
.stat-tile .stat-icon {
  position: relative;
  z-index: 1;
  width: 3rem;
  height: 3rem;
  border-radius: var(--bp-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .2);
  color: #fff;
}
.stat-tile .stat-value {
  position: relative;
  z-index: 1;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.15;
  color: #fff;
}
.stat-tile .stat-label {
  position: relative;
  z-index: 1;
  font-size: .8rem;
  color: rgba(255, 255, 255, .82);
  font-weight: 500;
}
.stat-navy { background: linear-gradient(135deg, var(--bp-primary), var(--bp-primary-dark)); }
.stat-gold { background: linear-gradient(135deg, #dba63a, #a9750e); }
.stat-green { background: linear-gradient(135deg, #2fa96c, #1a7a49); }
.stat-orange { background: linear-gradient(135deg, #dd8144, #a5501e); }

/* ---------- Dashboard welcome banner ---------- */

.welcome-banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--bp-radius-lg);
  background: linear-gradient(120deg, var(--bp-primary-dark) 0%, var(--bp-primary) 60%, var(--bp-primary-light) 130%);
  color: #fff;
  box-shadow: var(--bp-shadow);
}
.welcome-banner .shape-a {
  position: absolute;
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  right: -4rem;
  top: -6rem;
  background: radial-gradient(circle, rgba(200, 149, 42, .3), transparent 70%);
  pointer-events: none;
}
.welcome-banner .shape-b {
  position: absolute;
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  right: 12rem;
  bottom: -5rem;
  background: radial-gradient(circle, rgba(255, 255, 255, .1), transparent 70%);
  pointer-events: none;
}
.welcome-banner .quote_container { color: rgba(255, 255, 255, .85) !important; }
.welcome-banner .quote_container div { border-left-color: rgba(255, 255, 255, .4) !important; }

/* ---------- Responsive table hints ---------- */

.table-responsive { position: relative; }
.table-responsive.has-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.25rem;
  background: linear-gradient(to right, transparent, rgba(15, 23, 42, .08));
  pointer-events: none;
}

.table-scroll-hint {
  display: none;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--bp-text-muted);
  padding: .6rem 1.25rem 0;
}
.table-scroll-hint.is-visible { display: flex; }

.table-sticky-action th:first-child,
.table-sticky-action td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}
.table-sticky-action thead th:first-child { background: #eef2f7; }
.table-sticky-action tbody td:first-child { background: var(--bp-surface); }
.table-sticky-action tbody tr:hover td:first-child { background: #eef2f7; }
