/* ============================================================
   BHM Design System — Modern, Accessible, Unified
   Supports: dark (default), light, sepia, high-contrast
   Custom themes via theme.json override :root variables.
   ============================================================ */

/* ── 1. Variables (Dark default) ── */
:root {
  --hue-primary: 260;
  --hue-secondary: 160;

  --bg-gradient-start: #0b0b14;
  --bg-gradient-end:   #13131f;

  --color-primary:       #8b5cf6;
  --color-primary-hover: #7c3aed;
  --color-secondary:     #06b6d4;

  --text-main:  #e2e2ea;
  --text-muted: #8a8a9e;

  --glass-bg:    rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);

  --card-radius:   16px;
  --input-radius:  10px;
  --transition-speed: 0.25s;

  --focus-ring: 0 0 0 3px rgba(139, 92, 246, 0.35);
  --theme-close-filter: invert(1);
}

/* ── 2. Embedded themes via data-theme ── */
html[data-theme="light"] {
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end:   #f1f5f9;
  --color-primary:       #4f46e5;
  --color-primary-hover: #4338ca;
  --color-secondary:     #0891b2;
  --text-main:  #0f172a;
  --text-muted: #475569;
  --glass-bg:    rgba(255, 255, 255, 0.72);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.25);
  --theme-close-filter: none;
}

html[data-theme="sepia"] {
  --bg-gradient-start: #f5f0e1;
  --bg-gradient-end:   #ece5d0;
  --color-primary:       #8c6239;
  --color-primary-hover: #6b4226;
  --color-secondary:     #a0522d;
  --text-main:  #3d2b1f;
  --text-muted: #6b5344;
  --glass-bg:    rgba(250, 246, 235, 0.80);
  --glass-border: rgba(140, 98, 57, 0.14);
  --glass-shadow: 0 4px 24px rgba(140, 98, 57, 0.08);
  --focus-ring: 0 0 0 3px rgba(140, 98, 57, 0.25);
  --theme-close-filter: none;
}

html[data-theme="high-contrast"] {
  --bg-gradient-start: #000000;
  --bg-gradient-end:   #000000;
  --color-primary:       #ffff00;
  --color-primary-hover: #ffffff;
  --color-secondary:     #00ffff;
  --text-main:  #ffffff;
  --text-muted: #ffff00;
  --glass-bg:    #000000;
  --glass-border: #ffffff;
  --glass-shadow: none;
  --card-radius: 0px;
  --input-radius: 0px;
  --transition-speed: 0s;
  --focus-ring: 0 0 0 4px #ffff00;
  --theme-close-filter: invert(1);
}

/* ── 3. Base reset ── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  display: flex;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast preference */
@media (prefers-contrast: more) {
  :root {
    --glass-border: rgba(255,255,255,0.5);
    --text-muted: #ffffff;
  }
  html[data-theme="light"] {
    --glass-border: rgba(0,0,0,0.5);
    --text-muted: #000000;
  }
}

/* ── 4. Ambient glow (dark & sepia only, subtle) ── */
body::before,
body::after {
  content: '';
  position: absolute;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
}

body::before {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, hsla(var(--hue-primary), 80%, 60%, 0.08) 0%, transparent 70%);
  top: -150px;
  left: -150px;
}

body::after {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, hsla(var(--hue-secondary), 80%, 55%, 0.05) 0%, transparent 70%);
  bottom: -200px;
  right: -200px;
}

html[data-theme="light"] body::before,
html[data-theme="light"] body::after,
html[data-theme="high-contrast"] body::before,
html[data-theme="high-contrast"] body::after {
  display: none;
}

/* ── 5. Focus indicators ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--input-radius);
}

html[data-theme="high-contrast"] a:focus-visible,
html[data-theme="high-contrast"] button:focus-visible,
html[data-theme="high-contrast"] input:focus-visible,
html[data-theme="high-contrast"] select:focus-visible,
html[data-theme="high-contrast"] textarea:focus-visible,
html[data-theme="high-contrast"] [tabindex]:focus-visible {
  outline: 3px solid #ffff00;
  outline-offset: 2px;
}

/* ── 6. Sidebar (app + admin) ── */
.app-sidebar,
.admin-sidebar {
  width: 280px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

html[data-theme="light"] .app-sidebar,
html[data-theme="light"] .admin-sidebar,
html[data-theme="sepia"] .app-sidebar,
html[data-theme="sepia"] .admin-sidebar {
  background: rgba(255, 255, 255, 0.85);
}

html[data-theme="high-contrast"] .app-sidebar,
html[data-theme="high-contrast"] .admin-sidebar {
  background: #000000;
  border-right: 3px solid #ffffff;
}

/* ── 7. Branding ── */
.brand-section {
  display: flex;
  align-items: center;
  margin-bottom: 36px;
  padding-left: 10px;
  gap: 12px;
}

.brand-logo {
  font-size: 1.55rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo img {
  max-height: 38px;
  object-fit: contain;
  border-radius: 8px;
}

.admin-badge {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.25);
  color: #ea868f;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 30px;
  margin-left: 8px;
}

html[data-theme="light"] .admin-badge,
html[data-theme="sepia"] .admin-badge {
  color: #991b1b;
  background: rgba(220, 53, 69, 0.08);
  border-color: rgba(220, 53, 69, 0.18);
}

/* ── 8. Navigation ── */
.nav-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item a {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--input-radius);
  font-weight: 500;
  font-size: 0.95rem;
  transition: background var(--transition-speed) ease,
              color var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
  border: 1px solid transparent;
}

.nav-item a:hover {
  color: var(--text-main);
  background: rgba(127, 127, 127, 0.08);
  border-color: var(--glass-border);
}

.nav-item.active a {
  color: var(--text-main);
  background: var(--glass-bg);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-weight: 600;
}

html[data-theme="light"] .nav-item a:hover,
html[data-theme="sepia"] .nav-item a:hover {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="high-contrast"] .nav-item a:hover {
  background: #ffff00;
  color: #000000;
  border-color: #ffffff;
}

html[data-theme="high-contrast"] .nav-item.active a {
  background: #ffff00;
  color: #000000;
  border: 2px solid #ffffff;
  box-shadow: none;
}

.nav-icon {
  font-size: 1.15rem;
  margin-right: 14px;
  line-height: 1;
}

.nav-menu-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-left: 10px;
  text-transform: none;
}

.logout-section {
  margin-top: auto;
  border-top: 1px solid var(--glass-border);
  padding-top: 18px;
}

/* ── 9. Main content ── */
.app-main,
.admin-main {
  margin-left: 280px;
  flex-grow: 1;
  padding: 36px;
  min-height: 100vh;
  position: relative;
  z-index: 10;
}

.top-navbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 36px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  padding: 14px 28px;
  box-shadow: var(--glass-shadow);
}

.sadmin-email {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
}

/* ── 10. Cards ── */
.dashboard-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  box-shadow: var(--glass-shadow);
  padding: 28px;
  margin-bottom: 24px;
  transition: transform var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

html[data-theme="light"] .dashboard-card:hover,
html[data-theme="sepia"] .dashboard-card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

html[data-theme="high-contrast"] .dashboard-card {
  background: #000000;
  border: 2px solid #ffffff;
  border-radius: 0;
  box-shadow: none;
}

html[data-theme="high-contrast"] .dashboard-card:hover {
  transform: none;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text-main);
}

/* gradient text only when motion is ok and not high-contrast */
@media (prefers-reduced-motion: no-preference) {
  .card-title.bhm-text-gradient {
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

html[data-theme="high-contrast"] .card-title {
  background: none !important;
  -webkit-background-clip: initial !important;
  -webkit-text-fill-color: #ffffff !important;
  color: #ffffff !important;
}

/* ── 11. Auth layout ── */
.auth-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 460px;
  padding: 20px;
}

.auth-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  box-shadow: var(--glass-shadow);
  padding: 36px;
  transition: transform var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
}

.auth-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ── 12. Buttons ── */
.btn-action {
  border-radius: var(--input-radius);
  padding: 10px 20px;
  font-weight: 600;
  transition: background var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              transform var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
}

.btn-primary {
  background: var(--color-primary);
  border: 1px solid var(--color-primary);
  color: #ffffff;
  border-radius: var(--input-radius);
  padding: 12px 24px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: background var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              transform var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

html[data-theme="high-contrast"] .btn-primary {
  background: #ffff00 !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  font-weight: 900 !important;
}

html[data-theme="high-contrast"] .btn-primary:hover {
  background: #ffffff !important;
  color: #000000 !important;
}

.btn-logout {
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.18);
  color: #ea868f;
  border-radius: var(--input-radius);
  padding: 10px 20px;
  font-weight: 600;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  transition: background var(--transition-speed) ease,
              color var(--transition-speed) ease;
}

.btn-logout:hover {
  background: rgba(220, 53, 69, 0.16);
  color: #ff9da6;
}

html[data-theme="light"] .btn-logout,
html[data-theme="sepia"] .btn-logout {
  color: #991b1b;
  background: rgba(220, 53, 69, 0.06);
  border-color: rgba(220, 53, 69, 0.14);
}

html[data-theme="light"] .btn-logout:hover,
html[data-theme="sepia"] .btn-logout:hover {
  background: rgba(220, 53, 69, 0.12);
}

html[data-theme="high-contrast"] .btn-logout {
  background: #000000;
  color: #ff0000;
  border: 2px solid #ff0000;
}

/* ── 13. Forms ── */
.form-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.4rem;
  display: block;
}

.form-control,
.form-select {
  background: rgba(127, 127, 127, 0.06) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--input-radius) !important;
  color: var(--text-main) !important;
  padding: 12px 16px !important;
  font-size: 1rem;
  line-height: 1.5;
  transition: background var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              box-shadow var(--transition-speed) ease;
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.form-control:focus,
.form-select:focus {
  background: rgba(127, 127, 127, 0.10);
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
  outline: none;
}

html[data-theme="light"] .form-control,
html[data-theme="light"] .form-select,
html[data-theme="sepia"] .form-control,
html[data-theme="sepia"] .form-select {
  background: #ffffff !important;
}

html[data-theme="light"] .form-control:focus,
html[data-theme="light"] .form-select:focus,
html[data-theme="sepia"] .form-control:focus,
html[data-theme="sepia"] .form-select:focus {
  background: #ffffff !important;
}

html[data-theme="high-contrast"] .form-control,
html[data-theme="high-contrast"] .form-select {
  background: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
  border-radius: 0;
}

html[data-theme="high-contrast"] .form-control:focus,
html[data-theme="high-contrast"] .form-select:focus {
  border-color: #ffff00;
  box-shadow: 0 0 0 3px #ffff00;
}

/* Theme switcher select inside sidebar */
#theme-switcher-form .form-select {
  background: rgba(127, 127, 127, 0.08);
  border-color: var(--glass-border);
  color: var(--text-main);
  font-size: 0.875rem;
}

/* ── 14. Tables ── */
.table-responsive {
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.table-custom {
  margin-bottom: 0;
  background: transparent;
  width: 100%;
}

.table-custom th {
  background: rgba(127, 127, 127, 0.06);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  text-align: left;
}

.table-custom td {
  background: transparent;
  color: var(--text-main);
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}

.table-custom tr:last-child td {
  border-bottom: none;
}

html[data-theme="high-contrast"] .table-custom th,
html[data-theme="high-contrast"] .table-custom td {
  border: 1px solid #ffffff;
  color: #ffffff;
  background: #000000;
}

/* ── 15. Dialogs & Modals ── */
dialog,
.modal-content {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  color: var(--text-main);
  box-shadow: var(--glass-shadow);
}

html[data-theme="light"] dialog,
html[data-theme="light"] .modal-content {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.10);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.10);
  color: #0f172a;
}

html[data-theme="sepia"] dialog,
html[data-theme="sepia"] .modal-content {
  background: #faf6eb;
  border-color: rgba(140, 98, 57, 0.20);
  box-shadow: 0 10px 40px rgba(140, 98, 57, 0.12);
  color: #3d2b1f;
}

html[data-theme="high-contrast"] dialog,
html[data-theme="high-contrast"] .modal-content {
  background: #000000;
  border: 3px solid #ffffff;
  box-shadow: none;
  color: #ffffff;
  border-radius: 0;
}

/* Dialog children color overrides per tema */
html[data-theme="light"] dialog h1,
html[data-theme="light"] dialog h2,
html[data-theme="light"] dialog h3,
html[data-theme="light"] dialog h4,
html[data-theme="light"] dialog h5,
html[data-theme="light"] dialog h6,
html[data-theme="light"] .modal-content h1,
html[data-theme="light"] .modal-content h2,
html[data-theme="light"] .modal-content h3,
html[data-theme="light"] .modal-content h4,
html[data-theme="light"] .modal-content h5,
html[data-theme="light"] .modal-content h6 { color: #0f172a; }

html[data-theme="light"] dialog label,
html[data-theme="light"] .modal-content label { color: #475569; }

html[data-theme="light"] dialog .form-check-label,
html[data-theme="light"] .modal-content .form-check-label { color: #0f172a; }

html[data-theme="light"] dialog .text-muted,
html[data-theme="light"] .modal-content .text-muted { color: #475569; }

html[data-theme="light"] dialog .border,
html[data-theme="light"] .modal-content .border {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.10);
  color: #0f172a;
}

html[data-theme="light"] dialog input:disabled,
html[data-theme="light"] .modal-content input:disabled {
  background: rgba(0, 0, 0, 0.04);
  color: #475569;
  border-color: rgba(0, 0, 0, 0.10);
}

html[data-theme="light"] dialog .form-check-input,
html[data-theme="light"] .modal-content .form-check-input { border-color: rgba(0, 0, 0, 0.20); }

/* Sepia dialog children */
html[data-theme="sepia"] dialog h1,
html[data-theme="sepia"] dialog h2,
html[data-theme="sepia"] dialog h3,
html[data-theme="sepia"] dialog h4,
html[data-theme="sepia"] dialog h5,
html[data-theme="sepia"] dialog h6,
html[data-theme="sepia"] .modal-content h1,
html[data-theme="sepia"] .modal-content h2,
html[data-theme="sepia"] .modal-content h3,
html[data-theme="sepia"] .modal-content h4,
html[data-theme="sepia"] .modal-content h5,
html[data-theme="sepia"] .modal-content h6 { color: #3d2b1f; }

html[data-theme="sepia"] dialog label,
html[data-theme="sepia"] .modal-content label { color: #6b5344; }

html[data-theme="sepia"] dialog .form-check-label,
html[data-theme="sepia"] .modal-content .form-check-label { color: #3d2b1f; }

html[data-theme="sepia"] dialog .text-muted,
html[data-theme="sepia"] .modal-content .text-muted { color: #6b5344; }

html[data-theme="sepia"] dialog .border,
html[data-theme="sepia"] .modal-content .border {
  background: rgba(140, 98, 57, 0.05);
  border-color: rgba(140, 98, 57, 0.18);
  color: #3d2b1f;
}

html[data-theme="sepia"] dialog input:disabled,
html[data-theme="sepia"] .modal-content input:disabled {
  background: rgba(140, 98, 57, 0.07);
  color: #6b5344;
  border-color: rgba(140, 98, 57, 0.18);
}

html[data-theme="sepia"] dialog .form-check-input,
html[data-theme="sepia"] .modal-content .form-check-input { border-color: rgba(140, 98, 57, 0.28); }

/* High-contrast dialog children */
html[data-theme="high-contrast"] dialog h1,
html[data-theme="high-contrast"] dialog h2,
html[data-theme="high-contrast"] dialog h3,
html[data-theme="high-contrast"] dialog h4,
html[data-theme="high-contrast"] dialog h5,
html[data-theme="high-contrast"] dialog h6,
html[data-theme="high-contrast"] .modal-content h1,
html[data-theme="high-contrast"] .modal-content h2,
html[data-theme="high-contrast"] .modal-content h3,
html[data-theme="high-contrast"] .modal-content h4,
html[data-theme="high-contrast"] .modal-content h5,
html[data-theme="high-contrast"] .modal-content h6 { color: #ffffff; }

html[data-theme="high-contrast"] dialog label,
html[data-theme="high-contrast"] .modal-content label { color: #ffff00; }

html[data-theme="high-contrast"] dialog .form-check-label,
html[data-theme="high-contrast"] .modal-content .form-check-label { color: #ffffff; }

html[data-theme="high-contrast"] dialog .text-muted,
html[data-theme="high-contrast"] .modal-content .text-muted { color: #ffff00; }

html[data-theme="high-contrast"] dialog .border,
html[data-theme="high-contrast"] .modal-content .border {
  background: #000000;
  border-color: #ffffff;
  color: #ffffff;
}

html[data-theme="high-contrast"] dialog input:disabled,
html[data-theme="high-contrast"] .modal-content input:disabled {
  background: #000000;
  color: #ffff00;
  border-color: #ffffff;
}

html[data-theme="high-contrast"] dialog .form-check-input,
html[data-theme="high-contrast"] .modal-content .form-check-input { border-color: #ffffff; }

/* Ensure disabled checkbox labels inside dialogs have high opacity */
dialog .form-check-input:disabled,
dialog .form-check-label,
.modal-content .form-check-input:disabled,
.modal-content .form-check-label {
  opacity: 0.95;
}

/* ── 16. Badges & Alerts ── */
.badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 30px;
}

.alert {
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.15);
  border-radius: var(--input-radius);
  color: #ea868f;
  font-size: 0.9rem;
  padding: 12px 16px;
}

.alert-success {
  background: rgba(25, 135, 84, 0.08);
  border: 1px solid rgba(25, 135, 84, 0.15);
  color: #75b798;
}

html[data-theme="light"] .alert,
html[data-theme="sepia"] .alert {
  color: #991b1b;
  background: rgba(220, 53, 69, 0.06);
  border-color: rgba(220, 53, 69, 0.12);
}

html[data-theme="light"] .alert-success,
html[data-theme="sepia"] .alert-success {
  color: #14532d;
  background: rgba(25, 135, 84, 0.06);
  border-color: rgba(25, 135, 84, 0.12);
}

/* ── 17. Impersonation bar ── */
.impersonation-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  backdrop-filter: blur(8px);
  background: rgba(220, 53, 69, 0.88);
  border-bottom: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

/* ── 18. Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animated-fade {
  animation: fadeIn 0.4s ease forwards;
}

/* ── 19. Utility classes ── */
.bhm-surface {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  box-shadow: var(--glass-shadow);
}

.bhm-border-subtle {
  border-color: var(--glass-border) !important;
}

.bhm-text-main {
  color: var(--text-main) !important;
}

.bhm-text-muted {
  color: var(--text-muted) !important;
}

.bhm-bg-subtle {
  background: rgba(127, 127, 127, 0.06) !important;
}

html[data-theme="light"] .bhm-bg-subtle,
html[data-theme="sepia"] .bhm-bg-subtle {
  background: rgba(0, 0, 0, 0.03) !important;
}

.bhm-close-btn {
  filter: var(--theme-close-filter);
}

/* ── 20. Profile / Dashboard local components ── */
.profile-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.info-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.welcome-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-main);
}

.welcome-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.feature-card {
  background: rgba(127, 127, 127, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  padding: 24px;
  transition: background var(--transition-speed) ease,
              border-color var(--transition-speed) ease,
              transform var(--transition-speed) ease;
}

.feature-card:hover {
  background: rgba(127, 127, 127, 0.08);
  border-color: rgba(127, 127, 127, 0.16);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 1.75rem;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.feature-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.feature-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* ── 21. Bootstrap utility compatibility ── */
/* Fix bg-dark / text-muted / text-dark on dark backgrounds */
html[data-theme="dark"] .bg-dark,
html[data-theme="sepia"] .bg-dark {
  background-color: rgba(255, 255, 255, 0.10) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="sepia"] .text-muted,
html[data-theme="high-contrast"] .text-muted {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="sepia"] .text-dark {
  color: var(--text-main) !important;
}

html[data-theme="light"] .text-white {
  color: var(--text-main) !important;
}

html[data-theme="dark"] .border-secondary,
html[data-theme="sepia"] .border-secondary {
  border-color: var(--glass-border) !important;
}

html[data-theme="high-contrast"] .bg-dark {
  background-color: #000000 !important;
  border: 1px solid #ffffff !important;
}

html[data-theme="high-contrast"] .text-dark {
  color: #ffffff !important;
}

html[data-theme="high-contrast"] .border-secondary {
  border-color: #ffffff !important;
}

/* Subtle backgrounds in dark mode (Bootstrap 5 compatibility) */
html[data-theme="dark"] .bg-success-subtle {
  background-color: rgba(25, 135, 84, 0.18) !important;
}
html[data-theme="dark"] .text-success {
  color: #34d399 !important;
}
html[data-theme="dark"] .border-success-subtle {
  border-color: rgba(52, 211, 153, 0.35) !important;
}

html[data-theme="dark"] .bg-warning-subtle {
  background-color: rgba(255, 193, 7, 0.18) !important;
}
html[data-theme="dark"] .text-warning {
  color: #fbbf24 !important;
}
html[data-theme="dark"] .border-warning-subtle {
  border-color: rgba(251, 191, 36, 0.35) !important;
}

html[data-theme="dark"] .bg-danger-subtle {
  background-color: rgba(220, 53, 69, 0.18) !important;
}
html[data-theme="dark"] .text-danger {
  color: #f87171 !important;
}
html[data-theme="dark"] .border-danger-subtle {
  border-color: rgba(248, 113, 113, 0.35) !important;
}

html[data-theme="dark"] .bg-info-subtle {
  background-color: rgba(13, 202, 240, 0.18) !important;
}
html[data-theme="dark"] .text-info {
  color: #22d3ee !important;
}

/* Ensure badge links remain readable */
.badge {
  font-weight: 600;
}

/* ── 22. Responsive sidebar ── */
/* Fix bg-dark / text-muted / text-dark on dark backgrounds */
html[data-theme="dark"] .bg-dark,
html[data-theme="sepia"] .bg-dark {
  background-color: rgba(255, 255, 255, 0.10) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="sepia"] .text-muted,
html[data-theme="high-contrast"] .text-muted {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="sepia"] .text-dark {
  color: var(--text-main) !important;
}

html[data-theme="dark"] .border-secondary,
html[data-theme="sepia"] .border-secondary {
  border-color: var(--glass-border) !important;
}

html[data-theme="high-contrast"] .bg-dark {
  background-color: #000000 !important;
  border: 1px solid #ffffff !important;
}

html[data-theme="high-contrast"] .text-dark {
  color: #ffffff !important;
}

html[data-theme="high-contrast"] .border-secondary {
  border-color: #ffffff !important;
}

/* Ensure badge links remain readable */
.badge {
  font-weight: 600;
}

/* ── 22. Responsive sidebar ── */
@media (max-width: 991.98px) {
  .app-sidebar,
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-speed) ease;
  }
  .app-sidebar.open,
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .app-main,
  .admin-main {
    margin-left: 0;
    padding: 24px;
  }
}

/* ── Collapsible sidebar (icons-only, desktop) ── */
.sidebar-toggle {
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px 11px;
  font-size: 1.05rem;
  line-height: 1;
  margin-left: auto;
}
.sidebar-toggle:hover { background: rgba(127, 127, 127, 0.16); }

.app-sidebar,
.admin-sidebar { transition: width var(--transition-speed) ease; }
.app-main,
.admin-main { transition: margin-left var(--transition-speed) ease; }

@media (min-width: 992px) {
  html.sidebar-collapsed .app-sidebar,
  html.sidebar-collapsed .admin-sidebar {
    width: 76px;
    padding-left: 12px;
    padding-right: 12px;
  }
  html.sidebar-collapsed .app-main,
  html.sidebar-collapsed .admin-main {
    margin-left: 76px;
  }
  /* Hide all textual content, keep the icons */
  html.sidebar-collapsed .nav-item a span:not(.nav-icon),
  html.sidebar-collapsed .brand-logo,
  html.sidebar-collapsed .admin-badge,
  html.sidebar-collapsed .nav-menu-title,
  html.sidebar-collapsed #theme-switcher-form,
  html.sidebar-collapsed .logout-section span:not(.nav-icon) {
    display: none !important;
  }
  /* Center the remaining icons */
  html.sidebar-collapsed .nav-item a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  html.sidebar-collapsed .nav-icon { margin-right: 0 !important; }
  html.sidebar-collapsed .brand-section { justify-content: center; padding-left: 0; }
  html.sidebar-collapsed .btn-logout { justify-content: center; }
}
