/* ==========================================================================
   Auto Linked Variations - Frontend Swatches
   ========================================================================== */

.alv-swatches {
    margin: 15px 0;
    padding: 0;
    clear: both;
}

.alv-swatches-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.3;
}

.alv-swatches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

/* --- Single Swatch --- */
.alv-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    max-width: calc(var(--alv-size, 50px) + 20px);
}

.alv-swatch img {
    width: var(--alv-size, 50px);
    height: var(--alv-size, 50px);
    object-fit: cover;
    border-radius: var(--alv-radius, 8px);
    border: 2px solid #e0e0e0;
    transition: all 0.2s ease;
    display: block;
    background: #f5f5f5;
}

/* Active (current product) */
.alv-swatch--active img {
    border-color: var(--alv-active, #7c3aed);
    box-shadow: 0 0 0 2px var(--alv-active, #7c3aed);
}

/* Out of stock */
.alv-swatch--oos {
    opacity: 0.45;
    position: relative;
}

.alv-swatch--oos::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--alv-size, 50px) + 4px);
    height: 2px;
    background: #dc2626;
    transform: translate(-50%, -50%) rotate(-45deg);
    pointer-events: none;
    z-index: 1;
    border-radius: 1px;
    /* Only over the image area */
    max-height: calc(var(--alv-size, 50px));
}

/* Label under swatch */
.alv-swatch-label {
    display: block;
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 4px;
    line-height: 1.2;
    max-width: calc(var(--alv-size, 50px) + 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}

.alv-swatch--active .alv-swatch-label {
    color: var(--alv-active, #7c3aed);
    font-weight: 600;
}

.alv-swatch:hover .alv-swatch-label {
    color: #333;
}

/* --- Hover Effects --- */

/* Scale */
.alv-swatches[data-hover="scale"] .alv-swatch:not(.alv-swatch--active):hover img {
    transform: scale(1.1);
    border-color: #bbb;
}

/* Border */
.alv-swatches[data-hover="border"] .alv-swatch:not(.alv-swatch--active):hover img {
    border-color: var(--alv-active, #7c3aed);
}

/* Shadow */
.alv-swatches[data-hover="shadow"] .alv-swatch:not(.alv-swatch--active):hover img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #ccc;
}

/* None */
.alv-swatches[data-hover="none"] .alv-swatch:not(.alv-swatch--active):hover img {
    border-color: #bbb;
}

/* --- Tooltip on hover (full title) --- */
.alv-swatch[title] {
    position: relative;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .alv-swatches-list {
        gap: 8px;
    }

    .alv-swatch img {
        width: calc(var(--alv-size, 50px) * 0.85);
        height: calc(var(--alv-size, 50px) * 0.85);
    }

    .alv-swatch-label {
        font-size: 10px;
    }
}

/* --- WoodMart Theme Compatibility --- */
.single-product .alv-swatches {
    width: 100%;
}

/* Fix for WoodMart summary area */
.single-product-content .alv-swatches,
.product-summary .alv-swatches {
    margin-top: 10px;
    margin-bottom: 15px;
}

/* Nice transition when swatches container appears */
@keyframes alv-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alv-swatches {
    animation: alv-fade-in 0.3s ease-out;
}
