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

   BoozeButler / Halytic Design System v1.0

   COMPONENT SYSTEM — Buttons, Inputs, Cards, Lists, Tabs, Tags

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



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

   COMPONENTS — FORMS, BUTTONS, CARDS
   Phase C Consolidation (Chunk 120)
   Phase 121 — Functional Card System (Option C)
   Builder, Home Hub, Inventory IQ

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

/* ---------------------------------------------
   BUILDER HEADERS (Round / Make / Mocktail / SFS)
   From ui-chunk113-polish + ui-home-page-fix-final
   --------------------------------------------- */
.make-header,
.builder-header,
.round-builder-header,
.mocktail-builder-header,
.start-from-scratch-header,
.page-header {
  margin-bottom: var(--bb-space-xl);
}

.make-header h2,
.builder-header h2,
.round-builder-header h2,
.mocktail-builder-header h2,
.start-from-scratch-header h2,
.page-header h2 {
  font-size: var(--bb-h2-size);
  font-weight: 600;
  margin-bottom: var(--bb-space-sm);
}

.make-header p,
.builder-header p,
.round-builder-header p,
.mocktail-builder-header p,
.page-header p {
  font-size: var(--bb-body-size);
  opacity: 0.7;
  line-height: 1.6;
}

/* ---------------------------------------------
   BUILDER FORM SECTIONS
   --------------------------------------------- */
.builder-section,
.make-panel,
.section {
  margin-bottom: var(--bb-space-xl);
}

.make-form__section,
.round-builder-form__section,
.mocktail-builder-form__section,
.start-from-scratch-form__section {
  margin: var(--bb-space-lg) 0;
  padding: var(--bb-space-lg) 0;
}

/* ---------------------------------------------
   "NO INVENTORY" MESSAGE
   --------------------------------------------- */
.no-inventory-message {
  padding: var(--bb-space-lg);
  background: var(--bb-cream);
  border-radius: 12px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--bb-deep);
  opacity: 0.8;
  margin: var(--bb-space-lg) 0;
}
.no-inventory-message::before {
  content: "📋 ";
  margin-right: 8px;
}

/* ---------------------------------------------
   HOME HUB CARDS
   --------------------------------------------- */
.home-hub-card {
  transform: scale(0.8);
  transform-origin: center;
  width: calc(100% / 0.8);
  max-width: calc(400px / 0.8);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1),
              0 4px 16px rgba(0,0,0,0.08);
  transition: 0.2s ease;
}

.home-hub-card:hover {
  transform: scale(0.82);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15),
              0 8px 24px rgba(0,0,0,0.1);
}

.home-hub-section {
  margin-bottom: var(--bb-section-spacing);
}

.home-hub-section h1,
.home-hub-section h2 {
  font-family: 'Playfair Display', serif;
  margin-bottom: var(--bb-internal-spacing);
}

/* ---------------------------------------------
   INVENTORY CATEGORY HEADERS
   --------------------------------------------- */
.inventory-category-header,
.inventory-section-header {
  text-transform: uppercase;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 2px solid var(--bb-gold);
  padding-bottom: var(--bb-space-sm);
  margin: var(--bb-space-lg) 0 var(--bb-space-md);
  letter-spacing: 0.05em;
}

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

   1. BUTTONS — Primary, Secondary, Tertiary

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

/* ---------------------------------------------

   BUTTON SYSTEM — primary / secondary / tertiary

   --------------------------------------------- */

.bb-button {

  padding: var(--bb-space-md) var(--bb-space-xl);

  border-radius: 8px;

  font-weight: 600;

  font-size: var(--bb-body-size);

  display: inline-flex;

  align-items: center;

  justify-content: center;

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

  cursor: pointer;

  transition: 0.15s ease;

  border: none;

}

.bb-button--primary {

  background: var(--bb-gold);

  color: var(--bb-white);

}

.bb-button--primary:hover:not(:disabled) {

  background: #A68A4F;

}

/* Chunk 120 Phase 3A — Consolidated button text contrast rules
   Migrated from card-contrast-fixes.css.
   Ensures all primary/accent buttons use readable text color in all themes. */
.btn--primary,
.btn--accent,
.bb-button--primary,
.bb-button--accent {
  color: var(--bb-white);
}

.bb-button--secondary {

  background: transparent;

  color: var(--bb-gold);

  border: 1px solid var(--bb-gold);

}

.bb-button--secondary:hover:not(:disabled) {

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

}

.bb-button--tertiary {

  background: transparent;

  color: var(--bb-deep);

  padding: var(--bb-space-sm) var(--bb-space-md);

}

.bb-button--tertiary:hover:not(:disabled) {

  background: rgba(0,0,0,0.05);

}

.bb-button:disabled {

  opacity: 0.5;

  cursor: not-allowed;

}

/* Note: Button system now unified in Phase B .bb-button system above */

/* Icon buttons */

.bb-icon-btn {

  width: 36px;

  height: 36px;

  border-radius: var(--radius-button);

  display: inline-flex;

  align-items: center;

  justify-content: center;

  background: var(--bg-surface);

  border: 1px solid var(--border-subtle);

}

.bb-icon-btn:hover {

  background: var(--accent-light);

  border-color: var(--accent);

}



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

   2. INPUTS

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

/* ---------------------------------------------

   INPUTS — unified 44px standard height

   --------------------------------------------- */

input[type="text"],

input[type="email"],

input[type="number"],

input[type="search"],

select,

textarea,

.bb-select,

.make-form__input,

.round-builder-form__input,

.mocktail-builder-form__input,

.start-from-scratch-form__input {

  min-height: 44px;

  padding: var(--bb-space-sm) var(--bb-space-md);

  font-size: var(--bb-body-size);

  width: 100%;

  border-radius: 8px;

  border: 1px solid rgba(0, 0, 0, 0.12);

  box-sizing: border-box;

}

textarea {

  min-height: 100px;

  resize: vertical;

}

label {

  font-size: 0.875rem;

  font-weight: 600;

  color: var(--bb-deep);

  margin-bottom: 8px;

  display: block;

}

/* Note: Input styles now unified in Phase B unified inputs section above */

/* Focus states for inputs (complement Phase B unified inputs) */

input:focus,

textarea:focus,

select:focus {

  border-color: var(--accent);

  box-shadow: 0 0 0 2px var(--accent-light);

  outline: none;

}



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

   3. CARDS

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

/* ---------------------------------------------

   CARDS — unified card system

   --------------------------------------------- */

/* Base Card */

.bb-card,

.card,

.card-md,

.analytics-card,

.intelligence-card,

.iq-block,

.inventory-intelligence-block {

  background: var(--bb-white);

  border-radius: var(--bb-radius-card);

  padding: var(--bb-space-lg);

  box-shadow: var(--bb-shadow-card);

  border: 1px solid rgba(0, 0, 0, 0.08);

  transition: box-shadow 0.2s ease;

}

.bb-card:hover,

.card-md:hover,

.analytics-card:hover,

.intelligence-card:hover {

  box-shadow: var(--bb-shadow-card-hover);

}

/* Title inside cards - use DS12 tokens */

.card-title,

.analytics-card .card-title,

.intelligence-card .card-title,

.iq-block h3,

.bb-card-title {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  margin-bottom: var(--bb-internal-spacing);

  color: var(--bb-deep);

}

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

   CARD VARIANT — DATA

   Structured information, lists, tables

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

.bb-card--data {

  padding: var(--bb-space-lg);

  display: flex;

  flex-direction: column;

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

}

.bb-card--data .bb-list,

.bb-card--data ul {

  margin: 0;

  padding: 0;

  list-style: none;

}

/* Card typography - Data cards */

.bb-card--data .bb-card-title,

.bb-card--data h3,

.history-card .bb-card-title,

.history-card h3 {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  color: var(--bb-deep);

}

.bb-card--data p,

.bb-card--data .bb-text-md,

.history-card p {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}

.bb-card--data .bb-text-sm,

.history-card .bb-text-sm {

  font-size: var(--font-size-sm);

  line-height: var(--line-height-base);

}



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

   CARD VARIANT — METRIC

   Analytics, KPIs, Stats

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

.bb-card--metric {

  text-align: center;

  padding: var(--bb-space-xl);

  border-radius: var(--bb-radius-card-lg);

}

.bb-card--metric .metric-value {

  font-size: 32px;

  font-weight: var(--font-weight-bold);

  color: var(--bb-deep);

  margin-bottom: var(--bb-space-sm);

  line-height: var(--line-height-tight);

}

.bb-card--metric .metric-label {

  opacity: 0.7;

  font-size: var(--font-size-sm);

  line-height: var(--line-height-base);

}

/* Card typography - Metric cards */

.bb-card--metric .bb-card-title,

.bb-card--metric h3,

.analytics-card .bb-card-title,

.analytics-card h3 {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  color: var(--bb-deep);

}

.bb-card--metric p,

.analytics-card p {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}



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

   CARD VARIANT — INTERACTIVE

   Clickable cards (home hub, builder tiles)

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

.bb-card--interactive {

  cursor: pointer;

  transition: transform 0.2s ease, box-shadow 0.2s ease;

}

.bb-card--interactive:hover {

  transform: translateY(-2px);

  box-shadow: var(--bb-shadow-card-hover);

}

/* Card typography - Interactive cards */

.bb-card--interactive .bb-card-title,

.bb-card--interactive h3,

.favorite-card .bb-card-title,

.favorite-card h3 {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  color: var(--bb-deep);

}

.bb-card--interactive p,

.favorite-card p {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}



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

   CARD VARIANT — FORM

   Forms, wizards, grouped input areas

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

.bb-card--form {

  padding: var(--bb-space-xl) var(--bb-space-lg);

  display: flex;

  flex-direction: column;

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

}

.bb-card--form h3,

.bb-card--form .bb-card-title {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  margin-bottom: var(--bb-space-md);

  color: var(--bb-deep);

}

/* Card typography - Form cards */

.bb-card--form p,

.bb-card--form label {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}

.bb-card--form .bb-text-sm {

  font-size: var(--font-size-sm);

  line-height: var(--line-height-base);

}

/* CHUNK 151: Ensure readable text colors in form cards */
.bb-card--form .bb-page-subtitle,
.bb-card--form .bb-page-helper,
.bb-card--form .bb-text-muted,
.bb-card--form p.bb-text-muted {
  color: var(--bb-deep, #0F1118) !important; /* Dark text for readability on light card backgrounds */
  opacity: 1 !important; /* Remove opacity that might make text too light */
}

/* CHUNK 151: Ensure all paragraph text in form cards is readable */
.bb-card--form p {
  color: var(--bb-deep, #0F1118) !important; /* Override any light text colors */
}

/* CHUNK 151: Mocktail builder specific - ensure subtitle is readable */
.mocktail-builder-card .bb-page-subtitle,
.mocktail-builder-card p.bb-page-subtitle {
  color: var(--bb-deep, #0F1118) !important;
  opacity: 1 !important;
}

/* === Header Brand Wordmark + Title (Prevent Text Wrapping) === */
.bb-header-logo__text {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
  white-space: nowrap;
}

.bb-header-logo__text .bb-header-title {
  white-space: nowrap;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Mobile: Allow title to shrink more on small screens */
@media (max-width: 959px) {
  .bb-header-logo__text {
    min-width: 0; /* Allow flex items to shrink below content size */
    flex: 1 1 auto; /* Allow text to grow/shrink */
    overflow: hidden; /* Enable ellipsis for overflow */
  }
  
  .bb-header-logo__text .bb-header-title {
    overflow: visible !important; /* Don't truncate - show full text */
    text-overflow: clip !important; /* Use clip instead of ellipsis */
    white-space: nowrap;
    max-width: none !important; /* Remove max-width constraint */
    min-width: 0;
    font-size: 0.8rem; /* Slightly smaller but readable */
    flex: 0 1 auto; /* Allow shrinking but don't force it */
    /* Ensure title is visible even if it means hiding brand wordmark */
  }
  
  .bb-header-brand {
    flex-shrink: 1;
    min-width: auto;
  }
  
  /* Show brand wordmark on mobile with responsive styling - but allow it to be hidden if needed */
  .bb-brand-wordmark {
    display: inline !important;
    font-size: 0.65rem; /* Smaller to save space */
    max-width: 60px; /* Further reduced to give more room */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
  }
  
  /* If title is long, hide brand wordmark to make room */
  .bb-header-logo__text:has(.bb-header-title[data-long="true"]) .bb-brand-wordmark {
    display: none !important;
  }
  
  .bb-page-title-sep {
    display: inline;
    font-size: 0.6rem; /* Smaller separator */
    margin: 0 2px;
    flex-shrink: 0;
  }
  
  /* Ensure header container allows overflow for long titles */
  .bb-header-logo {
    min-width: 0 !important;
    overflow: visible !important; /* Allow title to overflow if needed */
  }
  
  .bb-header-left {
    min-width: 0 !important;
    overflow: visible !important;
    flex: 1 1 auto !important;
  }
  
  /* Ensure header logo container doesn't hide content */
  .bb-header-logo {
    display: flex !important;
    align-items: center;
    gap: 6px; /* Tighter gap on mobile */
    min-width: 0; /* Allow shrinking */
    flex: 1 1 auto;
    overflow: visible !important; /* Show all content - let children handle ellipsis */
    width: auto !important; /* Don't force width */
    max-width: 100% !important; /* But respect container */
  }
  
  /* Force brand wordmark to be visible */
  .bb-brand-wordmark {
    display: inline-block !important; /* Use block to ensure visibility */
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 90px !important; /* Limit width but allow visibility */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Force page title separator to be visible */
  .bb-page-title-sep {
    display: inline !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    flex-shrink: 0 !important;
  }
  
  /* Force page title to be visible */
  .bb-header-title {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 150px !important; /* Allow some width for title */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Ensure brand container is visible */
  .bb-header-brand {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important; /* Don't shrink brand */
    min-width: auto !important;
  }
  
  /* Ensure logo text container is visible */
  .bb-header-logo__text {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: visible !important; /* Show content */
  }
  
  /* Ensure header left container allows content to show */
  .bb-header-left {
    overflow: visible !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
}

/* Clickable brand link (logo + wordmark) */
.bb-header-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.bb-header-brand:hover {
  opacity: 0.8;
}

.bb-header-brand:focus {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
  border-radius: 4px;
}

.bb-brand-wordmark {
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 600;
  color: var(--bb-muted, #6b7280);
  letter-spacing: 0.2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.bb-page-title-sep {
  font-size: var(--font-size-sm, 0.875rem);
  color: var(--bb-muted, #6b7280);
  margin: 0 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===============================================================
   Mobile Menu Button & Navigation Drawer
   =============================================================== */

/* ===============================================================
   Mobile Nav Scroll Lock + Drawer Scrolling (Chunk 160)
   - Single scroll container: #bb-nav / #bbMobileNav
   - Avoid body position:fixed (breaks iOS drawer scrolling)
   =============================================================== */

/* Mobile Menu Button */
.bb-mobile-menu-btn {
  display: none; /* Hidden on desktop */
  background: transparent !important;
  border: 0 !important;
  padding: 8px !important;
  margin-right: 12px !important;
  cursor: pointer;
  color: var(--bb-deep, #2d2926) !important;
  min-width: 44px !important;
  min-height: 44px !important;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.bb-mobile-menu-btn svg {
  display: block;
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.bb-mobile-menu-btn:hover {
  background-color: rgba(191, 160, 90, 0.1) !important;
}

.bb-mobile-menu-btn:active,
.bb-mobile-menu-btn[aria-expanded="true"] {
  background-color: var(--bb-gold, #BFA05A) !important;
  color: var(--bb-white, #ffffff) !important;
}

/* Hide the old duplicate mobile toggle button */
.bb-mobile-toggle,
#bb-mobile-toggle {
  display: none !important;
  visibility: hidden !important;
}

.bb-mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Show button on mobile */
@media (max-width: 959px) {
  .bb-mobile-menu-btn {
    display: flex;
  }
}

/* Mobile Navigation Overlay */
.bb-mobile-nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 950; /* Above content (900) but below drawer (1000) */
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  /* Prevent overlay from scrolling */
  overflow: hidden;
  touch-action: none;
}

.bb-mobile-nav-overlay:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Navigation Drawer */
@media (max-width: 959px) {
  /* Ensure the DRAWER container is the single scroll container on mobile */
  body.bb-nav-open #bb-nav,
  body.bb-nav-open #bbMobileNav,
  body.sidebar-open #bb-nav,
  body.sidebar-open #bbMobileNav {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
  }

  /* Prevent background page scroll when nav is open (iOS-safe: DO NOT position:fixed body) */
  html.bb-nav-open,
  body.bb-nav-open {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  /* Body offset is applied via JS to preserve scroll position while overflow is locked */
  body.bb-nav-open {
    position: relative !important;
    width: 100% !important;
  }
  
  /* CRITICAL: Ensure drawer can scroll independently when body is locked */
  /* The drawer must be able to scroll even when body has restrictions */
  body.bb-nav-open #bb-nav,
  body.bb-nav-open #bbMobileNav {
    /* Override body restrictions - drawer needs to scroll */
    touch-action: pan-y !important; /* Allow vertical scrolling */
    -webkit-overflow-scrolling: touch !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    /* Ensure drawer is positioned correctly and scrollable */
    position: fixed !important;
    top: 64px !important;
    bottom: 0 !important;
    left: 0 !important;
    /* Fill available viewport space under header */
    height: calc(100dvh - 64px) !important;
    max-height: calc(100dvh - 64px) !important;
    width: 280px !important;
    max-width: 85vw !important;
  }
  
  /* CRITICAL: Ensure sidebar inside drawer can scroll */
  body.bb-nav-open #bb-nav .bb-sidebar,
  body.bb-nav-open #bbMobileNav .bb-sidebar {
    /* Sidebar should not block touch scrolling */
    touch-action: pan-y !important;
    height: auto !important;
    max-height: none !important;
    /* But ensure it's visible */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* CRITICAL: Remove any position constraints that might prevent parent scrolling */
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
  }
  
  #bb-nav,
  #bbMobileNav {
    position: fixed !important;
    top: 64px !important; /* Start below header (header height is typically 64px) */
    bottom: 0 !important; /* Fill to bottom */
    left: 0 !important;
    height: auto !important; /* Override 100vh - use top/bottom instead */
    width: 280px !important;
    max-width: 85vw !important;
    z-index: 1000 !important; /* Below overlay (900) but above content */
    transform: translateX(-100%) translateZ(0) !important; /* Add translateZ for hardware acceleration */
    -webkit-transform: translateX(-100%) translateZ(0) !important;
    transition: transform 0.3s ease !important;
    background-color: var(--bb-white, #ffffff) !important;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15) !important;
    overflow-y: auto !important; /* Enable scrolling on drawer */
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
    overscroll-behavior: contain !important; /* Prevent scroll chaining */
    visibility: visible !important;
    opacity: 1 !important;
    /* CRITICAL: Allow vertical scrolling in drawer even when body is fixed */
    touch-action: pan-y !important;
    /* Ensure drawer is scrollable */
    will-change: scroll-position;
    /* Force hardware acceleration for smooth scrolling */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* CRITICAL: Ensure drawer can receive touch events even when body is fixed */
    pointer-events: auto !important;
    /* Force scroll container to be active */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* Remove nested scroll - only the drawer container should scroll */
  #bb-nav .bb-sidebar,
  #bbMobileNav .bb-sidebar {
    overflow: visible !important; /* Let parent handle scrolling */
    height: auto !important;
    max-height: none !important;
    /* Ensure sidebar doesn't prevent parent scroll */
    /*
      CRITICAL:
      touch-action:none blocks scrolling on iOS/Android.
      We allow vertical panning so the drawer can scroll naturally.
    */
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Fix modal scrolling - ensure modals can scroll independently */
  .modal,
  .bb-modal,
  [class*="modal"],
  .modal-dialog,
  .modal-content {
    /* When modal is open, allow it to scroll even if body is fixed */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    max-height: 90vh !important;
    /* Ensure modal scrolls independently */
    overscroll-behavior: contain !important;
  }
  
  /* Prevent body scroll when modal is open, but allow modal to scroll */
  body.modal-open,
  body:has(.modal.show),
  body:has(.bb-modal.show) {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
  }
  
  /* But allow modal itself to scroll */
  body.modal-open .modal,
  body.modal-open .bb-modal,
  body:has(.modal.show) .modal,
  body:has(.bb-modal.show) .bb-modal {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
  }

  #bb-nav.is-open,
  #bbMobileNav.is-open,
  #bb-nav.open,
  #bbMobileNav.open,
  #bb-nav[data-state="open"],
  #bbMobileNav[data-state="open"],
  body.sidebar-open #bb-nav,
  body.bb-nav-open #bb-nav,
  body.bb-nav-open #bbMobileNav {
    transform: translateX(0) translateZ(0) !important; /* Keep translateZ when open */
    -webkit-transform: translateX(0) translateZ(0) !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    /* Maintain hardware acceleration */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  
  /* Override any conflicting display rules from ui-layouts.css */
  body.sidebar-open #bb-nav,
  #bb-nav.is-open,
  #bb-nav.open,
  #bb-nav[data-state="open"] {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Ensure navigation sidebar is visible and positioned correctly when drawer is open */
  #bb-nav.is-open .bb-sidebar,
  #bb-nav.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,
  #bb-nav .bb-sidebar.open {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    left: 0 !important;
    transform: translateX(0) !important;
    background-color: #ffffff !important;
    z-index: 1001 !important;
    /* Ensure sidebar never blocks scrolling */
    touch-action: pan-y !important;
  }
  

  #bb-nav.is-open .bb-nav-link,
  #bb-nav.open .bb-nav-link,
  #bb-nav[data-state="open"] .bb-nav-link,
  body.sidebar-open #bb-nav .bb-nav-link,
  #bb-nav .bb-sidebar.open .bb-nav-link {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #333 !important;
  }

  #bb-nav.is-open .bb-nav-section-title,
  #bb-nav.open .bb-nav-section-title,
  #bb-nav[data-state="open"] .bb-nav-section-title,
  body.sidebar-open #bb-nav .bb-nav-section-title,
  #bb-nav .bb-sidebar.open .bb-nav-section-title {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: #666 !important;
  }

  /* Ensure icons are visible */
  #bb-nav.is-open .bb-nav-link .icon,
  #bb-nav.open .bb-nav-link .icon,
  #bb-nav[data-state="open"] .bb-nav-link .icon,
  body.sidebar-open #bb-nav .bb-nav-link .icon,
  #bb-nav .bb-sidebar.open .bb-nav-link .icon {
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Ensure header z-index is lower when menu is open */
  .bb-header {
    z-index: 998;
  }

  /* When menu is open, header should be below overlay */
  body:has(#bb-nav.is-open) .bb-header,
  body:has(#bbMobileNav.is-open) .bb-header {
    z-index: 998;
  }
}

/* Card typography - Feature cards */

.bb-card--feature .bb-card-title,

.bb-card--feature h3,

.subscription-plan-card .bb-card-title,

.subscription-plan-card h3 {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  color: var(--bb-deep);

}

.bb-card--feature p,

.subscription-plan-card p {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}

/* Card typography - Result cards */

.bb-card--result .bb-card-title,

.bb-card--result h3,

.result-card .bb-card-title,

.result-card h3,

.recipe.card .bb-card-title,

.recipe.card h3 {

  font-size: var(--font-size-xl);

  font-weight: var(--font-weight-semibold);

  line-height: var(--line-height-normal);

  color: var(--bb-deep);

}

.bb-card--result p,

.result-card p,

.recipe.card p {

  font-size: var(--font-size-md);

  line-height: var(--line-height-relaxed);

  color: var(--bb-deep);

}

.bb-card--result .bb-text-sm,

.result-card .bb-text-sm,

.recipe.card .bb-text-sm {

  font-size: var(--font-size-sm);

  line-height: var(--line-height-base);

}



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

   LEGACY CLASS BACKWARD COMPATIBILITY

   (Ensures no breakage during migration)

   Legacy classes (.card-md, .analytics-card, etc.) are already

   included in the base .bb-card selector above, so they inherit

   all base card styles automatically.

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

.bb-card,

.card {

  background: var(--bg-surface);

  border-radius: var(--radius-card);

  box-shadow: var(--shadow-sm);

  padding: var(--space-lg);

  margin-bottom: var(--space-lg);

}



.bb-card h2,

.bb-card h3 {

  margin-top: 0;

}



/* Flat Card (no shadow) */

.bb-card-flat {

  background: var(--bg-surface);

  border-radius: var(--radius-card);

  border: 1px solid var(--border-subtle);

  padding: var(--space-lg);

}



/* Elevated Card */

.bb-card-elevated {

  background: var(--bg-surface);

  border-radius: var(--radius-card);

  box-shadow: var(--shadow-md);

  padding: var(--space-xl);

}



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

   4. TABS

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



.bb-tabs {

  display: flex;

  gap: var(--space-md);

  border-bottom: 1px solid var(--border-subtle);

  margin-bottom: var(--space-lg);

}



.bb-tab {

  padding: var(--space-sm) var(--space-md);

  cursor: pointer;

  border-radius: var(--radius-button);

  color: var(--text-muted);

  transition: var(--transition-fast);

}



.bb-tab:hover {

  background: var(--accent-light);

  color: var(--accent);

}



.bb-tab-active {

  background: var(--accent-light);

  color: var(--accent);

  font-weight: 600;

}



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

   5. TAGS / BADGES

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



.bb-tag {

  display: inline-flex;

  align-items: center;

  padding: 2px 8px;

  border-radius: var(--radius-tag);

  font-size: var(--text-sm);

  background: var(--bg-subtle);

  border: 1px solid var(--border-subtle);

  color: var(--text-default);

}



.bb-tag-accent {

  background: var(--accent-light);

  border-color: var(--accent);

  color: var(--accent);

}



.bb-tag-pro {

  background: var(--accent);

  color: var(--text-inverse);

  border-radius: var(--radius-tag);

  font-weight: 600;

}



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

   6. DROPDOWNS

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



.bb-dropdown {

  position: relative;

  display: inline-block;

}



.bb-dropdown-menu {

  position: absolute;

  right: 0;

  top: 100%;

  margin-top: var(--space-xs);

  min-width: 200px;

  background: var(--bg-surface);

  border: 1px solid var(--border-subtle);

  border-radius: var(--radius-card);

  box-shadow: var(--shadow-md);

  padding: var(--space-xs) 0;

  z-index: var(--z-dropdown);

  display: none;

}



.bb-dropdown.open .bb-dropdown-menu {

  display: block;

}



.bb-dropdown-item {

  padding: var(--space-sm) var(--space-md);

  cursor: pointer;

  transition: var(--transition-fast);

}



.bb-dropdown-item:hover {

  background: var(--accent-light);

}



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

   7. EMPTY STATES

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



.bb-empty {

  text-align: center;

  padding: var(--space-xl) var(--space-lg);

  color: var(--text-muted);

}



.bb-empty h2 {

  color: var(--text-default);

}



.bb-empty-icon {

  font-size: 40px;

  opacity: 0.3;

  margin-bottom: var(--space-sm);

}



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

   8. LOADERS

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



.bb-spinner {

  width: 28px;

  height: 28px;

  border: 3px solid var(--border-subtle);

  border-top-color: var(--accent);

  border-radius: 50%;

  animation: spin 0.8s linear infinite;

}



@keyframes spin {

  to { transform: rotate(360deg); }

}



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

   9. TOASTS

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



.bb-toast {

  position: fixed;

  bottom: var(--space-xl);

  right: var(--space-xl);

  background: var(--bg-surface);

  border-radius: var(--radius-card);

  padding: var(--space-lg);

  box-shadow: var(--shadow-lg);

  font-size: var(--text-md);

  z-index: var(--z-toast);

  display: none;

}



.bb-toast.show {

  display: block;

}



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

   END COMPONENT SYSTEM

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



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

   CARD COMPONENT — CANONICAL DESIGN SYSTEM DEFINITION

   Added in Chunk 120 Phase 1 (fixes "Cards not found" validator error)

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



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

   CARD COMPONENT — TYPOGRAPHY ALIGNMENT

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

.bb-card,

.ds-card,

.component-card {

  display: block;

  background: var(--surface-card, var(--bg-surface, #ffffff));

  border-radius: var(--radius-md, var(--radius-card, 12px));

  padding: var(--space-lg, 24px);

  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.08));

  color: var(--text-primary, var(--text-default, #111));

  box-sizing: border-box;

  margin-bottom: var(--space-md, 16px);

  font-size: var(--font-size-md);

  line-height: var(--line-height-normal);

}



/* Header inside cards */

.bb-card h3,

.component-card h3,

.ds-card h3 {

  font-size: var(--font-size-lg);

  font-weight: var(--weight-semibold);

  margin-bottom: var(--space-sm, 8px);

  color: var(--text-primary, var(--text-default, #111));

}



/* Body text */

.bb-card p,

.component-card p,

.ds-card p {

  font-size: var(--font-size-sm);

  line-height: var(--line-height-normal);

  margin: 0 0 var(--space-sm);

  color: var(--text-secondary, var(--text-muted, #444));

}



/* Optional card sections */

.bb-card .section,

.component-card .section,

.ds-card .section {

  margin-top: var(--space-md, 16px);

}



/* Deprecated aliases — safe for removal in Step 8 */
/* Note: .card styles now consolidated in Phase B unified card system above */

/* ---------------------------------------------
   BUILDER WARNING BLOCK (Round / Make / SFS / AI Bartender)
   Single-line friendly messages at top of results; no internal jargon.
   --------------------------------------------- */
.builder-warning-block {
  margin-bottom: var(--space-md, 1rem);
  padding: var(--space-sm, 0.75rem) var(--space-md, 1rem);
  background: var(--bb-warning-bg, rgba(255, 193, 7, 0.1));
  border-left: 3px solid var(--bb-warning-border, #ffc107);
  border-radius: var(--radius-sm, 4px);
  font-size: var(--type-body-size, 1rem);
}
.builder-warning-block__inner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs, 0.5rem);
}
.builder-warning-block__icon {
  color: var(--bb-warning-border, #ffc107);
  font-size: 1.1em;
  flex-shrink: 0;
}
.builder-warning-block__list {
  margin: 0;
  padding-left: 1.25rem;
  list-style: disc;
}
.builder-warning-block__item {
  color: var(--bb-warning-text, #856404);
  margin-bottom: 0.25em;
}
.builder-warning-block__item:last-child {
  margin-bottom: 0;
}