/**
 * Bundle Builder - Consolidated CSS (CLEANED)
 * Version: 2.0 - Deduplicated, conflicts resolved
 */

/* ========================================
   CSS CUSTOM PROPERTIES (GLOBALS)
   ======================================== */

:root {
  /* Colors - mapped to framework variables */
  --bb-primary: var(--at-primary, #059669);
  --bb-primary-light: var(--at-primary-l-5, #ecfdf5);
  --bb-primary-lighter: var(--at-primary-l-4, rgba(5, 150, 105, 0.1));
  --bb-success: var(--at-success, #059669);
  --bb-danger: var(--at-danger, #dc2626);
  --bb-border: var(--at-border, #e5e7eb);

  /* Neutrals */
  --bb-gray-50: #f9fafb;
  --bb-gray-100: #f3f4f6;
  --bb-gray-200: #e5e7eb;
  --bb-gray-300: #d1d5db;
  --bb-gray-700: #374151;
  --bb-gray-800: #1f2937;
  --bb-gray-900: #111827;

  /* Spacing */
  --bb-space-xs: 4px;
  --bb-space-s: 8px;
  --bb-space-m: 16px;
  --bb-space-l: 24px;

  /* Border radius */
  --bb-radius-s: 8px;
  --bb-radius-m: 12px;
  --bb-radius-l: 16px;

}

/* ========================================
   SUBSCRIPTION SELECTOR
   ======================================== */

/* Universal visibility transition for all BB elements */
[data-bb-subscription-container],
[data-bb-subscription-schemes] {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.5s ease-out;
}

/* Universal hidden state with smooth transition */
.bb-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  max-height: 0 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
  margin-inline: 0 !important;
  padding-inline: 0 !important;
  overflow: hidden !important;
  transition: opacity 0.85s ease-out, max-height 0.85s ease-out, margin 0.85s ease-out, padding 0.85s ease-out !important;
}

/* Scheme selector - only hide on frontend */
body:not(.brx-body) [data-bb-subscription-schemes][data-scheme-count="0"],
body:not(.brx-body) [data-bb-subscription-schemes][data-scheme-count="1"] {
  display: none !important;
}

/* Mobile expandable container - smooth transition (controlled via JS) */
@media (max-width: 768px) {
  .bb-summary {
    transition: max-height 0.4s ease-out;
    position: relative;
  }

  /* Expanded state when on step 2 */
  .bb-summary.bb-expanded {
    height: 85vh;
    max-height: 85vh;
    overflow-y: auto;
  }

  /* Close/collapse button */
  .bb-collapse-btn {
    position: absolute;
    top: var(--bb-space-m);
    right: var(--bb-space-m);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bb-gray-100);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-s);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
  }

  .bb-collapse-btn:hover {
    background: var(--bb-gray-200);
    transform: translateY(2px);
  }

  .bb-collapse-btn svg {
    color: var(--bb-gray-700);
    transition: transform 0.3s ease;
    transform: rotate(0deg); /* Chevron up when collapsed (vergroot) */
  }

  /* Rotate chevron when expanded */
  .bb-summary.bb-expanded .bb-collapse-btn svg {
    transform: rotate(180deg); /* Chevron down when expanded (verklein) */
  }
}

/* ========================================
   SUBSCRIPTION TYPE SELECTOR - CHECKMARK CONTROL
   ======================================== */

/* Hide checkmark for toggle switches (only show for tabs) */
.bb-pricing__switch [data-bb-subscription-type].selected::before,
.bb-pricing__switch-text[data-bb-subscription-type].selected::before {
  display: none !important;
}

/* Show checkmark ONLY in tab-menu context (Bricks Tabs) */
.tab-menu [data-bb-subscription-type].selected::before {
  display: block !important;
}

/* ========================================
   MOBILE MULTI-STEP NAVIGATION
   ======================================== */

/* Step content visibility - class-based (preserves Bricks styling) */
.bb-step-hidden {
  display: none !important;
}

/* On desktop, always show all steps */
@media (min-width: 769px) {
  .bb-step-hidden {
    display: block !important;
  }
}

@media (max-width: 768px) {

  /* Step indicators */
  [data-bb-step-indicator] {
    cursor: pointer;
    transition: all 0.2s ease;
  }

  [data-bb-step-indicator].active {
    /* Active styling - override in Bricks with your own styles */
  }

  [data-bb-step-indicator]:not(.active) {
    /* Inactive styling - override in Bricks with your own styles */
  }

  [data-bb-step-indicator][aria-disabled="true"],
  [data-bb-step-indicator].disabled {
    cursor: not-allowed;
    pointer-events: none;
    background-color: transparent !important;
  }

  /* Compact spacing */
  [data-bb-subscription-type] {
    padding: 14px 16px;
  }

  /* Selected checkmark - ONLY for tab-menu context (not toggle switches) */
  .tab-menu [data-bb-subscription-type].selected::before {
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
}

/* ========================================
   QUANTITY BADGES
   ======================================== */

article,
li {
  position: relative;
  overflow: visible;
}

/* Shared badge styles */
.bb-qty-badge,
[data-bb-qty-badge] {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, var(--at-secondary-l-1) 0%, var(--at-secondary) 100%);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px var(--at-secondary-l-4);
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: scale(0);
}

.bb-qty-badge--visible {
  opacity: 1;
  transform: scale(1);
}

@keyframes badge-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.bb-qty-badge--bounce {
  animation: badge-bounce 0.3s ease;
}


/* ========================================
   BUTTON STATE: QTY CONTROLS ACTIVE
   ======================================== */

[data-action="add-to-bundle"]:has(.bb-qty-controls) {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  transition: none !important;
}

[data-action="add-to-bundle"]:has(.bb-qty-controls) > *:not(.bb-qty-controls) {
  display: none !important;
}

[data-action="add-to-bundle"]:has(.bb-qty-controls):hover {
  transform: none !important;
  background: transparent !important;
}

/* ========================================
   QUANTITY CONTROLS
   ======================================== */

.bb-qty-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.bb-qty-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1.5px solid #d1d5db;
  border-radius: 50%;
  color: #374151;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.bb-qty-btn:hover {
  background: #f9fafb;
}

.bb-qty-btn.bb-qty-increase {
  border-color: var(--bb-primary);
  color: var(--bb-primary);
}

.bb-qty-btn.bb-qty-increase:hover {
  background: var(--bb-primary);
  color: white;
}

.bb-qty-btn.bb-qty-decrease {
  border-color: var(--bb-primary);
  color: var(--bb-primary);
}

.bb-qty-btn.bb-qty-decrease:hover {
  background: var(--bb-primary);
  color: white;
}

.bb-qty-display {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  color: #1f2937;
  font-size: 14px;
  line-height: 1;
  user-select: none;
}

/* ========================================
   TAB BUTTONS
   ======================================== */

/* Tab container with counter reset */
[data-bb-tab-container] {
  counter-reset: tab-counter;
  column-gap: 2rem;
  justify-content: flex-end;
}

/* Tab button base styles */
[data-bb-tab-button] {
  min-width: 40px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #e2e8f0;
  color: #64748b;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  counter-increment: tab-counter;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tab number via CSS counter */
[data-bb-tab-button]::before {
  content: counter(tab-counter);
}

[data-bb-tab-button]:hover {
  background: #cbd5e1;
  transform: translateY(-1px);
  border-color: #059669;
}

[data-bb-tab-button].active {
  background-color: var(--at-secondary);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  border-color: #059669 !important;
  opacity: 1 !important;
}

/* ========================================
   TAB PROGRESS VISUALIZATION
   ======================================== */

/* Progressive opacity based on fill percentage */
[data-bb-tab-button][data-fill-percentage="0"] {
  opacity: 0.4;
}

[data-bb-tab-button][data-fill-percentage="25"] {
  opacity: 0.55;
  background-color: rgba(5, 150, 105, 0.25);
}

[data-bb-tab-button][data-fill-percentage="50"] {
  opacity: 0.7;
  background-color: rgba(5, 150, 105, 0.5);
}

[data-bb-tab-button][data-fill-percentage="75"] {
  opacity: 0.85;
  background-color: rgba(5, 150, 105, 0.75);
}

/* Complete state - 50% GREEN (overschrijft .active background) */
[data-bb-tab-button][data-fill-percentage="100"],
[data-bb-tab-button].bb-box-complete,
[data-bb-tab-button].active[data-fill-percentage="100"],
[data-bb-tab-button].active.bb-box-complete {
  opacity: 1;
  background-color: rgba(5, 150, 105, 0.5) !important;
  color: white !important;
}

/* Progress bar (bottom border) */
[data-bb-tab-button]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #059669, #047857);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    border-radius: 0 0 8px 8px;
    padding: 4px 0;
    width: 100%;
}

[data-bb-tab-button][data-fill-percentage="25"]::after {
  transform: scaleX(0.25);
}

[data-bb-tab-button][data-fill-percentage="50"]::after {
  transform: scaleX(0.5);
}

[data-bb-tab-button][data-fill-percentage="75"]::after {
  transform: scaleX(0.75);
}

[data-bb-tab-button][data-fill-percentage="100"]::after {
  transform: scaleX(1);
}

/* Completion checkmark (JS-generated element) */
.bb-tab-checkmark {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #059669;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 10;
  animation: checkmarkPop 0.3s ease;
  pointer-events: none;
}

@keyframes checkmarkPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   SLOTS STYLING
   ======================================== */

/* Slots grid container */
[data-bb-slots-container] {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  padding: 1rem 0;
  width: 100%;
}

/* Slot numbering with CSS counters */
[data-bb-box] {
  counter-reset: slot-counter;
}

[data-bb-slot] {
  counter-increment: slot-counter;
  position: relative;
}

[data-bb-slot]::before {
  content: counter(slot-counter);
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2rem;
  font-weight: 700;
  color: var(--at-black-t-3);
  pointer-events: none;
  z-index: 0; /* Achter de img zodat img nummer bedekt */
}

/* ========================================
   PRODUCT NAME TOOLTIP
   ======================================== */

/* Tooltip for filled slots - shows product name on hover */
[data-bb-slot].bb-slot--filled[data-bb-product-name]::after {
  content: attr(data-bb-product-name);
  position: absolute;
  bottom: 92%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(17, 24, 39, 0.95);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Tooltip arrow */
[data-bb-slot].bb-slot--filled[data-bb-product-name]::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(17, 24, 39, 0.95);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
}

/* Show tooltip on hover */
[data-bb-slot].bb-slot--filled[data-bb-product-name]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-12px);
}

[data-bb-slot].bb-slot--filled[data-bb-product-name]:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Mobile: Position tooltip above with better spacing */
@media (max-width: 768px) {
  [data-bb-slot].bb-slot--filled[data-bb-product-name]::after {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* ========================================
   REMOVE BUTTON
   ======================================== */

.bb-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--at-danger);
  color: white;
  border: 2px solid #ffffff;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.bb-remove-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

[data-bb-slot].bb-slot--filled .bb-remove-btn {
  display: flex;
}

/* ========================================
   BOX CONTAINERS
   ======================================== */

[data-bb-box] {
  display: none;
  flex-direction: column;
  width: 100%;
}

[data-bb-box].bb-box--active {
  display: block !important;
}


/* REMOVED: Old .bb-add-to-cart (unused - uses data attributes)
   REMOVED: Old .bb-subscription-selector (unused - uses data attributes) */

/* ========================================
   BUTTON STATES
   ======================================== */

[data-bb-cart-button] {
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.disabled,
button.disabled {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
  pointer-events: none;
  background-color: #9ca3af !important;
}

.already-added,
button.already-added {
  opacity: 0.7 !important;
  cursor: not-allowed !important;
  pointer-events: none;
  background-color: #6b7280 !important;
  color: white !important;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.bb-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: 400px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  animation: toast-in 0.3s ease-out;
}

.bb-toast__message,
.bb-toast__content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
}

.bb-toast--success {
  background: var(--at-success); /* #10b981 */
  color: white;
}

.bb-toast--error {
  background: var(--at-danger); /* #ef4444; */
  color: white;
}

.bb-toast--warning {
  background: var(--at-warning); /* #f59e0b; */
  color: white;
}

.bb-toast--info {
  background: var(--at-info); /* #3b82f6 */
  color: white;
}

@keyframes toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========================================
   PRICING DISPLAY
   ======================================== */

.bb-price-old {
  text-decoration: line-through;
  opacity: 0.7;
  font-weight: 500;
  font-size: small;
  align-self: end;
}

.bb-price-new {
  font-weight: 700;
}

/* ========================================
   FLY ANIMATIONS
   ======================================== */

.bb-flying-element {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  [data-bb-slots-container] {
    gap: 1.25rem;
  }

  [data-bb-slot] {
    min-height: 60px;
  }

  [data-bb-tab-button] {
    width: 36px;
    height: 36px;
  }

  .bb-slot__fallback {
    font-size: 14px;
  }

  .bb-remove-btn {
    width: 18px;
    height: 18px;
  }

  .bb-toast {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .bb-qty-controls {
    gap: 6px;
    padding: 3px 6px;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.bb-loading {
  position: relative;
  pointer-events: none;
}

.bb-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

[data-bb-slot]:focus,
[data-bb-subscription-type]:focus,
[data-bb-scheme]:focus,
.bb-qty-btn:focus,
.bb-remove-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ========================================
   DEBUG STYLES
   ======================================== */

[data-bb-debug] .bb-slot {
  border: 2px solid red !important;
}


/* ========================================
   GLOBAL STYLES
   ======================================== */

* {
  box-sizing: border-box;
}

[data-bb-slot],
[data-bb-subscription-type],
[data-bb-scheme],
.bb-qty-btn,
.bb-remove-btn,
[data-bb-cart-button] {
  transition: all 0.2s ease;
}

/* ========================================
   PRICE DISPLAY CONTROL (CSS-BASED)
   ======================================== */

/**
 * Control price visibility via body classes
 * Classes added via PHP based on ACF settings and bundle configuration
 *
 * Performance: Native CSS (0ms overhead, no FOUC)
 * Separation of concerns: CSS for presentation, JS for calculations
 */

/* ========================================
   HIDE ALL PRICES
   ======================================== */

/* Hide all price elements completely */
body.byb-hide-all-prices .price,
body.byb-hide-all-prices .onsale,
body.byb-hide-all-prices .sale-badge,
body.byb-hide-all-prices [class*="price"] {
  display: none !important;
}

/* ========================================
   HIDE SALE PRICES ONLY (SHOW REGULAR)
   ======================================== */

/* Hide sale badges */
body.byb-hide-sale-prices .onsale,
body.byb-hide-sale-prices .sale-badge {
  display: none !important;
}

/* Hide strikethrough prices (del) and sale prices (ins) in product cards */
body.byb-hide-sale-prices .price del,
body.byb-hide-sale-prices .price ins {
  display: none !important;
}

/* Hide old price in PRODUCT CARDS ONLY (target Bricks query loop items, not summary/CTA) */
body.byb-hide-sale-prices .brx-loop-start .bb-price-old,
body.byb-hide-sale-prices .brx-loop-start [data-bb-price-old],
body.byb-hide-sale-prices [data-brx-loop-start] .bb-price-old,
body.byb-hide-sale-prices [data-brx-loop-start] [data-bb-price-old] {
  display: none !important;
}

/* Reset sale price styling to regular price styling in PRODUCT CARDS ONLY */
body.byb-hide-sale-prices .brx-loop-start .bb-price-new,
body.byb-hide-sale-prices .brx-loop-start [data-bb-price-new],
body.byb-hide-sale-prices [data-brx-loop-start] .bb-price-new,
body.byb-hide-sale-prices [data-brx-loop-start] [data-bb-price-new] {
  font-weight: normal;
  color: inherit;
}

/* Ensure price element uses regular styling when sale hidden */
body.byb-hide-sale-prices .price {
  font-weight: normal;
  color: inherit;
}

/* ========================================
   SCROLL-TRIGGERED STICKY (MOBILE ONLY)
   ========================================
   Hides sticky summary on mobile until user scrolls past threshold
   Class .bb-sticky-visible is added via JavaScript in init.js
   ======================================== */

@media (max-width: 768px) {

  /* Bundle summary wrapper - default state on mobile */
  .bb-summary__wrapper,
  [data-bb-summary-container] {
    /* Default: in normal page flow */
    position: relative;
  }

  /* Visible state after scroll threshold - class added via JS */
  .bb-summary__wrapper.bb-sticky-visible,
  [data-bb-summary-container].bb-sticky-visible {
    /* Fixed positioning at bottom */
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    z-index: 999;
    margin: 0;

    /* Visual styling */
    box-shadow: 0 -10px 25px 0 rgba(0, 0, 0, 0.15);
    border-radius: var(--bb-radius-l, 16px) var(--bb-radius-l, 16px) 0 0;

    /* Slide up animation */
    animation: bb-slideUpSticky 0.4s ease-out;
  }

  /* Slide up keyframes */
  @keyframes bb-slideUpSticky {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
}

/* Desktop: always visible, no scroll trigger needed */
@media (min-width: 769px) {
  .bb-summary__wrapper,
  [data-bb-summary-container] {
    position: relative;
    opacity: 1;
    transform: none;
  }
}