/**
 * Custom Variation Swatches Styles
 * Save this as: /wp-content/themes/astra-child/css/custom-swatches.css
 */

/* ===== Main Wrapper ===== */
.custom-variation-swatches-wrapper {
    margin: 20px 0;
    padding: 0;
}

.swatch-group {
    margin-bottom: 25px;
}

.swatch-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.swatch-label .selected-value {
    font-weight: 400;
    color: #666;
    text-transform: none;
    letter-spacing: normal;
}

/* ===== Image Swatches Slider ===== */
.swatch-slider-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.swatch-slider {
    display: flex;
    gap: 12px;
    overflow: hidden;
    scroll-behavior: smooth;
    width: 100%;
    padding: 5px 0;
}

.swatch-item.image-swatch {
    width: 60px;
    height: 60px;
    min-width: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #e1e1e1;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: #fff;
}

.swatch-item.image-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.swatch-item.image-swatch:hover {
    border-color: #999;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.swatch-item.image-swatch.selected {
    border-color: #000;
    box-shadow: 0 0 0 2px #000;
    transform: scale(1.05);
}

.swatch-item.image-swatch.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Navigation Buttons */
.swatch-nav {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
}

.swatch-nav:hover {
    background: #f5f5f5;
    border-color: #999;
}

.swatch-nav:active {
    transform: scale(0.95);
}

.swatch-nav.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== Button/Text Swatches ===== */
.swatch-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.swatch-item.button-swatch {
    padding: 10px;
    border: 1px solid #000;
    border-radius: 12px;
    background: #fff;
    color: #000;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
    text-align: center;
}

.swatch-item.button-swatch:hover {
    background: #f5f5f5;
    border-color: #333;
}

.swatch-item.button-swatch.selected {
    background: #000;
    color: #fff;
}

.swatch-item.button-swatch.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== Tooltip ===== */
.swatch-item.image-swatch:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.swatch-item.image-swatch.disabled:hover::after {
    display: none;
}

/* ===== Hide Default Variation Form Elements ===== */
.variations {
    display: none !important;
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 768px) {
    .swatch-item.image-swatch {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }
    
    .swatch-slider {
        gap: 8px;
    }
    
    .swatch-nav {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    
    .swatch-item.button-swatch {
        padding: 8px;
        font-size: 13px;
        min-width: 50px;
    }
}

@media (max-width: 480px) {
    .swatch-item.image-swatch {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }
    
    .swatch-label {
        font-size: 13px;
    }
    
    .swatch-buttons-container {
        gap: 8px;
    }
}

/* ===== Loading State ===== */
.custom-variation-swatches-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ===== Animation ===== */
@keyframes swatchPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.swatch-item.selected {
    animation: swatchPulse 0.3s ease;
}

/* ===== Fix for Astra Theme Compatibility ===== */
.ast-separate-container .custom-variation-swatches-wrapper {
    margin: 20px 0;
}

.single-product .summary .custom-variation-swatches-wrapper {
    clear: both;
}

/* ===== Force Image Swatches Visibility & Alignment ===== */
.custom-variation-swatches-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.swatch-slider-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
    padding: 10px 0;
}

/* Force the image circle size and spacing */
.swatch-slider {
    display: flex !important;
    align-items: center;
    gap: 14px;
    overflow-x: auto !important;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    padding: 5px 2px;
}

.swatch-item.image-swatch img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #f9f9f9;
}

/* Center the nav buttons */
.swatch-nav {
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.swatch-nav:hover {
    background-color: #f1f1f1;
}

/* Prevent stretching and wrap issues */
.swatch-group {
    flex: 1 1 auto;
    min-width: 0;
}

/* ===== Hide Broken Image Icons ===== */
.swatch-item.image-swatch img[src*="woocommerce-placeholder"] {
    opacity: 0.2;
    filter: grayscale(100%);
}

/* ===== Force proper spacing between swatches ===== */
.swatch-slider::-webkit-scrollbar {
    height: 6px;
}
.swatch-slider::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.custom-variation-swatches-wrapper {
  margin-top: 20px;
  text-align: center;
}

.swatch-slider-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.swatch-slider {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  max-width: 320px;
  padding: 8px;
}

.swatch-item {
  cursor: pointer;
  flex: 0 0 auto;
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 4px;
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.swatch-item img {
  border-radius: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.swatch-item.text-swatch {
  font-size: 14px;
  border: 1px solid #000;
  border-radius: 12px;
  padding: 10px;
  background-color: #fff;
}

.swatch-item.text-swatch.active {
  background-color: #000;
  color: #fff;
}

.swatch-nav {
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.swatch-nav:hover {
  background: #ccc;
}
.custom-variation-swatches-wrapper {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
}

.swatch-item {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: 1px solid #ccc;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 55px;
    font-size: 13px;
}

.swatch-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.swatch-item.active {
    border: 2px solid #000;
    box-shadow: 0 0 0 2px #0003;
}

.swatch-text {
    border-radius: 12px;
    border: 1px solid #000;
    padding: 10px 15px;
    min-width: 50px;
    background: #fff;
}

.swatch-text.active {
    background: #000;
    color: #fff;
}

