/**
 * Dinmatta Color & Size Swatches
 * Replaces default WooCommerce dropdowns with visual swatches
 */

/* Swatches Container */
.dinmatta-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 0;
    align-items: center;
}

/* Base Swatch Button */
.dinmatta-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dinmatta-swatch:focus {
    outline: none;
}

.dinmatta-swatch:focus-visible {
    box-shadow: 0 0 0 2px #FF85A3;
}

/* Color Swatches */
.dinmatta-swatch--color {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 3px;
}

.dinmatta-swatch--color:hover {
    transform: scale(1.1);
}

.dinmatta-swatch--color.is-selected {
    border-color: #1A1A1A;
}

.dinmatta-swatch__color {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Multi-color swatch */
.dinmatta-swatch--multi .dinmatta-swatch__multi {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        #E8C547 0deg,
        #5D8A66 60deg,
        #4A7CB5 120deg,
        #8B5A9C 180deg,
        #E8A0B0 240deg,
        #C44536 300deg,
        #E8C547 360deg
    );
}

/* Size Swatches */
.dinmatta-swatch--size {
    min-width: 48px;
    height: 40px;
    padding: 8px 16px;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
    background: #FFFFFF;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1A1A1A;
    white-space: nowrap;
}

.dinmatta-swatch--size:hover {
    border-color: #1A1A1A;
    background: #FAFAFA;
}

.dinmatta-swatch--size.is-selected {
    border-color: #1A1A1A;
    background: #1A1A1A;
    color: #FFFFFF;
}

/* Disabled/Out of Stock State */
.dinmatta-swatch.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.dinmatta-swatch--size.is-disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #999;
    transform: rotate(-10deg);
}

.dinmatta-swatch--color.is-disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 1px;
    background: #999;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Tooltip on hover */
.dinmatta-swatch--color[title] {
    position: relative;
}

.dinmatta-swatch--color:hover::before {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: #1A1A1A;
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
}

.dinmatta-swatch--color:hover::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1A1A1A;
    z-index: 10;
    pointer-events: none;
}

/* Variation labels */
.variations .label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1A1A1A;
    margin-bottom: 4px;
}

.variations .label label {
    font-weight: 600;
}

/* Reset link */
.reset_variations {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.8125rem;
    color: #666;
    text-decoration: underline;
    cursor: pointer;
}

.reset_variations:hover {
    color: #1A1A1A;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .dinmatta-swatch--color {
        width: 32px;
        height: 32px;
    }

    .dinmatta-swatch--size {
        min-width: 44px;
        height: 36px;
        padding: 6px 12px;
        font-size: 0.8125rem;
    }
}

/* Selected variation info */
.woocommerce-variation-description {
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: #666;
}

.woocommerce-variation-price {
    margin-bottom: 16px;
}

.woocommerce-variation-price .price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1A1A1A;
}

.woocommerce-variation-availability {
    margin-bottom: 12px;
}

.woocommerce-variation-availability .stock {
    font-size: 0.875rem;
    font-weight: 500;
}

.woocommerce-variation-availability .in-stock {
    color: #22c55e;
}

.woocommerce-variation-availability .out-of-stock {
    color: #ef4444;
}
