/* ═══════════════════════════════════════════════
   Smart Add to Cart — [bpco_smart_add_to_cart]
   Button + Stepper + Variation Popup
   @since 1.8.0
   ═══════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────── */
:root {
  --satc-accent: #16a34a;
  --satc-accent-hover: #15803d;
  --satc-accent-light: #dcfce7;
  --satc-text: #1e293b;
  --satc-text-sec: #64748b;
  --satc-bg: #ffffff;
  --satc-bg-hover: #f8fafc;
  --satc-border: #e2e8f0;
  --satc-overlay-bg: rgba(0, 0, 0, 0.45);
  --satc-radius: 12px;
  --satc-radius-lg: 16px;
  --satc-shadow: 0 10px 40px rgba(0, 0, 0, 0.15),
                 0 2px 10px rgba(0, 0, 0, 0.08);
  --satc-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════
   OUTER BUTTON / STEPPER
   ═══════════════════════════════════════════════ */

.bpco-satc {
  display: inline-flex;
  position: relative;
  width: 100%;
}

/* ── Add Button (State 1) ──────────────────── */
.bpco-satc__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 20px;
  background: var(--satc-accent);
  color: #fff;
  border: 2px solid var(--satc-accent);
  border-radius: var(--satc-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--satc-transition);
  min-height: 44px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.bpco-satc__add:hover:not([disabled]) {
  background: var(--satc-accent-hover);
  border-color: var(--satc-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.bpco-satc__add:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: none;
}

.bpco-satc__add[disabled] {
  background: #d0d0d0;
  border-color: #d0d0d0;
  color: #999;
  cursor: not-allowed;
}

/* Spinner */
.bpco-satc__spinner {
  display: none;
  flex-shrink: 0;
}

.bpco-satc__add.is-loading .bpco-satc__spinner {
  display: flex;
}

.bpco-satc__add.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.bpco-satc-spin {
  animation: bpco-satc-spin 0.7s linear infinite;
}

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

/* ── Stepper (State 2) ─────────────────────── */
.bpco-satc__stepper {
  display: none;
  align-items: center;
  width: 100%;
  border: 2px solid var(--satc-accent);
  border-radius: var(--satc-radius);
  overflow: hidden;
  min-height: 44px;
  background: var(--satc-accent-light);
}

.bpco-satc__dec,
.bpco-satc__inc {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-height: 44px;
  background: var(--satc-accent);
  border: none;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.bpco-satc__dec:hover,
.bpco-satc__inc:hover {
  background: var(--satc-accent-hover);
}

.bpco-satc__dec:active,
.bpco-satc__inc:active {
  background: #166534;
}

.bpco-satc__qty {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--satc-accent);
  user-select: none;
  line-height: 1;
}

/* ── State Toggling ────────────────────────── */
.bpco-satc.is-in-cart .bpco-satc__add {
  display: none;
}

.bpco-satc.is-in-cart .bpco-satc__stepper {
  display: flex;
}

/* Out of stock */
.bpco-satc.is-out-of-stock .bpco-satc__stepper {
  display: none !important;
}

.bpco-satc.is-out-of-stock .bpco-satc__add {
  display: inline-flex !important;
}

/* Busy state (during AJAX) */
.bpco-satc.is-busy .bpco-satc__stepper {
  opacity: 0.6;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════
   POPUP — Overlay
   ═══════════════════════════════════════════════ */

.bpco-satc-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--satc-overlay-bg);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--satc-transition);
}

.bpco-satc-overlay--visible {
  opacity: 1;
}

/* ═══════════════════════════════════════════════
   POPUP — Container
   ═══════════════════════════════════════════════ */

.bpco-satc-popup {
  background: var(--satc-bg);
  border-radius: var(--satc-radius-lg) var(--satc-radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--satc-shadow);
  transform: translateY(100%);
  transition: transform var(--satc-transition);
  overflow: hidden;
}

.bpco-satc-overlay--visible .bpco-satc-popup {
  transform: translateY(0);
}

/* Drag handle */
.bpco-satc-popup__drag {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: grab;
}

.bpco-satc-popup__drag span {
  display: block;
  width: 36px;
  height: 4px;
  background: var(--satc-border);
  border-radius: 2px;
}

/* Header */
.bpco-satc-popup__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 4px 16px 12px;
  border-bottom: 1px solid var(--satc-border);
  gap: 12px;
}

.bpco-satc-popup__product-info {
  flex: 1;
  min-width: 0;
}

.bpco-satc-popup__name {
  font-size: 17px;
  font-weight: 600;
  color: var(--satc-text);
  margin: 0 0 2px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.bpco-satc-popup__price {
  font-size: 15px;
  font-weight: 500;
  color: var(--satc-text-sec);
}

.bpco-satc-popup__price del {
  opacity: 0.5;
  font-size: 13px;
}

.bpco-satc-popup__price ins {
  text-decoration: none;
  color: var(--satc-accent);
  font-weight: 700;
}

.bpco-satc-popup__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  color: var(--satc-text-sec);
  transition: all var(--satc-transition);
  line-height: 0;
  flex-shrink: 0;
}

.bpco-satc-popup__close svg {
  width: 20px;
  height: 20px;
}

.bpco-satc-popup__close:hover {
  background: var(--satc-bg-hover);
  color: var(--satc-text);
}

/* ═══════════════════════════════════════════════
   POPUP — Body (Variations)
   ═══════════════════════════════════════════════ */

.bpco-satc-popup__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* Loading */
.bpco-satc-popup__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.bpco-satc-popup__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--satc-border);
  border-top-color: var(--satc-accent);
  border-radius: 50%;
  animation: bpco-satc-spin 0.7s linear infinite;
}

/* Variation group */
.bpco-satc-popup__var-group {
  margin-bottom: 18px;
}

.bpco-satc-popup__var-group:last-child {
  margin-bottom: 0;
}

.bpco-satc-popup__var-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--satc-text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.bpco-satc-popup__var-label .bpco-satc-popup__selected-val {
  font-weight: 400;
  color: var(--satc-text);
  text-transform: none;
  letter-spacing: 0;
}

.bpco-satc-popup__var-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Variation option button */
.bpco-satc-popup__var-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1.5px solid var(--satc-border);
  border-radius: 8px;
  background: var(--satc-bg);
  font-size: 13.5px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.bpco-satc-popup__var-btn:hover {
  border-color: #aaa;
  background: var(--satc-bg-hover);
}

.bpco-satc-popup__var-btn.is-selected {
  border-color: var(--satc-accent);
  background: var(--satc-accent);
  color: #fff;
}

.bpco-satc-popup__var-btn.is-unavailable {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* ═══════════════════════════════════════════════
   POPUP — In-Cart Section
   ═══════════════════════════════════════════════ */

.bpco-satc-popup__cart {
  border-top: 1px solid var(--satc-border);
  padding: 10px 16px;
  background: #fafbfc;
}

.bpco-satc-popup__cart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--satc-text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.bpco-satc-popup__cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--satc-border);
}

.bpco-satc-popup__cart-item:last-child {
  border-bottom: none;
}

.bpco-satc-popup__cart-item-info {
  flex: 1;
  min-width: 0;
}

.bpco-satc-popup__cart-item-attrs {
  font-size: 13px;
  font-weight: 500;
  color: var(--satc-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bpco-satc-popup__cart-item-total {
  font-size: 12px;
  color: var(--satc-text-sec);
  margin-top: 1px;
}

/* Mini stepper inside popup cart items */
.bpco-satc-popup__mini-stepper {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--satc-border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  height: 32px;
}

.bpco-satc-popup__mini-dec,
.bpco-satc-popup__mini-inc {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--satc-text);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.bpco-satc-popup__mini-dec:hover,
.bpco-satc-popup__mini-inc:hover {
  background: var(--satc-bg-hover);
}

.bpco-satc-popup__mini-qty {
  width: 28px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--satc-text);
  border-left: 1.5px solid var(--satc-border);
  border-right: 1.5px solid var(--satc-border);
  line-height: 32px;
  user-select: none;
}

.bpco-satc-popup__cart-item.is-busy {
  opacity: 0.5;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════
   POPUP — Footer
   ═══════════════════════════════════════════════ */

.bpco-satc-popup__footer {
  border-top: 1px solid var(--satc-border);
  padding: 12px 16px 16px;
}

.bpco-satc-popup__var-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--satc-text);
  margin-bottom: 8px;
}

.bpco-satc-popup__var-stock {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.bpco-satc-popup__var-stock .out-of-stock {
  color: #dc2626;
}

.bpco-satc-popup__add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 24px;
  background: var(--satc-accent);
  color: #fff;
  border: none;
  border-radius: var(--satc-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--satc-transition);
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.bpco-satc-popup__add-btn:hover:not([disabled]) {
  background: var(--satc-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.bpco-satc-popup__add-btn:active:not([disabled]) {
  transform: translateY(0);
}

.bpco-satc-popup__add-btn[disabled] {
  background: #d0d0d0;
  color: #999;
  cursor: not-allowed;
}

.bpco-satc-popup__add-btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.bpco-satc-popup__add-spinner {
  display: none;
}

.bpco-satc-popup__add-btn.is-loading .bpco-satc-popup__add-spinner {
  display: flex;
}

/* ═══════════════════════════════════════════════
   DESKTOP — Centered Modal
   ═══════════════════════════════════════════════ */

@media (min-width: 768px) {
  .bpco-satc-overlay {
    align-items: center;
  }

  .bpco-satc-popup {
    border-radius: var(--satc-radius-lg);
    max-height: 70vh;
    transform: translateY(20px);
    opacity: 0;
  }

  .bpco-satc-overlay--visible .bpco-satc-popup {
    transform: translateY(0);
    opacity: 1;
  }

  .bpco-satc-popup__drag {
    display: none;
  }

  .bpco-satc-popup__header {
    padding: 16px 20px;
  }

  .bpco-satc-popup__body {
    padding: 20px;
  }

  .bpco-satc-popup__cart {
    padding: 12px 20px;
  }

  .bpco-satc-popup__footer {
    padding: 12px 20px 20px;
  }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════ */

@media (max-width: 480px) {
  .bpco-satc__add {
    font-size: 13px;
    padding: 9px 14px;
    min-height: 40px;
  }

  .bpco-satc__dec,
  .bpco-satc__inc {
    width: 38px;
    min-height: 40px;
  }

  .bpco-satc__stepper {
    min-height: 40px;
  }

  .bpco-satc__qty {
    font-size: 14px;
  }
}
