/**
 * Unified Product Purchase Box Styles
 *
 * This CSS handles the responsive positioning of the unified purchase box
 * to eliminate CLS (Cumulative Layout Shift) caused by duplicate DOM elements.
 *
 * Strategy:
 * - Mobile (<900px): Inline, sticky position for easy access
 * - Desktop (>=900px): Sidebar, floated right
 */

/* ========================================================================
   BASE STYLES - Shared across all breakpoints
   ======================================================================== */

.product-purchase-box-unified {
  width: 100%;
  box-sizing: border-box;
}

.product-purchase-box-unified .box-wrapper {
  background: var(--surface-base, #ffffff);
  border: 1px solid var(--border-base, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(16, 24, 40, 0.04));
  padding: var(--space-xl, 24px);
  transition: box-shadow 200ms ease;
}

.product-purchase-box-unified .box-wrapper:hover {
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(16, 24, 40, 0.06));
}

/* Main Purchase Actions Container */
.product-purchase-box-unified .main-purchase {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 8px);
}

.product-purchase-box-unified .main-purchase .button {
  width: 100%;
  justify-content: center;
  font-weight: 700;
}

/* Quotation Note - Only show on mobile */
.product-purchase-box-unified .quotation-note {
  display: block;
  color: var(--ink-tertiary, #667085);
  font-size: 11px;
  text-align: center;
  margin-top: 4px;
}

/* Shipping & Warranty Info */
.product-shipping-info {
  margin-top: var(--space-md, 12px);
  padding-top: var(--space-md, 12px);
  border-top: 1px solid var(--border-subtle, #eef0f2);
}

.product-shipping-info .info-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 8px);
  margin-bottom: var(--space-sm, 8px);
  padding: var(--space-sm, 8px);
  background: var(--surface-subtle, #f8fafc);
  border-radius: var(--radius-sm, 6px);
}

.product-shipping-info .info-row:last-child {
  margin-bottom: 0;
}

.product-shipping-info .info-icon {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-shipping-info .info-icon img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.product-shipping-info .info-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-secondary, #344054);
}

.product-shipping-info .info-text a {
  color: var(--accent-primary, #ff9f37);
  text-decoration: none;
  font-weight: 600;
  transition: color 200ms ease;
}

.product-shipping-info .info-text a:hover {
  color: var(--accent-hover, #ff8a1f);
  text-decoration: underline;
}

/* Alternative Purchase Sections (Promo, Installment) */
.product-purchase-box-unified .alt-purchase {
  background: var(--surface-subtle, #f8fafc);
  border: 1px dashed var(--border-base, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-lg, 16px);
}

.product-purchase-box-unified .alt-purchase .box-title {
  margin-bottom: var(--space-md, 12px);
  padding: 0;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--ink-primary, #101828);
}

/* ========================================================================
   MOBILE STYLES - JS-Repositioned, Inline Position
   ======================================================================== */

/* Mobile: When JS moves box into .purchase-desc-placeholder */
.product-purchase-box-unified.is-mobile-position {
  display: block;
  width: 100%;
  margin: var(--space-lg, 16px) 0;
}

.product-purchase-box-unified.is-mobile-position .box-wrapper {
  /* Sticky positioning for easy access while scrolling */
  position: sticky;
  top: var(--space-lg, 16px);
  z-index: 6;
  /* Above content but below header (typically z-index: 10) */
}

/* Fallback for no-JS: hide if JS hasn't repositioned yet */
@media (max-width: 899px) {
  .product-purchase-box-unified:not(.is-mobile-position):not(
      .is-desktop-position
    ) {
    display: none;
  }
}

/* Show quotation note on mobile */
.product-purchase-box-unified.is-mobile-position .quotation-note {
  display: block;
}

/* Ensure full-width buttons on mobile */
.product-purchase-box-unified.is-mobile-position .main-purchase .button,
.product-purchase-box-unified.is-mobile-position .alt-purchase .button {
  width: 100% !important;
}

.purchase-box-other-wrapper .toggle-product-marketplace,
.purchase-box-other-wrapper .toggle-shipping-estimation {
  display: block;
}

.purchase-box-other-wrapper #product-marketplace,
.purchase-box-other-wrapper #shipping-estimation {
  display: none;
}

.purchase-box-other-wrapper #product-marketplace .box-title,
.purchase-box-other-wrapper #shipping-estimation .box-title {
  display: none;
}

/* ========================================================================
   DESKTOP STYLES - Sidebar, Floated Right
   ======================================================================== */

@media (min-width: 900px) {
  /* Wrapper for product detail page layout */
  .product-detail-wrapper {
    display: flex;
    gap: var(--space-xl, 24px);
    align-items: flex-start;
  }

  /* Main content area (images, description, specs) */
  .product-main-box {
    flex: 1 1 auto;
    min-width: 0;
    /* Prevent flex item from overflowing */
  }

  /* Purchase box sidebar - when JS has positioned it */
  .product-purchase-box-unified.is-desktop-position {
    display: block;
    flex: 0 0 300px;
    /* Fixed width sidebar */
    width: 300px;
    max-width: 300px;
  }

  .product-purchase-box-unified.is-desktop-position .box-wrapper {
    /* Static positioning on desktop */
    position: static;
    top: auto;
  }

  /* Hide quotation note on desktop (save space) */
  .product-purchase-box-unified.is-desktop-position .quotation-note {
    display: none;
  }

  .purchase-box-other-wrapper .toggle-product-marketplace,
  .purchase-box-other-wrapper .toggle-shipping-estimation {
    display: none !important;
  }

  .purchase-box-other-wrapper #product-marketplace,
  .purchase-box-other-wrapper #shipping-estimation {
    display: block !important;
    margin-top: 20px;
  }

  .purchase-box-other-wrapper #product-marketplace .box-title,
  .purchase-box-other-wrapper #shipping-estimation .box-title {
    display: block !important;
    font-size: 12px !important;
  }
}

/* ========================================================================
   LARGER DESKTOP STYLES
   ======================================================================== */

@media (min-width: 1100px) {
  .product-purchase-box-unified {
    flex: 0 0 320px;
    width: 320px;
    max-width: 320px;
  }

  .product-purchase-box-unified .box-wrapper {
    padding: var(--space-2xl, 32px) var(--space-xl, 24px);
  }
}

/* ========================================================================
   LEGACY COMPATIBILITY - Hide old purchase boxes
   ======================================================================== */

/* Hide the old mobile purchase box (line 1372) */
.product-detail .product-desc .purchase-desc {
  display: none !important;
}

/* Hide the old desktop purchase box (line 2391) */
.product-purchase-box {
  display: none !important;
}

/* Placeholder element styling */
.purchase-desc-placeholder {
  /* Empty placeholder for JS to insert purchase box on mobile */
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Reserve space before JS repositions the purchase box (mobile breakpoint matches JS). */
@media (max-width: 899px) {
  .purchase-desc-placeholder {
    min-height: 620px;
    contain: layout;
  }
}

@media (min-width: 900px) {
  .purchase-desc-placeholder {
    min-height: 0;
  }
}

/* ========================================================================
   BUTTON OVERRIDES - Ensure consistency
   ======================================================================== */

.product-purchase-box-unified .button.block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md, 8px);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 160ms ease;
  text-transform: none;
  border: 1px solid transparent;
}

.product-purchase-box-unified .button.block.uppercase {
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.product-purchase-box-unified .button.block.big {
  padding: 14px 18px;
  font-size: 14px;
}

.product-purchase-box-unified .button.block.small {
  padding: 8px 12px;
  font-size: 12px;
}

/* Orange Buy Button */
.product-purchase-box-unified .button.orange {
  background: var(--accent-primary, #ff9f37);
  border-color: var(--accent-primary, #ff9f37);
  color: #ffffff;
}

.product-purchase-box-unified .button.orange:hover {
  background: var(--accent-hover, #ff8a1f);
  border-color: var(--accent-hover, #ff8a1f);
  box-shadow: var(--shadow-md, 0 4px 8px rgba(16, 24, 40, 0.08));
}

.product-purchase-box-unified .button.orange.invert {
  background: transparent;
  border-color: var(--accent-primary, #ff9f37);
  color: var(--accent-primary, #ff9f37);
}

.product-purchase-box-unified .button.orange.invert:hover {
  background: var(--accent-primary, #ff9f37);
  color: #ffffff;
}

/* Blue Button */
.product-purchase-box-unified .button.blue {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

.product-purchase-box-unified .button.blue:hover {
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(16, 24, 40, 0.06));
}

/* Green WhatsApp Button */
.product-purchase-box-unified .button.green {
  background: #25d366;
  border-color: #25d366;
  color: #ffffff;
}

.product-purchase-box-unified .button.green:hover {
  background: #1fb855;
  border-color: #1fb855;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(16, 24, 40, 0.06));
}

.product-purchase-box-unified .button.green.invert {
  background: transparent;
  border-color: #25d366;
  color: #25d366;
}

.product-purchase-box-unified .button.green.invert:hover {
  background: #25d366;
  color: #ffffff;
}

/* ========================================================================
   ACCESSIBILITY & INTERACTIONS
   ======================================================================== */

.product-purchase-box-unified .button:focus-visible {
  outline: 2px solid var(--accent-primary, #ff9f37);
  outline-offset: 2px;
}

.product-purchase-box-unified .button.nohover {
  cursor: default;
}

.product-purchase-box-unified .button.nohover:hover {
  transform: none;
  box-shadow: none;
}

/* Form styling */
.product-purchase-box-unified form {
  margin: 0;
}

/* ========================================================================
   PRINT STYLES
   ======================================================================== */

@media print {
  .product-purchase-box-unified {
    display: none;
  }
}
