/**
 * PPPurchaseTogether - Front Office CSS
 * "Recommended to buy together" bundle block
 *
 * Adapted from static mockup: /static/assets/css/components/purchase-together.css
 * Uses CSS custom properties defined in the theme's _variables.scss
 */

/* ==========================================================================
   Container
   ========================================================================== */

.purchase-together {
  padding: var(--spacing-4);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
}

/* ==========================================================================
   Title
   ========================================================================== */

.purchase-together__title {
  font-family: var(--font-family-base);
  font-size: 20px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  margin: 0 0 var(--spacing-4);
}

/* ==========================================================================
   Product List
   ========================================================================== */

.purchase-together__list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-4);
}

/* ==========================================================================
   Product Item
   ========================================================================== */

.purchase-together__item {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding: var(--spacing-3);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.purchase-together__item:hover {
  border-color: var(--color-primary);
}

.purchase-together__item--selected {
  border-color: var(--color-primary);
}

/* Hidden checkbox */
.purchase-together__checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Item Image
   ========================================================================== */

.purchase-together__item-image {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  height: 96px;
  background-color: var(--color-bg-card);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.purchase-together__item-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Discount badge */
.purchase-together__discount {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 6px;
  font-family: var(--font-family-base);
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-inverse);
  background-color: var(--color-accent-red);
  border-radius: var(--border-radius-sm);
}

/* ==========================================================================
   Item Info
   ========================================================================== */

.purchase-together__item-info {
  flex: 1;
  min-width: 0;
}

.purchase-together__item-name {
  display: block;
  font-family: var(--font-family-base);
  font-size: 16px;
  font-weight: var(--font-weight-normal);
  line-height: 18px;
  color: var(--color-text-primary);
  text-decoration: none;
  margin-bottom: var(--spacing-2);
}

a.purchase-together__item-name:hover {
  color: var(--color-primary);
}

.purchase-together__item-price {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-2);
}

.purchase-together__price-current {
  font-family: var(--font-family-base);
  font-size: 18px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

.purchase-together__price-old {
  font-family: var(--font-family-base);
  font-size: 14px;
  font-weight: var(--font-weight-normal);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

/* ==========================================================================
   Toggle Button (Checkbox visual)
   ========================================================================== */

.purchase-together__item-toggle {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.purchase-together__toggle-check {
  display: none;
  width: 20px;
  height: 20px;
  background-color: var(--color-primary);
  border-radius: 3px;
  align-items: center;
  justify-content: center;
}

.purchase-together__toggle-check svg {
  width: 11px;
  height: 8px;
}

.purchase-together__toggle-plus {
  display: flex;
  width: 24px;
  height: 24px;
  background-color: var(--color-bg-primary);
  border-radius: 3px;
  box-shadow: 0 4px 10px rgba(26, 48, 47, 0.12);
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.purchase-together__toggle-plus svg {
  width: 12px;
  height: 12px;
}

/* Selected state */
.purchase-together__item--selected .purchase-together__toggle-check {
  display: flex;
}

.purchase-together__item--selected .purchase-together__toggle-plus {
  display: none;
}

/* ==========================================================================
   Footer (Total + Button)
   ========================================================================== */

.purchase-together__footer {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
}

.purchase-together__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.purchase-together__total-label {
  font-family: var(--font-family-base);
  font-size: 18px;
  font-weight: var(--font-weight-normal);
  color: var(--color-text-primary);
}

.purchase-together__total-value {
  font-family: var(--font-family-base);
  font-size: 24px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

/* Add to cart button */
.purchase-together__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  width: 100%;
  height: 48px;
  padding: 0 var(--spacing-4);
  font-family: var(--font-family-base);
  font-size: 16px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-inverse);
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.purchase-together__btn:hover {
  background-color: var(--color-btn-primary-hover);
}

.purchase-together__btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.purchase-together__btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Success state */
.purchase-together__btn--success {
  background-color: #16a34a;
}

.purchase-together__btn--success:hover {
  background-color: #16a34a;
}

/* Error state */
.purchase-together__btn--error {
  background-color: var(--color-accent-red);
}

.purchase-together__btn--error:hover {
  background-color: var(--color-accent-red);
}

/* Loading spinner */
.purchase-together__spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pt-spin 0.6s linear infinite;
}

@keyframes pt-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
  .purchase-together__item-image {
    flex: 0 0 72px;
    width: 72px;
    height: 80px;
  }

  .purchase-together__item-name {
    font-size: 14px;
  }

  .purchase-together__price-current {
    font-size: 16px;
  }
}
