/* ------------------------------------------------------------------
   CANONICAL NAVIGATION SYSTEM — FINAL POLISH
------------------------------------------------------------------ */

/* ===============================================================

   NAVIGATION — SIDEBAR, ICONS, ACTIVE STATES

   Phase B Consolidation (Chunk 120)

   =============================================================== */

/* Icon sizing (merged from ui-professional-polish) */

.bb-nav__icon,

.bb-icon {

  width: 20px;

  height: 20px;

  opacity: 0.7;

}

.bb-nav__item--active .bb-nav__icon,

.bb-nav__item[aria-current="page"] .bb-nav__icon {

  opacity: 1;

  color: var(--bb-gold);

}

/* Sidebar item styling */

.bb-nav__item {

  padding: 12px var(--bb-space-md);

  display: flex;

  align-items: center;

  gap: var(--bb-space-md);

  margin-bottom: 2px;

  color: var(--bb-deep);

}

.bb-nav__item--active,

.bb-nav__item[aria-current="page"] {

  background: rgba(191,160,90,0.1);

  border-left: 3px solid var(--bb-gold);

  font-weight: 500;

}

.bb-nav__item:hover:not(.bb-nav__item--active):not([aria-current="page"]) {

  background: rgba(191,160,90,0.08);

}

.bb-nav__section-label {

  font-size: 12px;

  font-weight: 600;

  text-transform: uppercase;

  margin: 20px 0 0 var(--bb-space-sm);

  opacity: 0.6;

  letter-spacing: 0.05em;

}

.bb-sidebar {
  width: 240px;
  padding: 24px 16px;
  background: var(--bb-nav-bg, #ffffff);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Section Titles */
.bb-nav-section-title {
  margin: 24px 0 8px;
  font-size: var(--font-size-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(0, 0, 0, 0.45);
}

/* Nav Links */
.bb-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  font-size: var(--font-size-md);
  font-weight: var(--weight-regular);
  text-decoration: none;
  color: #333;
  transition: background 0.15s ease, color 0.15s ease;
}

.bb-nav-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

.bb-nav-link.active {
  background: rgba(0, 0, 0, 0.07);
  font-weight: var(--weight-semibold);
  position: relative;
}

.bb-nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 70%;
  background: var(--bb-accent, #c79c47);
  border-radius: 0 4px 4px 0;
}

/* Icons */
.bb-nav-link .icon {
  width: 20px;
  height: 20px;
  opacity: 0.9;
  display: inline-block;
  flex-shrink: 0;
}

.bb-nav-link:hover .icon {
  opacity: 1;
}

/* PRO Badge */
.bb-pro-badge {
  margin-left: auto;
  padding: 2px 6px;
  background: #f5d7a2;
  border-radius: 6px;
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: #735c2f;
}

/* Mobile Drawer */
@media (max-width: 960px) {
  /* The sidebar content should never disable touch scrolling on mobile */
  #bb-nav .bb-sidebar,
  #bbMobileNav .bb-sidebar {
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Hard lock background scroll via html/body class (JS toggles both) */
  html.bb-nav-open,
  body.bb-nav-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }
  
  /* Drawer container positioning - handled by #bb-nav in ui-components.css */
  /* Sidebar inside should be relative, not fixed - parent drawer handles scrolling */
  #bb-nav .bb-sidebar,
  #bbMobileNav .bb-sidebar {
    position: relative !important; /* Relative to parent container */
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    height: auto !important;
    width: 100% !important;
    /* CRITICAL: Remove nested scroll - parent drawer container handles scrolling */
    overflow: visible !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    /* Ensure sidebar doesn't prevent parent scroll */
    touch-action: pan-y !important; /* Allow vertical scroll gestures */
  }
  
  /* CRITICAL: Ensure drawer container can scroll when body scroll is locked */
  body.bb-nav-open #bb-nav,
  body.bb-nav-open #bbMobileNav {
    /* Override any body restrictions - menu container must be scrollable */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    /* Ensure it's scrollable and takes full viewport height */
    pointer-events: auto !important;
    max-height: calc(100dvh - 64px) !important;
    height: calc(100dvh - 64px) !important;
  }
  
  .bb-sidebar.open,
  #bb-nav.open .bb-sidebar,
  #bb-nav.is-open .bb-sidebar,
  #bb-nav[data-state="open"] .bb-sidebar,
  body.sidebar-open #bb-nav .bb-sidebar,
  body.bb-nav-open #bb-nav .bb-sidebar {
    transform: translateX(0) !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: #ffffff !important;
    /* Ensure no nested scroll */
    overflow: visible !important;
  }
  
  /* Ensure no nested scrolling in nav links container */
  #bb-nav .bb-sidebar > *,
  #bbMobileNav .bb-sidebar > * {
    overflow: visible !important;
  }
  .bb-mobile-toggle,
  #bb-mobile-toggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  /* Legacy - hidden */
  .bb-mobile-toggle {
    position: fixed;
    top: 18px;
    left: 18px;
    background: #ffffff;
    border-radius: 8px;
    padding: 8px;
    width: 38px;
    height: 38px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
    z-index: 10000;
    cursor: pointer;
  }
}

/* Scrollbar cleanup */
.bb-sidebar::-webkit-scrollbar {
  width: 6px;
}

.bb-sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 10px;
}

/* === HEADER POLISH === */
.bb-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  background: var(--surface-header, #faf7f5);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 900;
}

/* Title injected by JS - CHUNK 160: Standardized to match Mocktail Builder */
.bb-header-title {
  font-size: var(--font-size-xl, 1.25rem);
  font-weight: var(--weight-semibold, 600);
  margin-left: var(--space-md);
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
  flex: 1;
  font-family: var(--font-ui, 'Inter', system-ui, sans-serif);
  line-height: 1.2;
  display: flex;
  align-items: center;
  vertical-align: middle;
  text-transform: none; /* Ensure no case transformation */
}

/* MOBILE NAV IMPROVEMENTS */
.bb-sidebar {
  transition: transform 0.28s ease;
}

.bb-sidebar.open {
  transform: translateX(0);
}

/* Body scroll lock when nav is open - handled by .bb-nav-open class */
body.bb-nav-open {
  overflow: hidden !important;
  /* Don't use position: fixed as it prevents menu scrolling on mobile */
  /* position: fixed !important; */
  /* Prevent iOS scroll bounce */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  /* touch-action: none; - removed to allow menu scrolling */
}

/* Legacy support */
body.nav-open {
  overflow: hidden;
}

/* Keyboard Navigation (A11y) */
body.keyboard-nav .bb-nav-link:focus {
  outline: 2px solid var(--theme-accent, #d4a373);
  outline-offset: 2px;
}
