/* =============================
   Header / Menu (Dark Blue)
   ============================= */

/* Header shell */
header {
  background: #0b1c36;
  color: #e6f0ff;
  padding: 10px 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  z-index: 1000;
  margin: 0;
}

/* Top row with logo + hamburger */
.header-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: center;
}

/* Logo */
header h1 {
  margin: 0;
  font-size: 24px;
  color: #e6f0ff;
}

/* Hamburger (mobile) */
.hamburger {
  font-size: 24px;
  cursor: pointer;
  color: #e6f0ff;
  user-select: none;
}

/* =============================
   Mobile default menu (slide down)
   ============================= */
#menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: #0b1c36;
  color: #e6f0ff;
  flex-direction: column;
  align-items: flex-start;
  overflow: visible;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.5s ease, opacity 0.5s ease;
  padding: 0;
  z-index: 999;
  margin: 0;
  visibility: hidden;
  border-top: 1px solid rgba(255,255,255,0.06);
}

#menu.active {
  visibility: visible;
  opacity: 1;
  max-height: 300px;
  padding: 10px 0;
}

/* Menu items */
#menu li {
  list-style-type: none;
  padding: 10px 20px;
  text-align: left;
  width: 100%;
}

/* Top-level menu link colors on MOBILE = white */
#menu > li > a {
  color: #ffffff;                 /* mobile: white main menu names */
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  line-height: 1.1;
}
#menu > li > a:hover {
  text-decoration: underline;
  color: #ffffff;
}

/* Badge */
.badge {
  background-color: #2563eb;
  color: #fff;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  margin-left: 5px;
  vertical-align: top;
}

/* =============================
   Desktop layout
   ============================= */
@media (min-width: 768px) {
  header {
    flex-direction: row;
    align-items: center;
    padding: 10px 15px;
  }

  .hamburger { display: none; }

  /* Desktop menu: inline, right-aligned, tighter spacing */
  #menu {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    max-height: none;
    opacity: 1;
    overflow: visible;
    padding: 0;
    visibility: visible;
    gap: 6px;
    flex-wrap: nowrap;
    background-color: transparent;
    color: #e6f0ff;
    border-top: 0;
  }

  /* remove mobile li padding on desktop */
  #menu li {
    padding: 0;
    width: auto;
  }

  /* Desktop top-level: dark blue labels */
  #menu > li > a {
    display: inline-flex;
    align-items: center;
    padding: 8px 10px;
    text-decoration: none;
    color: #1e3a8a;         /* DARK BLUE (desktop main menu names) */
  }
  #menu > li > a:hover,
  #menu > li > a:focus {
    color: #2d6df6;         /* brighter blue hover */
    text-decoration: underline;
  }

  /* Desktop-only: small gap between icons and labels (menu + submenu) */
  #menu a,
  .dropdown-menu li a {
    display: inline-flex;
    align-items: center;
  }
  #menu a > i,
  #menu a > svg,
  #menu a > img,
  #menu a > .icon,
  .dropdown-menu li a > i,
  .dropdown-menu li a > svg,
  .dropdown-menu li a > img,
  .dropdown-menu li a > .icon {
    margin-right: 6px;
  }
}

/* =============================
   Dropdowns (fix: works on hover OR .open class; no scrollbar flash)
   ============================= */
.dropdown {
  position: relative;
  overflow: visible; /* don't clip the menu */
}

/* CLOSED STATE (no scrollbars) */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #0b1c36;  /* dark blue dropdown */
  border: none;
  box-shadow: none;
  z-index: 1001;
  min-width: 200px;
  padding: 8px 0;
  border-radius: 10px;

  max-height: 0;              /* collapse height */
  overflow: hidden;           /* no scrollbar when closed */
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition:
    max-height .24s ease,
    opacity .18s ease,
    transform .18s ease,
    visibility 0s linear .18s; /* delay visibility so no flicker */
  will-change: opacity, transform;
}

/* OPEN STATE —
   Works if your JS adds .open to the menu,
   OR adds .open to the parent .dropdown,
   OR if the menu opens on :hover (Exchange style). */
.dropdown-menu.open,
.dropdown.open > .dropdown-menu,
.dropdown:hover > .dropdown-menu,
.dropdown-menu.show {          /* support .show if used */
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  max-height: 70vh;            /* allow tall menus */
  overflow-y: auto;            /* enable scrolling when needed, but... */
  -webkit-overflow-scrolling: touch;

  /* hide scrollbars to avoid the brief flash while opening */
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge legacy */
}
.dropdown-menu.open::-webkit-scrollbar,
.dropdown.open > .dropdown-menu::-webkit-scrollbar,
.dropdown:hover > .dropdown-menu::-webkit-scrollbar,
.dropdown-menu.show::-webkit-scrollbar {
  display: none;               /* WebKit */
}

/* Submenu items (stay white) */
.dropdown-menu li { list-style: none; margin: 0; padding: 0; }
.dropdown-menu li a {
  display: block;
  padding: 10px 20px;
  color: #ffffff;             /* keep submenu names white */
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
}
.dropdown-menu li a:hover {
  background-color: #102544;  /* darker blue hover bg */
  color: #ffffff;
}

/* =============================
   Mobile dropdown: stretch; don't cut off
   ============================= */
@media (max-width: 767.98px) {
  .dropdown-menu {
    left: 0;
    right: 0;
    min-width: unset;
    width: 100%;
    box-shadow: none;       /* flat on mobile */
    border-radius: 0;
  }

  /* Mobile top-level links should be white */
  #menu > li > a {
    color: #ffffff;
  }
}
