/* ─── Archive Swatches Container ──────────────────────────────────────────── */

.archive-swatches-container {
  width: 100%;
}

.archive-swatches-container form.archive-variations-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── Archive ATC Container ──────────────────────────────────────────────── */

.archive-atc-container {
  width: 100%;
}

/* ─── Swatch Attribute Row ───────────────────────────────────────────────── */

.archive-swatch-variations {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.swatch-attribute {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.swatch-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ─── Base Swatch Item ───────────────────────────────────────────────────── */

.swatch-item {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.15s ease, opacity 0.15s ease;
  box-sizing: border-box;
  line-height: 0;
}

.swatch-item:hover {
  border-color: rgba(0, 0, 0, 0.4);
}

.swatch-item.active-swatch {
  border-color: #000;
}

/* ─── Color Swatches ─────────────────────────────────────────────────────── */

.swatch-item.swatch-color {
  border-radius: 50%;
  padding: 2px;
}

.swatch-item.swatch-color > span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* ─── Image Swatches ─────────────────────────────────────────────────────── */

.swatch-item.swatch-image {
  padding: 1px;
}

.swatch-item.swatch-image > span {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ─── Label / Text Swatches ──────────────────────────────────────────────── */

.swatch-item.swatch-label {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  line-height: 1;
}

.swatch-item.swatch-label > span {
  display: inline-block;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.swatch-item.swatch-label:hover {
  border-color: #000;
}

.swatch-item.swatch-label.active-swatch {
  border-color: #000;
  background-color: #000;
}

.swatch-item.swatch-label.active-swatch > span {
  color: #fff;
}

/* ─── Disabled & Out-of-Stock States ─────────────────────────────────────── */

.swatch-item.swatch-disabled {
  opacity: 0.25;
  pointer-events: none;
  cursor: default;
}

.swatch-item.swatch-ofs {
  opacity: 0.4;
  position: relative;
}

.swatch-item.swatch-ofs::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -2px;
  right: -2px;
  height: 1px;
  background-color: #ef4444;
  transform: rotate(-45deg);
  pointer-events: none;
}

/* ─── Tooltip (CSS-only) ─────────────────────────────────────────────────── */

.swatch-item[title] {
  position: relative;
}

.swatch-item[title]::before {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.swatch-item[title]:hover::before {
  opacity: 1;
}

/* ─── Add to Cart Button ─────────────────────────────────────────────────── */

.archive-atc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
  background-color: #000;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  text-align: center;
  gap: 6px;
}

.archive-atc-btn:hover:not([disabled]):not(.loading) {
  background-color: #333;
}

.archive-atc-btn[disabled] {
  background-color: #9ca3af;
  cursor: default;
}

.archive-atc-btn.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.archive-atc-btn.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: archive-swatch-spin 0.6s linear infinite;
}

.archive-atc-btn.added {
  background-color: #16a34a;
}

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

/* ─── Image Loading State ────────────────────────────────────────────────── */

.loading-swatch-image .image-loading {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

/* ─── Hide elements we control via JS ────────────────────────────────────── */

.archive-swatches-container .reset_variations {
  display: none !important;
}

.archive-swatches-container .single_variation_wrap {
  display: none !important;
  position: absolute !important;
  visibility: hidden !important;
}

.archive-swatches-container .archive-swatch-select {
  display: none !important;
  position: absolute !important;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .swatch-item.swatch-color > span {
    width: 20px;
    height: 20px;
  }

  .swatch-item.swatch-image > span {
    width: 24px;
    height: 24px;
  }

  .swatch-item.swatch-label > span {
    padding: 3px 6px;
    font-size: 11px;
  }

  .archive-atc-btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}
