/* Compact role dropdown menus.
   Groups are simple headings with lightweight link rows: no card-like boxes, no nested section toggles. */
.nav-dropdown-menu--grouped{
  box-sizing:border-box;
  min-width:min(336px,calc(100vw - 24px));
  max-height:min(78vh,680px);
  overflow:auto;
  overscroll-behavior:contain;
  padding:8px;
  gap:6px;
  background:var(--card,var(--surface));
  border:1px solid var(--line);
  box-shadow:var(--shadow-lg, var(--shadow));
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

.nav-dropdown-menu--grouped>a,
.nav-dropdown-menu--grouped .nav-dropdown-form button,
.nav-menu-group__links>a,
.nav-nested-menu>a,
.nav-nested-menu .nav-dropdown-form button{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  box-sizing:border-box;
  width:100%;
  min-height:34px;
  border:0!important;
  border-radius:8px;
  padding:7px 9px;
  background:transparent!important;
  box-shadow:none!important;
  color:var(--ink);
  font-size:var(--font-size-small,14px);
  font-weight:var(--font-weight-base,400);
  line-height:1.25;
  text-align:left;
  white-space:normal;
  -webkit-user-select:none;
  user-select:none;
}

.nav-dropdown-menu--grouped>a:hover,
.nav-dropdown-menu--grouped .nav-dropdown-form button:hover,
.nav-menu-group__links>a:hover,
.nav-nested-menu>a:hover,
.nav-nested-menu .nav-dropdown-form button:hover,
.nav-dropdown-menu--grouped>a:focus-visible,
.nav-dropdown-menu--grouped .nav-dropdown-form button:focus-visible,
.nav-menu-group__links>a:focus-visible,
.nav-nested-menu>a:focus-visible,
.nav-nested-menu .nav-dropdown-form button:focus-visible{
  background:var(--surface-2,var(--card))!important;
  color:var(--ink);
}

.nav-dropdown-menu--grouped>.nav-menu-group,
.nav-dropdown-menu--grouped>.nav-nested-dropdown{
  margin-top:4px;
  padding-top:8px;
  border-top:1px solid var(--line);
}

.nav-menu-group{
  display:grid;
  gap:5px;
  min-width:0;
}

.nav-menu-group__title,
.nav-nested-summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:22px;
  padding:0 4px;
  border:0;
  background:transparent;
  color:var(--muted);
  font-family:inherit;
  font-size:11px;
  font-weight:var(--font-weight-strong,700);
  line-height:1.2;
  letter-spacing:.02em;
  text-transform:uppercase;
}

.nav-menu-group__links,
.nav-nested-menu{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:2px 4px;
  min-width:0;
}

.nav-nested-dropdown{
  display:block;
  box-sizing:border-box;
  width:100%;
  min-width:0;
  max-width:100%;
  overflow:hidden;
}

.nav-nested-summary{
  box-sizing:border-box;
  width:100%;
  cursor:pointer;
  list-style:none;
  -webkit-tap-highlight-color:transparent;
  -webkit-touch-callout:none;
  -webkit-user-select:none;
  user-select:none;
}

.nav-nested-summary:focus:not(:focus-visible){
  outline:none;
}

.nav-nested-summary::selection,
.nav-nested-summary *::selection,
.nav-nested-menu::selection,
.nav-nested-menu *::selection{
  background:transparent;
}

.nav-nested-summary::-moz-selection,
.nav-nested-summary *::-moz-selection,
.nav-nested-menu::-moz-selection,
.nav-nested-menu *::-moz-selection{
  background:transparent;
}

.nav-nested-summary::-webkit-details-marker{
  display:none;
}

.nav-nested-summary::after{
  content:"▾";
  color:var(--muted);
  font-size:12px;
  transition:transform .16s ease;
}

.nav-nested-dropdown[open]>.nav-nested-summary::after{
  transform:rotate(180deg);
}

.nav-nested-menu{
  box-sizing:border-box;
  width:100%;
  max-width:100%;
  margin-top:4px;
  padding:6px;
  overflow:hidden;
  border-radius:10px;
  background:var(--surface,var(--card));
  box-shadow:inset 0 0 0 1px var(--line);
}

.nav-dropdown-menu--grouped .nav-dropdown-form{
  box-sizing:border-box;
  width:100%;
  min-width:0;
  margin:0;
  padding:0;
}

.nav-nested-menu>.nav-dropdown-form{
  min-width:0;
}

.nav-nested-menu .nav-dropdown-form button{
  min-width:0;
  overflow-wrap:anywhere;
}

.nav-dropdown-menu--grouped>.nav-dropdown-form{
  margin-top:6px;
  padding-top:8px;
  border-top:1px solid var(--line);
}

.nav-dropdown-menu--grouped>.nav-dropdown-form button{
  color:var(--danger,var(--ink));
}

.nav-menu-link-with-badge,
.nav-dropdown-menu--grouped .nav-menu-link-with-badge{
  justify-content:space-between;
}

.nav-menu-link-with-badge>span:first-child{
  min-width:0;
}

.nav-dropdown-menu--grouped .active-business-choice{
  background:var(--surface-2,var(--card))!important;
  color:var(--ink)!important;
  font-weight:var(--font-weight-strong,700)!important;
}

.nav-dropdown-empty{
  display:block;
  padding:7px 9px;
  color:var(--muted);
  font-size:var(--font-size-small,14px);
}

@media(max-width:960px){
  .nav-dropdown-menu--grouped{
    max-height:none;
    overflow:visible;
    padding:4px 0;
  }
}

@media(max-width:720px){
  .nav-menu-group__links,
  .nav-nested-menu{
    grid-template-columns:1fr;
  }
}

.profile-menu-groups{
  display:grid;
  gap:14px;
  width:100%;
}

.profile-menu-group{
  display:grid;
  gap:8px;
}

.profile-menu-group>h3{
  margin:0;
  color:var(--muted);
  font-size:var(--font-size-small,14px);
  font-weight:var(--font-weight-strong,700);
  line-height:1.25;
}

/* Keep dropdowns fully opaque in dark/system-dark themes. */
html[data-crm-theme="dark"] .nav-dropdown-menu,
html[data-crm-theme="dark"] .nav-dropdown-menu--grouped,
html[data-crm-theme="dark"] .nav-nested-menu,
html[data-crm-theme="dark"] body[data-interface-mode="pwa"] .nav-dropdown-menu,
html[data-crm-theme="dark"] body[data-interface-mode="pwa"] .nav-dropdown-menu--grouped,
html[data-crm-theme="dark"] body[data-interface-mode="pwa"] .nav-nested-menu,
html[data-crm-theme="dark"] body[data-interface-mode="mobile"] .nav-dropdown-menu,
html[data-crm-theme="dark"] body[data-interface-mode="mobile"] .nav-dropdown-menu--grouped,
html[data-crm-theme="dark"] body[data-interface-mode="mobile"] .nav-nested-menu{
  background:var(--card,var(--surface))!important;
  background-color:var(--card,var(--surface))!important;
  border-color:var(--line)!important;
  color:var(--ink)!important;
  backdrop-filter:none!important;
  -webkit-backdrop-filter:none!important;
}

html[data-crm-theme="dark"] .nav-nested-menu{
  box-shadow:inset 0 0 0 1px var(--line)!important;
}

html[data-crm-theme="dark"] .nav-dropdown-menu a,
html[data-crm-theme="dark"] .nav-dropdown-menu--grouped a,
html[data-crm-theme="dark"] .nav-dropdown-form button,
html[data-crm-theme="dark"] .nav-nested-menu a,
html[data-crm-theme="dark"] .nav-nested-menu .nav-dropdown-form button{
  color:var(--ink)!important;
}

html[data-crm-theme="dark"] .nav-dropdown-menu a:hover,
html[data-crm-theme="dark"] .nav-dropdown-menu--grouped a:hover,
html[data-crm-theme="dark"] .nav-dropdown-form button:hover,
html[data-crm-theme="dark"] .nav-dropdown-menu a:focus-visible,
html[data-crm-theme="dark"] .nav-dropdown-menu--grouped a:focus-visible,
html[data-crm-theme="dark"] .nav-dropdown-form button:focus-visible{
  background:var(--surface-2,var(--card))!important;
  background-color:var(--surface-2,var(--card))!important;
}

@media (prefers-color-scheme: dark){
  html[data-crm-theme="system"] .nav-dropdown-menu,
  html[data-crm-theme="system"] .nav-dropdown-menu--grouped,
  html[data-crm-theme="system"] .nav-nested-menu,
  html[data-crm-theme="system"] body[data-interface-mode="pwa"] .nav-dropdown-menu,
  html[data-crm-theme="system"] body[data-interface-mode="pwa"] .nav-dropdown-menu--grouped,
  html[data-crm-theme="system"] body[data-interface-mode="pwa"] .nav-nested-menu,
  html[data-crm-theme="system"] body[data-interface-mode="mobile"] .nav-dropdown-menu,
  html[data-crm-theme="system"] body[data-interface-mode="mobile"] .nav-dropdown-menu--grouped,
  html[data-crm-theme="system"] body[data-interface-mode="mobile"] .nav-nested-menu{
    background:var(--card,var(--surface))!important;
    background-color:var(--card,var(--surface))!important;
    border-color:var(--line)!important;
    color:var(--ink)!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }

  html[data-crm-theme="system"] .nav-nested-menu{
    box-shadow:inset 0 0 0 1px var(--line)!important;
  }

  html[data-crm-theme="system"] .nav-dropdown-menu a,
  html[data-crm-theme="system"] .nav-dropdown-menu--grouped a,
  html[data-crm-theme="system"] .nav-dropdown-form button,
  html[data-crm-theme="system"] .nav-nested-menu a,
  html[data-crm-theme="system"] .nav-nested-menu .nav-dropdown-form button{
    color:var(--ink)!important;
  }

  html[data-crm-theme="system"] .nav-dropdown-menu a:hover,
  html[data-crm-theme="system"] .nav-dropdown-menu--grouped a:hover,
  html[data-crm-theme="system"] .nav-dropdown-form button:hover,
  html[data-crm-theme="system"] .nav-dropdown-menu a:focus-visible,
  html[data-crm-theme="system"] .nav-dropdown-menu--grouped a:focus-visible,
  html[data-crm-theme="system"] .nav-dropdown-form button:focus-visible{
    background:var(--surface-2,var(--card))!important;
    background-color:var(--surface-2,var(--card))!important;
  }
}
