/* =========================================================
   NAVBAR — SOLID, THEME AWARE, MOBILE OPTIMISED
   ========================================================= */

.navbar {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  background-color: inherit;
}

/* =========================================================
   THEMES
   ========================================================= */

body[data-theme="light"] .navbar {
  background-color: #1e3a8a;
  color: #ffffff;
}

body[data-theme="blue"] .navbar {
  background-color: #1e2a6d;
  color: #e5faff;
}

body[data-theme="dark"] .navbar {
  background-color: #0f172a;
  color: #e5e7eb;
}

.navbar a,
.brand {
  color: inherit;
}

/* =========================================================
   LAYOUT
   ========================================================= */

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 18px;
  font-weight: 700;
}

/* =========================================================
   DESKTOP NAV
   ========================================================= */

.nav-links.desktop {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
}

.nav-links.desktop a {
  position: relative;
  font-weight: 500;
  text-decoration: none;
}

/* Active underline */
.nav-links.desktop a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.nav-links.desktop a:hover::after,
.nav-links.desktop a.active::after {
  transform: scaleX(1);
}

/* =========================================================
   MEGA MENUS (DESKTOP ONLY)
   ========================================================= */

.dropdown {
  position: relative;
}

.dropdown > a::after {
  content: "\f078";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.7rem;
  margin-left: 0.3rem;
}

.mega-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: 640px;
  max-width: 90vw;
  background: #1e3a8a;
  border-radius: 12px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.25s ease;
}

.dropdown:hover .mega-menu,
.dropdown:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.mega-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  padding: 2rem;
}

.mega-grid h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.mega-grid a {
  font-size: 0.95rem;
}

/* =========================================================
   USER BADGE
   ========================================================= */

.user-greeting {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  font-size: 0.85rem;
}

.avatar-wrap img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* =========================================================
   USER DROPDOWN
   ========================================================= */

.user-menu {
  position: relative;
}

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 180px;
  background: #ffffff;
  color: #111827;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.user-menu.open .user-dropdown {
  display: block;
}

.user-dropdown a,
.user-dropdown button {
  padding: 0.7rem 1rem;
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

/* =========================================================
   MOBILE NAVIGATION (OPTIMISED)
   ========================================================= */

.nav-toggle {
  display: none;
  font-size: 26px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

/* Mobile menu container */
.nav-links.mobile {
  display: none;
  flex-direction: column;
  background-color: inherit;
  padding: 12px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-links.mobile.nav-open {
  display: flex;
}

/* Mobile links */
.nav-links.mobile li {
  list-style: none;
}

.nav-links.mobile a {
  display: block;
  padding: 14px 0;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
}

/* Mobile user greeting */
.nav-links.mobile .user-greeting {
  margin-top: 12px;
  justify-content: center;
}

/* =========================================================
   BREAKPOINTS
   ========================================================= */

@media (max-width: 900px) {

  .nav-links.desktop {
    display: none;
  }

  .nav-toggle {
    display: block;
  }

  /* Disable mega menus completely on mobile */
  .mega-menu {
    display: none !important;
  }
}

/* =========================================================
   MEGA MENU — HEADER HIERARCHY & PREMIUM EFFECTS (DESKTOP)
   ========================================================= */

/* Strengthen mega container presence */
.mega-menu {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0)
  );
}

/* =========================================================
   MEGA COLUMN HEADERS (TRUE MEGA FEEL)
   ========================================================= */

.mega-grid h4 {
  position: relative;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  padding-bottom: 0.7rem;
  margin-bottom: 1.3rem;
}

/* Accent bar under headers */
.mega-grid h4::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 52px;
  height: 3px;
  background: linear-gradient(
    90deg,
    #fbbf24,
    #fde68a
  );
  border-radius: 999px;
}

/* =========================================================
   COLUMN GROUPING & VISUAL SEPARATION
   ========================================================= */

.mega-grid > div {
  position: relative;
  padding-right: 1.25rem;
}

/* Vertical separators between columns */
.mega-grid > div:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0.75rem;
  right: -1.25rem;
  width: 1px;
  height: calc(100% - 1.5rem);
  background: rgba(255, 255, 255, 0.12);
}

/* =========================================================
   LINK ENHANCEMENT — DIRECTIONAL & PREMIUM
   ========================================================= */

.mega-grid a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #e5e7eb;
  font-weight: 500;
  transition:
    color 0.25s ease,
    transform 0.25s ease;
}

/* Chevron reveal */
.mega-grid a::before {
  content: "\f105";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  opacity: 0;
  transform: translateX(-6px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.mega-grid a:hover {
  color: #ffffff;
  transform: translateX(6px);
}

.mega-grid a:hover::before {
  opacity: 1;
  transform: translateX(0);
}

/* =========================================================
   OPEN STATE — DEPTH & AUTHORITY
   ========================================================= */

.dropdown:hover .mega-menu,
.dropdown:focus-within .mega-menu {
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* =========================================================
   THEME-AWARE MEGA ACCENTS
   ========================================================= */

body[data-theme="blue"] .mega-menu {
  background-color: #1e2a6d;
}

body[data-theme="dark"] .mega-menu {
  background-color: #0f172a;
}

body[data-theme="dark"] .mega-grid h4::after {
  background: linear-gradient(
    90deg,
    #38bdf8,
    #7dd3fc
  );
}
/* =========================================================
   FINAL FIX — MEGA MENU AUTO-WIDTH + SINGLE LINE + DIVIDERS
   ========================================================= */

/* Ensure mega menu sizes to content */
.mega-menu {
  width: auto;
  max-width: none;
  white-space: nowrap;
}

/* Force horizontal layout for mega sections */
.mega-grid {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0; /* spacing handled by padding + dividers */
  padding: 2rem 2.5rem;
}

/* Each column / section */
.mega-grid > div {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: max-content;
  padding: 0 2rem;
}

/* Vertical divider between sections */
.mega-grid > div:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0.08)
  );
}

/* Edge cleanup */
.mega-grid > div:first-child {
  padding-left: 0;
}

.mega-grid > div:last-child {
  padding-right: 0;
}

/* Prevent wrapping of links */
.mega-grid a {
  white-space: nowrap;
}



/* =========================================================
   FINAL MOBILE MENU FIX — RELIABLE & CLICKABLE
   ========================================================= */

/* Ensure navbar stays above content */
.navbar {
  z-index: 1000;
}

/* Mobile menu container — authoritative */
@media (max-width: 900px) {

  /* Mobile menu panel */
  .nav-links.mobile {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: inherit;
    display: none;
    flex-direction: column;
    padding: 16px 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  }

  /* OPEN STATE */
  .nav-links.mobile.nav-open {
    display: flex;
  }

  /* Prevent overlap blocking clicks */
  .nav-links.mobile,
  .nav-links.mobile * {
    pointer-events: auto;
  }

  /* Mobile links */
  .nav-links.mobile a {
    padding: 14px 0;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
  }

  /* Mobile user badge spacing */
  .nav-links.mobile .user-greeting {
    margin-top: 16px;
    justify-content: flex-start;
  }

  /* Disable mega menu hover traps on mobile */
  .dropdown:hover .mega-menu {
    display: none !important;
  }
}


/* =========================================================
   MOBILE OVERLAY + CLICK SAFETY (REQUIRED)
   ========================================================= */

/* Overlay created by JS */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 998; /* below navbar, above page */
}

/* Overlay active state */
.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Ensure navbar stays above overlay */
.navbar {
  z-index: 1000;
}

/* =========================================================
   MOBILE MENU PANEL — AUTHORITATIVE POSITIONING
   ========================================================= */

@media (max-width: 900px) {

  /* Mobile menu panel */
  .nav-links.mobile {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: inherit;
    z-index: 999;
    display: none;
    flex-direction: column;
    padding: 16px 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  }

  /* Open state */
  .nav-links.mobile.nav-open {
    display: flex;
  }

  /* Prevent click blocking */
  .nav-links.mobile,
  .nav-links.mobile * {
    pointer-events: auto;
  }

  /* Mobile links spacing */
  .nav-links.mobile a {
    padding: 14px 0;
    font-size: 1rem;
    font-weight: 500;
  }

  /* Mobile user greeting alignment */
  .nav-links.mobile .user-greeting {
    margin-top: 16px;
    justify-content: flex-start;
  }

  /* Disable hover-based mega menus on mobile */
  .dropdown:hover .mega-menu {
    display: none !important;
  }
}

/* =========================================================
   MOBILE SIDEBAR (PURE CSS)
   ========================================================= */

.sidebar {
  position: fixed;
  top: 0;
  left: -300px;
  width: 300px;
  height: 100vh;
  background-color: inherit;
  color: inherit;
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
  transition: left 0.35s ease;
  z-index: 4000;
  padding: 1.25rem;
  overflow-y: auto;
}

#menu-toggle:checked ~ .sidebar {
  left: 0;
}

.close {
  font-size: 28px;
  cursor: pointer;
  display: block;
  text-align: right;
  margin-bottom: 1.5rem;
}

.menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu > li {
  margin-bottom: 0.25rem;
}

.menu a {
  display: block;
  padding: 0.75rem 0;
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}

.menu-divider {
  height: 1px;
  background: currentColor;
  opacity: 0.15;
  margin: 0.75rem 0;
}

/* Accordion submenus */
.has-submenu {
  margin-bottom: 0.5rem;
}

.submenu-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  cursor: pointer;
  font-weight: 600;
  color: inherit;
}

.chev {
  transition: transform 0.3s ease;
  font-size: 1.2rem;
}

.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  padding-left: 1rem;
  list-style: none;
}

.has-submenu input:checked + .submenu-toggle .chev {
  transform: rotate(180deg);
}

.has-submenu input:checked ~ .submenu {
  max-height: 1200px; /* large enough for all content */
}

.submenu-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0.75rem 0 0.25rem;
  color: #fae105;
  opacity: 0.9;
}

/* Mobile user badge styling */
#user-badge-mobile .submenu-toggle {
  gap: 0.75rem;
  align-items: center;
}

#user-badge-mobile .submenu-toggle > div {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

#user-avatar-mobile {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 3500;
}

#menu-toggle:checked ~ .overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Hide mobile elements on desktop */
@media (min-width: 901px) {
  .nav-toggle,
  .sidebar,
  .overlay {
    display: none;
  }
}

/* Hide desktop nav on mobile (keep your existing rule) */
@media (max-width: 900px) {
  .nav-links.desktop {
    display: none;
  }
  .nav-toggle {
    display: block;
  }
  .mega-menu {
    display: none !important;
  }
}

/* Theme-aware sidebar background (add to your existing theme section) */
body[data-theme="light"] .sidebar,
body[data-theme="blue"] .sidebar,
body[data-theme="dark"] .sidebar {
  background-color: inherit;
  color: inherit;
}