.upsell-container {
  margin: 1rem 0;
  position: relative;
  border: #ebebeb solid 1px;
  box-shadow: 0 8px 10px #0000001a;
  border-radius: 7px;
  padding: 15px;
}

.upsell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.upsell-container h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  text-align: left;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Grid overflow wrapper for slider */
.grid-overflow-wrapper {
  overflow: hidden;
  margin-bottom: 2.5rem;
  position: relative;
}

.upsell-products {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* Reset gap when Flickity is active */
.upsell-container .upsell-products.flickity-enabled {
  gap: 0;
}

/* When flickity is initialized - scoped to upsell container only */
.upsell-container .upsell-products.flickity-enabled {
  display: block;
}

/* Flickity cell sizing - standard approach */
.upsell-container .upsell-products.flickity-enabled .upsell-product {
  width: calc(50% - 10px);
  margin-right: 20px;
}

/* Desktop (1200px+): No slider needed when 3 items, show all in grid */
@media screen and (min-width: 1200px) {
  .upsell-container .upsell-products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Flickity disabled on desktop with 3 items */
  .upsell-container .upsell-products:not(.flickity-enabled) .upsell-product {
    width: auto;
    margin-right: 0;
  }
  
  /* Hide navigation on desktop */
  .upsell-container[data-product-count="3"] .upsell-nav {
    display: none !important;
  }
}

/* Tablet to Desktop (768px - 1199px): Use slider with 2 visible */
@media screen and (min-width: 768px) and (max-width: 1199px) {
  .upsell-container .upsell-products.flickity-enabled .upsell-product {
    width: calc(50% - 10px);
  }
}

/* Mobile (under 768px): Show 2 across with slider */
@media screen and (max-width: 767px) {
  .upsell-products {
    gap: 0.75rem;
  }
  
  .upsell-container .upsell-products.flickity-enabled .upsell-product {
    width: calc(50% - 7.5px);
    margin-right: 15px;
  }
}

/* Ensure grid stays visible when slider not initialized */
.upsell-container .upsell-products:not(.flickity-enabled) {
  display: grid !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* For browsers that don't support Flickity */
@media screen and (max-width: 1199px) {
  .upsell-container .upsell-products:not(.flickity-enabled) {
    grid-template-columns: repeat(2, 1fr);
  }
}

.upsell-product {
  border: 1px solid #ebebeb;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 8px 10px 0 rgba(0, 0, 0, 0.1);
  text-align: left;
  transition: transform 0.2s ease;
  position: relative;
  overflow: hidden;
}

.upsell-product:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px 0 rgba(0, 0, 0, 0.12);
}

/* Product badge */
.upsell-product-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 70px;
  height: 70px;
  background: #CD8B99;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  padding: 0.5rem;
  line-height: 1.2;
  z-index: 2;
}

.upsell-product-image-wrap {
  padding: 2rem;
  background: #fff;
  text-align: center;
}

.upsell-product img {
  width: 100%;
  height: auto;
  display: block;
}

.upsell-product-info {
  padding: 1.5rem;
  border-top: 1px solid #ebebeb;
  position: relative;
}

.upsell-product-info::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: #CD8B99;
}

.upsell-product h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  line-height: 1.3;
  text-transform: none;
  letter-spacing: 0;
}

/* Stacked title styling */
.upsell-main-title {
  display: block;
  margin-bottom: 0.25rem;
}

.upsell-size-info {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #666;
}

/* Star rating */
.upsell-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.upsell-stars {
  display: flex;
  gap: 2px;
}

.upsell-star {
  color: #CD8B99;
  font-size: 0.875rem;
}

.upsell-review-count {
  font-size: 0.75rem;
  color: #666;
}

.upsell-price {
  font-size: 16px;
  font-weight: 700;
  color: #000;
  margin-bottom: 1rem;
}

/* Variant selectors styling */
.upsell-variant-selector {
  margin: 0.5rem 0;
}

.upsell-variant-selector label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  color: var(--color-text-subdued, #6b7280);
}

.upsell-variant-selector select,
.upsell-option-select {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 0.25rem;
  background-color: var(--color-background, #ffffff);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  margin-bottom: 0.5rem;
}

.upsell-variant-selector select:focus,
.upsell-option-select:focus {
  outline: none;
  border-color: var(--color-primary, #3b82f6);
  box-shadow: 0 0 0 1px var(--color-primary, #3b82f6);
}

/* Variant option group for multiple option types */
.upsell-option-group:not(:last-child) {
  margin-bottom: 0.5rem;
}

/* Styling for in-cart products */
.upsell-product.in-cart {
  opacity: 0.7;
  background-color: var(--color-background-subdued, #f9fafb);
}

.upsell-product.in-cart select,
.upsell-product.in-cart button {
  opacity: 0.5;
  cursor: not-allowed;
}

.upsell-product.in-cart .upsell-add-btn {
  background-color: var(--color-success-background, #d1fae5);
  color: var(--color-success, #059669);
  border-color: var(--color-success, #059669);
}

/* Add All button styling */
[data-upsell-add-all] {
  margin-top: 8px;
  padding: 13px;
  background-color: #000;
  color: #fff;
  border: none;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size:0.72rem;
  width:100%;
  position: relative;
  z-index: 10;
}

[data-upsell-add-all]:hover {
  background-color: #333;
}

[data-upsell-add-all]:disabled {
  background-color: #999;
  cursor: not-allowed;
}

/* Navigation arrows */
.upsell-nav {
  display: flex;
  gap: 0.5rem;
}

.upsell-nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 20px;
}

.upsell-nav-btn--prev {
  background-color: #b8b8b8;
  color: #fff;
}

.upsell-nav-btn--next {
  background-color: #000;
  color: #fff;
}

.upsell-nav-btn:hover {
  transform: scale(1.05);
}

.upsell-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Bundle message */
.upsell-bundle-message {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 0.25rem;
  text-align: center;
  font-weight: 600;
  background-color: var(--color-background-subdued, #f9fafb);
  border: 1px solid var(--color-border, #e2e8f0);
}

.upsell-bundle-message.complete {
  background-color: var(--color-success-background, #d1fae5);
  border-color: var(--color-success, #059669);
  color: var(--color-success, #059669);
}

.main-product-status {
  font-style: italic;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: var(--color-text-subdued, #6b7280);
}

/* Loading state */
.upsell-loading {
  text-align: center;
  padding: 3rem;
  color: #666;
  font-size: 0.875rem;
}

/* Hide elements we don't need */
.upsell-bundle-message,
.main-product-status {
  display: none;
}

/* Message container */
.upsell-message-container {
  margin-top: 15px;
  text-align: center;
}

/* Success message styling */
.upsell-success-message {
  color: #4CAF50;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* Error message styling */
.upsell-error-message {
  color: #c00;
  font-size: 12px;
  line-height: 1.5;
}

/* Sold out product styling */
.upsell-product.sold-out {
  opacity: 0.6;
}

.upsell-product.sold-out .upsell-add-btn {
  background-color: #999;
  cursor: not-allowed;
}

/* Button styling */
.upsell-add-btn {
  width: 100%;
  padding: 7px;
  font-size: 0.775rem;
  font-weight: 600;
  background-color: #000;
  color: #fff;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  margin-top: auto;
}

.upsell-add-btn:hover {
  background-color: #333;
  transform: translateY(-1px);
}

.upsell-add-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
  opacity: 0.6;
}
