/*
 * Loads For Africa BackDoor - admin theme
 * Sits on top of Bootstrap 5.3. Light and dark themes are driven by
 * the data-bs-theme attribute on <html> (set by assets/js/backdoor.js).
 *
 * Contents
 *   1. Design tokens (light)
 *   2. Design tokens (dark)
 *   3. Base
 *   4. Layout: shell, sidebar, topbar, content, footer
 *   5. Components: cards, stat cards, tables, forms, buttons, badges
 *   6. Utilities
 *   7. Responsive
 */

/* ------------------------------------------------------------------
 * 1. Design tokens (light)
 * ------------------------------------------------------------------ */
:root,
[data-bs-theme="light"] {
  /* Brand */
  --bd-brand: #e07a1f;
  --bd-brand-rgb: 224, 122, 31;
  --bd-brand-hover: #c4661a;
  --bd-brand-soft: #fdf1e6;
  --bd-brand-contrast: #ffffff;

  /* Surfaces */
  --bd-body-bg: #f4f6f9;
  --bd-surface: #ffffff;
  --bd-surface-2: #f8f9fb;
  --bd-border: #e3e7ed;
  --bd-border-strong: #cfd5de;

  /* Text */
  --bd-text: #1f2937;
  --bd-text-muted: #6b7280;
  --bd-heading: #111827;

  /* Sidebar (dark navy in both themes) */
  --bd-sidebar-bg: #14213d;
  --bd-sidebar-border: rgba(255, 255, 255, 0.06);
  --bd-sidebar-text: #aab4c8;
  --bd-sidebar-text-hover: #ffffff;
  --bd-sidebar-heading: #6c7a96;
  --bd-sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --bd-sidebar-active-bg: rgba(var(--bd-brand-rgb), 0.16);
  --bd-sidebar-active-text: #ffb470;

  /* Topbar */
  --bd-topbar-bg: rgba(255, 255, 255, 0.85);

  /* Effects */
  --bd-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --bd-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --bd-shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12);
  --bd-radius: 0.625rem;
  --bd-radius-sm: 0.4rem;

  /* Sizes */
  --bd-sidebar-width: 260px;
  --bd-sidebar-collapsed-width: 76px;
  --bd-topbar-height: 64px;
  --bd-transition: 0.2s ease;

  /* Bootstrap overrides */
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 0.9rem;
  --bs-body-bg: var(--bd-body-bg);
  --bs-body-color: var(--bd-text);
  --bs-emphasis-color: var(--bd-heading);
  --bs-secondary-color: var(--bd-text-muted);
  --bs-border-color: var(--bd-border);
  --bs-border-radius: var(--bd-radius-sm);
  --bs-border-radius-lg: var(--bd-radius);
  --bs-primary: var(--bd-brand);
  --bs-primary-rgb: var(--bd-brand-rgb);
  --bs-primary-text-emphasis: #8a4510;
  --bs-primary-bg-subtle: var(--bd-brand-soft);
  --bs-primary-border-subtle: #f6c89e;
  --bs-link-color: var(--bd-brand-hover);
  --bs-link-color-rgb: 196, 102, 26;
  --bs-link-hover-color: #9c5114;
  --bs-link-hover-color-rgb: 156, 81, 20;
  --bs-focus-ring-color: rgba(var(--bd-brand-rgb), 0.25);
}

/* ------------------------------------------------------------------
 * 2. Design tokens (dark)
 * ------------------------------------------------------------------ */
[data-bs-theme="dark"] {
  --bd-brand: #f08c33;
  --bd-brand-rgb: 240, 140, 51;
  --bd-brand-hover: #f5a25a;
  --bd-brand-soft: rgba(240, 140, 51, 0.14);
  --bd-brand-contrast: #1a1205;

  --bd-body-bg: #0f1420;
  --bd-surface: #171d2b;
  --bd-surface-2: #1c2333;
  --bd-border: #262f42;
  --bd-border-strong: #344058;

  --bd-text: #d5dbe6;
  --bd-text-muted: #8b96ab;
  --bd-heading: #f3f5f9;

  --bd-sidebar-bg: #0b0f19;
  --bd-sidebar-border: rgba(255, 255, 255, 0.05);
  --bd-sidebar-hover-bg: rgba(255, 255, 255, 0.05);

  --bd-topbar-bg: rgba(23, 29, 43, 0.85);

  --bd-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --bd-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --bd-shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, 0.5);

  --bs-body-bg: var(--bd-body-bg);
  --bs-body-color: var(--bd-text);
  --bs-emphasis-color: var(--bd-heading);
  --bs-secondary-color: var(--bd-text-muted);
  --bs-border-color: var(--bd-border);
  --bs-tertiary-bg: var(--bd-surface-2);
  --bs-secondary-bg: var(--bd-surface-2);
  --bs-primary: var(--bd-brand);
  --bs-primary-rgb: var(--bd-brand-rgb);
  --bs-primary-text-emphasis: #f8b679;
  --bs-primary-bg-subtle: var(--bd-brand-soft);
  --bs-primary-border-subtle: #6b3d14;
  --bs-link-color: var(--bd-brand-hover);
  --bs-link-color-rgb: 245, 162, 90;
  --bs-link-hover-color: #f8bd85;
  --bs-link-hover-color-rgb: 248, 189, 133;
  --bs-focus-ring-color: rgba(var(--bd-brand-rgb), 0.3);
}

/* ------------------------------------------------------------------
 * 3. Base
 * ------------------------------------------------------------------ */
body {
  background-color: var(--bd-body-bg);
  color: var(--bd-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--bd-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

::selection {
  background: rgba(var(--bd-brand-rgb), 0.25);
}

/* Prevent transition flashes while the theme is being applied */
.bd-no-transition * {
  transition: none !important;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 2000;
  padding: 0.5rem 1rem;
  background: var(--bd-brand);
  color: var(--bd-brand-contrast);
  border-radius: var(--bd-radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

/* ------------------------------------------------------------------
 * 4. Layout
 * ------------------------------------------------------------------ */
.bd-shell {
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.bd-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  width: var(--bd-sidebar-width);
  background: var(--bd-sidebar-bg);
  border-right: 1px solid var(--bd-sidebar-border);
  transition: width var(--bd-transition), transform var(--bd-transition);
}

.bd-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--bd-topbar-height);
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--bd-sidebar-border);
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.bd-sidebar-brand:hover {
  color: #ffffff;
}

.bd-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f59e42 0%, #d0601a 100%);
  color: #ffffff;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(224, 122, 31, 0.35);
}

.bd-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.bd-brand-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.bd-brand-sub {
  font-size: 0.7rem;
  color: var(--bd-sidebar-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bd-sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.bd-nav-heading {
  padding: 1rem 0.75rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bd-sidebar-heading);
  white-space: nowrap;
}

.bd-nav-heading:first-child {
  padding-top: 0;
}

.bd-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--bd-radius-sm);
  color: var(--bd-sidebar-text);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--bd-transition), color var(--bd-transition);
}

.bd-nav-link > .bi {
  font-size: 1.15rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.bd-nav-link:hover,
.bd-nav-link:focus-visible {
  color: var(--bd-sidebar-text-hover);
  background: var(--bd-sidebar-hover-bg);
}

.bd-nav-link.active {
  color: var(--bd-sidebar-active-text);
  background: var(--bd-sidebar-active-bg);
}

.bd-nav-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--bd-brand);
}

.bd-nav-link .badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
}

.bd-nav-link-danger:hover,
.bd-nav-link-danger:focus-visible {
  color: #ff8a80;
  background: rgba(255, 82, 82, 0.1);
}

.bd-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--bd-sidebar-border);
  flex-shrink: 0;
}

/* Collapsed sidebar (desktop) */
.bd-sidebar-collapsed .bd-sidebar {
  width: var(--bd-sidebar-collapsed-width);
}

.bd-sidebar-collapsed .bd-brand-text,
.bd-sidebar-collapsed .bd-nav-label,
.bd-sidebar-collapsed .bd-nav-link .badge {
  display: none;
}

.bd-sidebar-collapsed .bd-nav-heading {
  height: 1px;
  padding: 0;
  margin: 0.75rem 0.5rem;
  overflow: hidden;
  background: var(--bd-sidebar-border);
  color: transparent;
}

.bd-sidebar-collapsed .bd-sidebar-brand {
  justify-content: center;
  padding: 0;
}

.bd-sidebar-collapsed .bd-nav-link {
  justify-content: center;
  padding: 0.7rem 0;
}

/* Mobile backdrop */
.bd-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1035;
  background: rgba(10, 15, 25, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--bd-transition), visibility var(--bd-transition);
}

/* ---- Main area ---- */
.bd-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--bd-sidebar-width);
  transition: margin-left var(--bd-transition);
}

.bd-sidebar-collapsed .bd-main {
  margin-left: var(--bd-sidebar-collapsed-width);
}

/* ---- Topbar ---- */
.bd-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--bd-topbar-height);
  padding: 0 1.5rem;
  background: var(--bd-topbar-bg);
  border-bottom: 1px solid var(--bd-border);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  backdrop-filter: saturate(180%) blur(10px);
}

.bd-topbar-search {
  position: relative;
  max-width: 340px;
  width: 100%;
}

.bd-topbar-search .bi {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bd-text-muted);
  pointer-events: none;
}

.bd-topbar-search .form-control {
  padding-left: 2.4rem;
  background-color: var(--bd-surface-2);
  border-color: transparent;
}

.bd-topbar-search .form-control:focus {
  background-color: var(--bd-surface);
  border-color: var(--bd-brand);
}

.bd-topbar-search kbd {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  background: var(--bd-surface);
  color: var(--bd-text-muted);
  border: 1px solid var(--bd-border);
  box-shadow: none;
}

.bd-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: var(--bd-radius-sm);
  background: transparent;
  color: var(--bd-text-muted);
  font-size: 1.15rem;
  transition: background-color var(--bd-transition), color var(--bd-transition);
}

.bd-icon-btn:hover,
.bd-icon-btn:focus-visible,
.bd-icon-btn[aria-expanded="true"] {
  background: var(--bd-surface-2);
  color: var(--bd-heading);
}

.bd-icon-btn .bd-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bs-danger);
  border: 2px solid var(--bd-surface);
}

.bd-user-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--bd-text);
  transition: background-color var(--bd-transition);
}

.bd-user-btn:hover,
.bd-user-btn[aria-expanded="true"] {
  background: var(--bd-surface-2);
}

.bd-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bd-brand-soft);
  color: var(--bd-brand);
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.bd-avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 0.95rem;
}

.bd-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
}

.bd-user-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.bd-user-role {
  font-size: 0.72rem;
  color: var(--bd-text-muted);
}

/* Dropdowns */
.dropdown-menu {
  --bs-dropdown-bg: var(--bd-surface);
  --bs-dropdown-border-color: var(--bd-border);
  --bs-dropdown-link-hover-bg: var(--bd-surface-2);
  --bs-dropdown-link-active-bg: var(--bd-brand-soft);
  --bs-dropdown-link-active-color: var(--bd-brand);
  --bs-dropdown-font-size: 0.875rem;
  padding: 0.4rem;
  border-radius: var(--bd-radius);
  box-shadow: var(--bd-shadow-lg);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--bd-radius-sm);
}

.dropdown-item .bi-check2 {
  margin-left: auto;
  visibility: hidden;
}

.dropdown-item.active .bi-check2 {
  visibility: visible;
}

.bd-dropdown-header {
  padding: 0.6rem 0.7rem;
}

/* ---- Content ---- */
.bd-content {
  flex: 1 1 auto;
  padding: 1.75rem 1.5rem 2rem;
}

.bd-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bd-page-title {
  margin: 0;
  font-size: 1.5rem;
}

.bd-page-subtitle {
  margin: 0.25rem 0 0;
  color: var(--bd-text-muted);
}

.breadcrumb {
  --bs-breadcrumb-font-size: 0.8rem;
  --bs-breadcrumb-margin-bottom: 0.35rem;
  --bs-breadcrumb-divider-color: var(--bd-text-muted);
  --bs-breadcrumb-item-active-color: var(--bd-text-muted);
}

.breadcrumb a {
  color: var(--bd-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--bd-brand);
}

/* ---- Footer ---- */
.bd-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bd-border);
  color: var(--bd-text-muted);
  font-size: 0.8rem;
}

.bd-footer a {
  color: var(--bd-text-muted);
  text-decoration: none;
}

.bd-footer a:hover {
  color: var(--bd-brand);
}

/* ------------------------------------------------------------------
 * 5. Components
 * ------------------------------------------------------------------ */

/* Cards */
.card {
  --bs-card-bg: var(--bd-surface);
  --bs-card-border-color: var(--bd-border);
  --bs-card-border-radius: var(--bd-radius);
  --bs-card-inner-border-radius: calc(var(--bd-radius) - 1px);
  --bs-card-cap-bg: transparent;
  --bs-card-spacer-y: 1.25rem;
  --bs-card-spacer-x: 1.25rem;
  box-shadow: var(--bd-shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-subtitle {
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--bd-text-muted);
}

/* Stat cards */
.bd-stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.bd-stat-label {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--bd-text-muted);
}

.bd-stat-value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--bd-heading);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.bd-stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--bd-radius);
  font-size: 1.3rem;
  flex-shrink: 0;
}

.bd-stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.bd-tone-brand { background: var(--bd-brand-soft); color: var(--bd-brand); }
.bd-tone-success { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.bd-tone-info { background: var(--bs-info-bg-subtle); color: var(--bs-info-text-emphasis); }
.bd-tone-warning { background: var(--bs-warning-bg-subtle); color: var(--bs-warning-text-emphasis); }
.bd-tone-danger { background: var(--bs-danger-bg-subtle); color: var(--bs-danger-text-emphasis); }
.bd-tone-neutral { background: var(--bd-surface-2); color: var(--bd-text-muted); }

/* Tables */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--bd-text);
  --bs-table-border-color: var(--bd-border);
  --bs-table-hover-bg: var(--bd-surface-2);
  --bs-table-striped-bg: var(--bd-surface-2);
  margin-bottom: 0;
  font-size: 0.875rem;
}

.table > thead th {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  background: var(--bd-surface-2);
  color: var(--bd-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom-width: 1px;
}

.table > :not(caption) > * > * {
  padding: 0.8rem 1rem;
  vertical-align: middle;
}

.card > .table-responsive:last-child .table tr:last-child td,
.card > .table:last-child tr:last-child td {
  border-bottom: 0;
}

/* Forms */
.form-control,
.form-select {
  --bs-border-color: var(--bd-border-strong);
  background-color: var(--bd-surface);
  font-size: 0.875rem;
  padding: 0.5rem 0.8rem;
}

.form-select {
  padding-right: 2.25rem;
}

.form-control-sm,
.form-select-sm {
  font-size: 0.8rem;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--bd-brand);
  box-shadow: 0 0 0 0.2rem rgba(var(--bd-brand-rgb), 0.2);
}

.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.form-text {
  font-size: 0.78rem;
}

.form-check-input:checked {
  background-color: var(--bd-brand);
  border-color: var(--bd-brand);
}

.input-group-text {
  background-color: var(--bd-surface-2);
  border-color: var(--bd-border-strong);
  color: var(--bd-text-muted);
}

/* Buttons */
.btn {
  --bs-btn-font-size: 0.875rem;
  --bs-btn-font-weight: 500;
  --bs-btn-padding-x: 0.95rem;
  --bs-btn-padding-y: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn-sm {
  --bs-btn-font-size: 0.8rem;
  --bs-btn-padding-x: 0.7rem;
  --bs-btn-padding-y: 0.3rem;
}

.btn-primary {
  --bs-btn-color: var(--bd-brand-contrast);
  --bs-btn-bg: var(--bd-brand);
  --bs-btn-border-color: var(--bd-brand);
  --bs-btn-hover-color: var(--bd-brand-contrast);
  --bs-btn-hover-bg: var(--bd-brand-hover);
  --bs-btn-hover-border-color: var(--bd-brand-hover);
  --bs-btn-active-color: var(--bd-brand-contrast);
  --bs-btn-active-bg: var(--bd-brand-hover);
  --bs-btn-active-border-color: var(--bd-brand-hover);
  --bs-btn-disabled-color: var(--bd-brand-contrast);
  --bs-btn-disabled-bg: var(--bd-brand);
  --bs-btn-disabled-border-color: var(--bd-brand);
  --bs-btn-focus-shadow-rgb: var(--bd-brand-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--bd-brand);
  --bs-btn-border-color: var(--bd-brand);
  --bs-btn-hover-color: var(--bd-brand-contrast);
  --bs-btn-hover-bg: var(--bd-brand);
  --bs-btn-hover-border-color: var(--bd-brand);
  --bs-btn-active-color: var(--bd-brand-contrast);
  --bs-btn-active-bg: var(--bd-brand);
  --bs-btn-active-border-color: var(--bd-brand);
  --bs-btn-focus-shadow-rgb: var(--bd-brand-rgb);
}

.btn-light-subtle {
  --bs-btn-color: var(--bd-text);
  --bs-btn-bg: var(--bd-surface);
  --bs-btn-border-color: var(--bd-border-strong);
  --bs-btn-hover-color: var(--bd-heading);
  --bs-btn-hover-bg: var(--bd-surface-2);
  --bs-btn-hover-border-color: var(--bd-border-strong);
  --bs-btn-active-color: var(--bd-heading);
  --bs-btn-active-bg: var(--bd-surface-2);
  --bs-btn-active-border-color: var(--bd-border-strong);
}

/* Badges and status pills */
.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.bd-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.bd-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: var(--bd-radius);
  font-size: 0.875rem;
}

.alert > .bi {
  font-size: 1.1rem;
  line-height: 1.3;
}

/* Modals */
.modal-content {
  --bs-modal-bg: var(--bd-surface);
  --bs-modal-border-color: var(--bd-border);
  --bs-modal-border-radius: var(--bd-radius);
  box-shadow: var(--bd-shadow-lg);
}

.bd-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.35rem;
}

/* Pagination */
.pagination {
  --bs-pagination-font-size: 0.85rem;
  --bs-pagination-color: var(--bd-text);
  --bs-pagination-bg: var(--bd-surface);
  --bs-pagination-border-color: var(--bd-border);
  --bs-pagination-hover-color: var(--bd-heading);
  --bs-pagination-hover-bg: var(--bd-surface-2);
  --bs-pagination-hover-border-color: var(--bd-border);
  --bs-pagination-active-bg: var(--bd-brand);
  --bs-pagination-active-border-color: var(--bd-brand);
  --bs-pagination-active-color: var(--bd-brand-contrast);
  --bs-pagination-focus-box-shadow: 0 0 0 0.2rem rgba(var(--bd-brand-rgb), 0.2);
  margin-bottom: 0;
}

/* Nav tabs/pills */
.nav-pills {
  --bs-nav-pills-link-active-bg: var(--bd-brand);
  --bs-nav-pills-link-active-color: var(--bd-brand-contrast);
}

.nav-link {
  --bs-nav-link-color: var(--bd-text-muted);
  --bs-nav-link-hover-color: var(--bd-heading);
}

.nav-tabs {
  --bs-nav-tabs-link-active-color: var(--bd-brand);
  --bs-nav-tabs-link-active-bg: transparent;
  --bs-nav-tabs-link-active-border-color: transparent transparent var(--bd-brand);
  --bs-nav-tabs-border-color: var(--bd-border);
}

.nav-tabs .nav-link {
  border-width: 0 0 2px;
  font-weight: 500;
}

/* Empty state */
.bd-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--bd-text-muted);
}

.bd-empty > .bi {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 2.5rem;
  opacity: 0.5;
}

/* Placeholder region used by the shell template */
.bd-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 2rem;
  border: 2px dashed var(--bd-border-strong);
  border-radius: var(--bd-radius);
  color: var(--bd-text-muted);
  text-align: center;
}

/* Style guide swatches */
.bd-swatch {
  height: 56px;
  border-radius: var(--bd-radius-sm);
  border: 1px solid var(--bd-border);
}

/* WhatsApp conversation (whatsapp_chat.php): incoming left, outgoing right */
.bd-chat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bd-surface-2);
}

.bd-chat-note {
  align-self: center;
  max-width: 100%;
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
  background: var(--bd-surface);
  border: 1px solid var(--bd-border);
  color: var(--bd-text-muted);
  font-size: 0.75rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.bd-bubble-row {
  display: flex;
}

.bd-bubble-row.is-out {
  justify-content: flex-end;
}

.bd-bubble {
  max-width: min(36rem, 90%);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bd-border);
  border-radius: var(--bd-radius);
  background: var(--bd-surface);
  overflow-wrap: anywhere;
}

.bd-bubble.is-out {
  border-color: transparent;
  background: var(--bd-brand-soft);
}

.bd-bubble-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--bd-text-muted);
  font-size: 0.75rem;
}

.bd-bubble-quote {
  margin: 0.25rem 0;
  padding-left: 0.5rem;
  border-left: 3px solid var(--bd-border-strong);
  color: var(--bd-text-muted);
  font-size: 0.8rem;
}

.bd-bubble-text {
  margin: 0.15rem 0;
  white-space: pre-wrap;
}

.bd-bubble-file {
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

.bd-bubble-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.bd-bubble-foot:empty {
  display: none;
}

.bd-bubble-reason {
  margin-top: 0.35rem;
  color: var(--bs-danger-text-emphasis);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------------
 * 6. Utilities
 * ------------------------------------------------------------------ */
.text-brand { color: var(--bd-brand) !important; }
.bg-brand { background-color: var(--bd-brand) !important; }
.bg-surface { background-color: var(--bd-surface) !important; }
.bg-surface-2 { background-color: var(--bd-surface-2) !important; }
.border-strong { border-color: var(--bd-border-strong) !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.85rem !important; }
.font-mono { font-family: SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace !important; font-size: 0.82em; }
.tabular { font-variant-numeric: tabular-nums; }

/* Theme toggle icon: show the icon of the active theme */
[data-bd-theme-icon] { display: none; }
[data-bd-active-theme="light"] [data-bd-theme-icon="light"],
[data-bd-active-theme="dark"] [data-bd-theme-icon="dark"],
[data-bd-active-theme="auto"] [data-bd-theme-icon="auto"] {
  display: inline-block;
}

/* ------------------------------------------------------------------
 * 7. Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 991.98px) {
  .bd-sidebar,
  .bd-sidebar-collapsed .bd-sidebar {
    width: var(--bd-sidebar-width);
    transform: translateX(-100%);
  }

  .bd-sidebar-collapsed .bd-brand-text,
  .bd-sidebar-collapsed .bd-nav-label {
    display: flex;
  }

  .bd-sidebar-collapsed .bd-nav-label {
    display: inline;
  }

  .bd-sidebar-collapsed .bd-nav-link .badge {
    display: inline-block;
  }

  .bd-sidebar-collapsed .bd-nav-heading {
    height: auto;
    margin: 0;
    padding: 1rem 0.75rem 0.5rem;
    background: none;
    color: var(--bd-sidebar-heading);
  }

  .bd-sidebar-collapsed .bd-sidebar-brand {
    justify-content: flex-start;
    padding: 0 1.25rem;
  }

  .bd-sidebar-collapsed .bd-nav-link {
    justify-content: flex-start;
    padding: 0.6rem 0.75rem;
  }

  .bd-sidebar-open .bd-sidebar {
    transform: translateX(0);
    box-shadow: var(--bd-shadow-lg);
  }

  .bd-sidebar-open .bd-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .bd-main,
  .bd-sidebar-collapsed .bd-main {
    margin-left: 0;
  }
}

@media (max-width: 575.98px) {
  .bd-topbar {
    padding: 0 1rem;
  }

  .bd-content {
    padding: 1.25rem 1rem 1.5rem;
  }

  .bd-footer {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media print {
  .bd-sidebar,
  .bd-topbar,
  .bd-footer,
  .bd-sidebar-backdrop {
    display: none !important;
  }

  .bd-main {
    margin-left: 0 !important;
  }
}
