/**
 * DS-05: Premium Navigation & Dropdown Menu Redesign
 * Premium SaaS-style dropdown menu with token-based styling
 */

/* ========================================
 * Dropdown Container
 * ======================================== */

.bb-identity-dropdown-wrapper {
  position: relative;
  z-index: 10001;
}

.bb-identity-dropdown {
  position: absolute;
  top: calc(100% + var(--space-xs, 8px));
  right: 0;
  min-width: 220px;
  max-width: 280px;
  max-height: 75vh;
  background: var(--card, #161516);
  border: 1px solid var(--border, rgba(196, 126, 66, 0.28));
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-modal, 0 24px 48px rgba(0, 0, 0, 0.4));
  padding: var(--space-xs, 8px) 0;
  z-index: 10000;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border, rgba(196, 126, 66, 0.4)) transparent;
  scrollbar-gutter: stable;
}

/* Webkit scrollbar styling */
.bb-identity-dropdown::-webkit-scrollbar {
  width: 6px;
}

.bb-identity-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.bb-identity-dropdown::-webkit-scrollbar-thumb {
  background: var(--border, rgba(196, 126, 66, 0.4));
  border-radius: var(--radius-sm, 8px);
}

.bb-identity-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--accent, rgba(196, 126, 66, 0.6));
}

/* ========================================
 * Dropdown Header
 * ======================================== */

.bb-identity-dropdown__header {
  padding: var(--space-sm, 12px) var(--space-md, 16px);
  border-bottom: 1px solid var(--border, rgba(196, 126, 66, 0.15));
  position: relative;
  background: transparent !important; /* Ensure consistent background */
}

.bb-identity-dropdown__header::after,
.bb-identity-dropdown__header::before,
.bb-identity-dropdown__email::after,
.bb-identity-dropdown__email::before {
  display: none !important;
  content: none !important;
}

.bb-identity-dropdown__email {
  font-size: var(--type-micro-size, 0.8125rem);
  color: var(--text-muted, var(--color-neutral-400));
  font-weight: 500;
  word-break: break-all;
  line-height: var(--type-micro-line, 1.45);
}

/* ========================================
 * Menu Groups & Separators
 * ======================================== */

.bb-identity-dropdown__divider {
  height: 1px;
  background: var(--border, rgba(196, 126, 66, 0.15));
  margin: var(--space-xs, 8px) var(--space-md, 16px);
  opacity: 0.5;
}

/* ========================================
 * Menu Items (Premium SaaS Style)
 * ======================================== */

.bb-identity-dropdown__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm, 12px);
  padding: var(--space-xs, 8px) var(--space-md, 16px);
  background: transparent !important; /* Force consistent transparent background */
  border: none;
  color: var(--text, var(--aperium-textLight));
  font-size: var(--type-body-size, 1rem);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-base, 0.2s ease);
  flex-shrink: 0;
  position: relative;
  border-radius: 0;
}

/* Hover State - CONSISTENT for all items (DS token) */
.bb-identity-dropdown__item:hover {
  background: var(--ds-surface-hover);
  color: var(--text, var(--aperium-textLight));
}

/* Focus State - CONSISTENT for all items */
.bb-identity-dropdown__item:focus {
  outline: 2px solid var(--accent, var(--aperium-copper));
  outline-offset: -2px;
  background: var(--ds-surface-hover);
}

/* Active State - CONSISTENT for all items */
.bb-identity-dropdown__item:active {
  background: var(--color-surface-active, rgba(255, 255, 255, 0.12));
  transform: translateY(0);
}

/* Danger Item (Logout) */
.bb-identity-dropdown__item--danger {
  color: var(--color-danger, #DC2626);
}

.bb-identity-dropdown__item--danger:hover {
  background: rgba(220, 38, 38, 0.15);
  color: #ff4444;
}

.bb-identity-dropdown__item--danger:focus {
  outline-color: var(--color-danger, #DC2626);
}

/* ========================================
 * Icons (Left-aligned with perfect spacing)
 * ======================================== */

.bb-identity-dropdown__icon {
  width: var(--icon-size-sm, 18px);
  height: var(--icon-size-sm, 18px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
  line-height: 1;
}

.bb-identity-dropdown__icon svg {
  width: 100%;
  height: 100%;
  color: inherit;
}

/* ========================================
 * Chevron Icons (Expandable Sections)
 * ======================================== */

.bb-identity-dropdown__chevron {
  margin-left: auto;
  flex-shrink: 0;
  width: var(--icon-size-xs, 14px);
  height: var(--icon-size-xs, 14px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  color: currentColor;
  transition: transform var(--transition-base, 0.2s ease);
}

.bb-identity-dropdown__chevron svg {
  width: 100%;
  height: 100%;
  color: inherit;
}

/* Rotate chevron when submenu is open */
.bb-identity-dropdown__submenu[aria-expanded="true"] .bb-identity-dropdown__chevron {
  transform: rotate(90deg);
}

/* ========================================
 * Check Icons (Selected Items)
 * ======================================== */

.bb-identity-dropdown__check {
  margin-left: auto;
  flex-shrink: 0;
  width: var(--icon-size-sm, 18px);
  height: var(--icon-size-sm, 18px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent, var(--aperium-copper));
}

.bb-identity-dropdown__check svg {
  width: 100%;
  height: 100%;
  color: inherit;
}

/* ========================================
 * Submenu (Expandable Sections)
 * ======================================== */

.bb-identity-dropdown__submenu {
  position: relative;
}

.bb-identity-dropdown__submenu-trigger {
  background: transparent !important; /* Ensure consistent background */
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm, 12px);
  padding: var(--space-xs, 8px) var(--space-md, 16px);
  border: none;
  color: var(--text, var(--aperium-textLight));
  font-size: var(--type-body-size, 1rem);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-base, 0.2s ease);
}

.bb-identity-dropdown__submenu-trigger:hover {
  background: var(--ds-surface-hover) !important;
  color: var(--text, var(--aperium-textLight));
}

.bb-identity-dropdown__submenu-items {
  padding-left: var(--space-md, 16px);
  border-left: 2px solid var(--border, rgba(196, 126, 66, 0.15));
  margin-left: var(--space-sm, 12px);
  margin-top: var(--space-xxs, 4px);
  margin-bottom: var(--space-xxs, 4px);
}

.bb-identity-dropdown__item--submenu {
  padding-left: calc(var(--space-md, 16px) + var(--space-lg, 24px));
  font-size: var(--type-micro-size, 0.8125rem);
  color: var(--text-muted, var(--color-neutral-400));
  padding-top: var(--space-xxs, 4px);
  padding-bottom: var(--space-xxs, 4px);
  background: transparent !important; /* Ensure consistent background */
}

/* CONSISTENT hover/focus/active states - must match base item */
.bb-identity-dropdown__item--submenu:hover {
  background: var(--ds-surface-hover) !important;
  color: var(--text, var(--aperium-textLight));
}

.bb-identity-dropdown__item--submenu:focus {
  outline: 2px solid var(--accent, var(--aperium-copper));
  outline-offset: -2px;
  background: var(--ds-surface-hover);
}

.bb-identity-dropdown__item--submenu:active {
  background: var(--color-surface-active, rgba(255, 255, 255, 0.12));
}

/* ========================================
 * Link Items
 * ======================================== */

.bb-identity-dropdown__item--link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm, 12px);
  padding: var(--space-xs, 8px) var(--space-md, 16px);
  background: transparent !important; /* Force consistent transparent background */
  border: none;
  color: var(--text, var(--aperium-textLight));
  font-size: var(--type-body-size, 1rem);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-base, 0.2s ease);
  width: 100%;
}

/* CONSISTENT hover/focus states - same as base item for consistency */
.bb-identity-dropdown__item--link:hover {
  background: var(--ds-surface-hover);
  text-decoration: none;
  color: var(--text, var(--aperium-textLight));
}

.bb-identity-dropdown__item--link:focus {
  outline: 2px solid var(--accent, var(--aperium-copper));
  outline-offset: -2px;
  background: var(--ds-surface-hover);
}

.bb-identity-dropdown__item--link:active {
  background: var(--color-surface-active, rgba(255, 255, 255, 0.12));
}

/* Ensure all dropdown items (including links) have consistent styling */
.bb-identity-dropdown__item,
.bb-identity-dropdown__item--link,
.bb-identity-dropdown__item--submenu,
.bb-identity-dropdown__item--subscription,
.bb-identity-dropdown__submenu-trigger {
  background: transparent !important; /* Force consistent transparent background for all items */
}

.bb-identity-dropdown__item:hover,
.bb-identity-dropdown__item--link:hover,
.bb-identity-dropdown__item--submenu:hover,
.bb-identity-dropdown__item--subscription:hover,
.bb-identity-dropdown__submenu-trigger:hover {
  background: var(--ds-surface-hover) !important; /* Consistent hover state via DS token */
}

/* ========================================
 * Subscription Section
 * ======================================== */

.bb-identity-dropdown__subscription {
  padding: var(--space-sm, 12px) var(--space-md, 16px);
  font-size: var(--type-micro-size, 0.8125rem);
  color: var(--text-muted, rgba(255, 255, 255, 0.8));
  line-height: var(--type-micro-line, 1.45);
  flex-shrink: 0;
  background: transparent !important; /* Ensure consistent background */
  border-top: 1px solid var(--border, rgba(196, 126, 66, 0.15)); /* Add top border for separation */
}

/* CRITICAL: Remove any background colors from items before subscription section */
.bb-identity-dropdown__item:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown__item--link:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown__item--subscription:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown__submenu-trigger:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
}

/* CRITICAL: Force transparent backgrounds on Settings, Subscription, Visit BoozeButler - MAXIMUM SPECIFICITY */
.bb-identity-dropdown #bbIdentityDropdownSettings,
.bb-identity-dropdown #bbIdentityDropdownSubscriptions,
.bb-identity-dropdown #bbIdentityDropdownVisit,
.bb-identity-dropdown a#bbIdentityDropdownSettings,
.bb-identity-dropdown a#bbIdentityDropdownSubscriptions,
.bb-identity-dropdown a#bbIdentityDropdownVisit,
.bb-identity-dropdown button#bbIdentityDropdownSettings,
.bb-identity-dropdown .bb-identity-dropdown__item#bbIdentityDropdownSettings,
.bb-identity-dropdown .bb-identity-dropdown__item#bbIdentityDropdownSubscriptions,
.bb-identity-dropdown .bb-identity-dropdown__item#bbIdentityDropdownVisit,
.bb-identity-dropdown .bb-identity-dropdown__item--link#bbIdentityDropdownSettings,
.bb-identity-dropdown .bb-identity-dropdown__item--link#bbIdentityDropdownSubscriptions,
.bb-identity-dropdown .bb-identity-dropdown__item--link#bbIdentityDropdownVisit {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* Ensure these stay transparent when not hovered/focused/active */
.bb-identity-dropdown #bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown #bbIdentityDropdownSubscriptions:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown #bbIdentityDropdownVisit:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown a#bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown a#bbIdentityDropdownSubscriptions:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown a#bbIdentityDropdownVisit:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown button#bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* Force transparent on all link states except hover/focus/active */
a.bb-identity-dropdown__item--link:link,
a.bb-identity-dropdown__item--link:visited,
a.bb-identity-dropdown__item--link:link:not(:hover):not(:focus):not(:active),
a.bb-identity-dropdown__item--link:visited:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* CRITICAL: Remove any goldish/amber tint from specific items - highest specificity */
.bb-identity-dropdown__item,
.bb-identity-dropdown__item--link,
button.bb-identity-dropdown__item,
a.bb-identity-dropdown__item--link {
  background: transparent !important;
  background-color: transparent !important;
}

.bb-identity-dropdown__item:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown__item--link:not(:hover):not(:focus):not(:active),
button.bb-identity-dropdown__item:not(:hover):not(:focus):not(:active),
a.bb-identity-dropdown__item--link:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* Override any theme-specific backgrounds that might add tint */
:root[data-ui-theme='aperium'] .bb-identity-dropdown__item:not(:hover):not(:focus):not(:active),
:root[data-ui-theme='aperium'] .bb-identity-dropdown__item--link:not(:hover):not(:focus):not(:active),
:root[data-ui-theme='halytic'] .bb-identity-dropdown__item:not(:hover):not(:focus):not(:active),
:root[data-ui-theme='halytic'] .bb-identity-dropdown__item--link:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

.bb-identity-dropdown__subscription-plan,
.bb-identity-dropdown__subscription-status {
  display: block;
  color: var(--text-muted, rgba(255, 255, 255, 0.8));
  font-size: var(--type-micro-size, 0.8125rem);
  line-height: var(--type-micro-line, 1.45);
}

/* CRITICAL FIX: Ensure subscription text is readable */
:root[data-ui-theme='aperium'][data-bar-mode='dark'] .bb-identity-dropdown__subscription-plan,
:root[data-ui-theme='aperium'][data-bar-mode='dark'] .bb-identity-dropdown__subscription-status {
  color: rgba(255, 255, 255, 0.85);
}

:root[data-ui-theme='aperium'][data-bar-mode='light'] .bb-identity-dropdown__subscription-plan,
:root[data-ui-theme='aperium'][data-bar-mode='light'] .bb-identity-dropdown__subscription-status {
  color: rgba(15, 23, 42, 0.75);
}

:root[data-ui-theme='halytic'] .bb-identity-dropdown__subscription-plan,
:root[data-ui-theme='halytic'] .bb-identity-dropdown__subscription-status {
  color: var(--halytic-text-muted, #6B7280);
}

.bb-identity-dropdown__subscription.is-trial .bb-identity-dropdown__subscription-plan {
  color: #ffe2ba;
}

.bb-identity-dropdown__subscription.is-active .bb-identity-dropdown__subscription-plan {
  color: #b6f3cf;
}

/* CRITICAL: Ensure subscription section never applies background to items above it */
.bb-identity-dropdown__subscription.is-trial,
.bb-identity-dropdown__subscription.is-active,
.bb-identity-dropdown__subscription.is-pro {
  background: transparent !important;
  background-color: transparent !important;
}

.bb-identity-dropdown__item--subscription {
  padding: var(--space-xs, 8px) var(--space-md, 16px);
  background: transparent !important; /* Ensure consistent background */
}

/* CONSISTENT hover/focus/active states for subscription items */
.bb-identity-dropdown__item--subscription:hover {
  background: var(--ds-surface-hover) !important;
  color: var(--text, var(--aperium-textLight));
}

.bb-identity-dropdown__item--subscription:focus {
  outline: 2px solid var(--accent, var(--aperium-copper));
  outline-offset: -2px;
  background: var(--ds-surface-hover);
}

.bb-identity-dropdown__item--subscription:active {
  background: var(--color-surface-active, rgba(255, 255, 255, 0.12));
}

/* ========================================
 * Theme-Specific Overrides
 * ======================================== */

:root[data-ui-theme='halytic'] .bb-identity-dropdown {
  background: var(--halytic-bg, #FFFFFF);
  border-color: var(--halytic-border, #E2E8F0);
  box-shadow: var(--shadow-card, 0 12px 24px rgba(0, 0, 0, 0.08));
}

:root[data-ui-theme='halytic'] .bb-identity-dropdown__item:hover {
  /* Use unified DS hover token for all themes */
  background: var(--ds-surface-hover);
}

:root[data-ui-theme='aperium'][data-bar-mode='light'] .bb-identity-dropdown {
  background: var(--aperium-ivory, #F7F5F2);
  border-color: rgba(196, 126, 66, 0.2);
}

:root[data-ui-theme='aperium'][data-bar-mode='light'] .bb-identity-dropdown__item:hover {
  /* Use unified DS hover token for all themes */
  background: var(--ds-surface-hover);
}

/* ========================================
 * Mobile Responsive
 * ======================================== */

@media (max-width: 768px) {
  .bb-identity-dropdown {
    min-width: 200px;
    max-width: calc(100vw - var(--space-lg, 24px));
    right: var(--space-xs, 8px);
    max-height: calc(100vh - 100px);
  }

  .bb-identity-dropdown__item,
  .bb-identity-dropdown__item--link {
    padding: var(--space-xs, 8px) var(--space-sm, 12px);
    font-size: var(--type-body-size, 1rem);
  }

  .bb-identity-dropdown__header {
    padding: var(--space-sm, 12px) var(--space-sm, 12px);
  }

  .bb-identity-dropdown__subscription {
    padding: var(--space-sm, 12px) var(--space-sm, 12px);
  }
}

/* ========================================
 * Accessibility Improvements
 * ======================================== */

.bb-identity-dropdown__item[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
/* Keyboard focus - unified DS focus ring + hover surface */
.bb-identity-dropdown__item:focus-visible {
  outline: 2px solid var(--ds-focus-ring, var(--accent, var(--aperium-copper)));
  outline-offset: -2px;
  background: var(--ds-surface-hover);
  z-index: 1;
}

/* DS-12: Ensure dropdown icons use DS icon sizing and secondary text color */
.bb-identity-dropdown__icon .bb-icon {
  width: var(--ds-icon-sm);
  height: var(--ds-icon-sm);
  color: var(--ds-text-secondary);
}

/* FINAL OVERRIDE: Force transparent backgrounds on problematic items - ABSOLUTE MAXIMUM SPECIFICITY */
.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownSettings,
.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownSubscriptions,
.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownVisit,
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownSettings,
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownSubscriptions,
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownVisit,
.bb-identity-dropdown-wrapper .bb-identity-dropdown button#bbIdentityDropdownSettings {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownSubscriptions:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown #bbIdentityDropdownVisit:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownSubscriptions:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown a#bbIdentityDropdownVisit:not(:hover):not(:focus):not(:active),
.bb-identity-dropdown-wrapper .bb-identity-dropdown button#bbIdentityDropdownSettings:not(:hover):not(:focus):not(:active) {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

/* B4: Submenu items hover should also use DS hover surface */
.bb-identity-dropdown__submenu-items > div:hover {
  background: var(--ds-surface-hover);
}

/* B2: Theme-mode unified hover behavior */
[data-theme] .bb-identity-dropdown__item:hover {
  background: var(--ds-surface-hover);
}

