/**
 * Smart Product Swatches - Frontend Styles
 */

/* Hide default WC variation select when our swatches are present */
.variations td.value .sps-swatches + select,
.variations select.sps-hidden {
    display: none !important;
}

/* Swatches container */
.sps-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0;
}

/* Base swatch */
.sps-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    background-color: #fff;
    transition: all 0.2s ease-in-out;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sps-swatch:hover {
    border-color: #999;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.sps-swatch:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.sps-swatch.sps-selected {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

/* Color swatches */
.sps-swatch.sps-color {
    background-color: #ccc;
}

.sps-swatch.sps-color::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    transform: translate(-50%, -50%) scale(0);
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.35);
    opacity: 0;
    transition: all 0.2s ease;
}

.sps-swatch.sps-color.sps-selected::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Image swatches */
.sps-swatch.sps-image {
    overflow: hidden;
    background-color: #f5f5f5;
}

.sps-swatch.sps-image.sps-hover-zoom:hover {
    transform: scale(1.08);
}

/* Text swatches */
.sps-swatch.sps-text {
    padding: 0 14px;
    min-height: 36px;
    height: auto !important;
    width: auto !important;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background-color: #fff;
    border-radius: 4px;
}

.sps-swatch.sps-text:hover {
    background-color: #f5f5f5;
}

.sps-swatch.sps-text.sps-selected {
    background-color: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.sps-swatch.sps-text .sps-swatch-text {
    line-height: 1;
    white-space: nowrap;
}

/* Out of stock */
.sps-swatch.sps-out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.sps-swatch.sps-out-of-stock::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #999;
    transform: rotate(-45deg);
    pointer-events: none;
}

.sps-swatch.sps-out-of-stock:hover {
    transform: none;
    box-shadow: none;
}

/* Selected label */
.sps-selected-label {
    font-size: 13px;
    color: #666;
    margin-left: 8px;
    font-style: italic;
}

/* Tooltip */
.sps-swatch[title]:hover::after {
    /* uses native browser tooltip */
}

/* Price display */
.sps-price-display {
    margin: 15px 0;
    padding: 12px;
    background: #fafafa;
    border-left: 3px solid #2271b1;
    border-radius: 3px;
}

.sps-price-info > div {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.sps-price-info .sps-label {
    font-weight: 600;
    color: #555;
}

.sps-price-info .sps-value {
    color: #222;
}

.sps-price-info .sps-sale-price .sps-value {
    color: #d63638;
    font-weight: 700;
}

.sps-price-info .sps-discount .sps-value {
    color: #2c8a2c;
    font-weight: 700;
}

.sps-availability-value.sps-in-stock {
    color: #2c8a2c;
    font-weight: 600;
}

.sps-availability-value.sps-out-of-stock {
    color: #d63638;
    font-weight: 600;
}

/* Archive swatches */
.sps-archive-swatches {
    margin: 8px 0;
}

.sps-archive-attribute {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}

.sps-archive-swatches .sps-swatch {
    width: 24px;
    height: 24px;
    border-width: 1px;
}

.sps-archive-swatches .sps-swatch.sps-text {
    width: auto;
    min-width: 24px;
    padding: 0 8px;
    min-height: 24px;
    font-size: 12px;
}

.sps-more-options {
    font-size: 12px;
    color: #666;
    margin-left: 4px;
}

/* Sale badge */
.woocommerce span.onsale,
.woocommerce ul.products li.product .onsale {
    z-index: 2;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sps-swatches {
        gap: 6px;
    }

    .sps-swatch {
        min-width: 28px;
    }

    .sps-swatch.sps-text {
        padding: 0 10px;
        font-size: 13px;
        min-height: 32px;
    }

    .sps-selected-label {
        flex-basis: 100%;
        margin-left: 0;
        margin-top: 4px;
    }

    .sps-price-info > div {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .sps-archive-swatches .sps-swatch {
        width: 20px;
        height: 20px;
    }
}

/* AJAX feedback */
.sps-cart-feedback {
    display: inline-block;
    margin-left: 10px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s;
}

.sps-cart-feedback.sps-show {
    opacity: 1;
}

.sps-cart-feedback.sps-success {
    color: #2c8a2c;
}

.sps-cart-feedback.sps-error {
    color: #d63638;
}

/* Loading state */
.sps-loading {
    opacity: 0.6;
    pointer-events: none;
}
