/**
 * WooCommerce Attribute Swatches - Frontend CSS
 */

/* ============================================
   Swatch Container
   ============================================ */

.was-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
    padding: 0;
    list-style: none;
    align-items: center;
}

.was-display-inline {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   Individual Swatches
   ============================================ */

.was-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

/* Color Swatches */
.was-type-color .was-swatch {
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Image Swatches */
.was-type-image .was-swatch {
    border: 2px solid transparent;
    overflow: hidden;
}

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

/* Label / Text Swatches */
.was-type-label .was-swatch {
    padding: 6px 16px;
    border: 2px solid #ddd;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    min-width: 40px;
    text-align: center;
    line-height: 1.4;
}

/* Radio Button Swatches */
.was-type-radio .was-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 2px solid #ddd;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.was-type-radio .was-radio-label input[type="radio"] {
    margin: 0;
    accent-color: #333;
}

/* ============================================
   Shapes
   ============================================ */

.was-shape-round .was-type-color .was-swatch,
.was-shape-round .was-swatch:not(.was-radio-label) {
    /* Applied via JS based on type */
}

.was-shape-round.was-type-color .was-swatch,
.was-shape-round.was-type-image .was-swatch {
    border-radius: 50%;
}

.was-shape-rounded.was-type-color .was-swatch,
.was-shape-rounded.was-type-image .was-swatch {
    border-radius: 6px;
}

.was-shape-square.was-type-color .was-swatch,
.was-shape-square.was-type-image .was-swatch {
    border-radius: 0;
}

.was-shape-round.was-type-label .was-swatch,
.was-shape-round.was-type-radio .was-radio-label {
    border-radius: 999px;
}

.was-shape-rounded.was-type-label .was-swatch,
.was-shape-rounded.was-type-radio .was-radio-label {
    border-radius: 6px;
}

.was-shape-square.was-type-label .was-swatch,
.was-shape-square.was-type-radio .was-radio-label {
    border-radius: 0;
}

/* ============================================
   Hover & Selected States
   ============================================ */

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

.was-type-label .was-swatch:hover,
.was-type-radio .was-radio-label:hover {
    border-color: #333;
    transform: none;
}

/* Selected - Border style */
.was-swatch.was-selected,
.was-type-color .was-swatch.was-selected,
.was-type-image .was-swatch.was-selected {
    border-color: #333;
    box-shadow: 0 0 0 1px #333;
}

.was-type-label .was-swatch.was-selected,
.was-type-radio .was-radio-label.was-selected {
    border-color: #333;
    background: #333;
    color: #fff;
    box-shadow: none;
}

/* Tick / Checkmark (hidden by default) */
.was-tick {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    pointer-events: none;
}

.was-tick::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    position: absolute;
    top: 1px;
    left: 4px;
}

/* Show tick on selected when tick style is active */
.was-selected-tick .was-swatch.was-selected .was-tick,
.was-selected-both .was-swatch.was-selected .was-tick {
    display: block;
}

/* Dark color detection helper - for light colored swatches */
.was-swatch.was-light-color .was-tick::after {
    border-color: #333;
}

/* ============================================
   Out of Stock Styles
   ============================================ */

.was-swatch.was-oos-cross {
    position: relative;
    opacity: 0.6;
    cursor: not-allowed;
}

.was-swatch.was-oos-cross::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -2px;
    right: -2px;
    height: 2px;
    background: #d32f2f;
    transform: rotate(-45deg);
    pointer-events: none;
}

.was-swatch.was-oos-fade {
    opacity: 0.3;
    cursor: not-allowed;
}

.was-swatch.was-oos-fade:hover {
    transform: none;
}

.was-swatch.was-oos-hide {
    display: none !important;
}

/* ============================================
   Tooltip
   ============================================ */

.was-swatch[data-tooltip] {
    position: relative;
}

.was-swatch[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1d2327;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
}

.was-swatch[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #1d2327;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 100;
}

.was-tooltip-enabled .was-swatch[data-tooltip]:hover::before,
.was-tooltip-enabled .was-swatch[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Large Image Preview
   ============================================ */

.was-large-preview {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 150px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.was-large-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.was-swatch:hover .was-large-preview {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Swatch Groups
   ============================================ */

.was-swatch-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.was-group-label {
    display: block;
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

/* ============================================
   Catalog / Shop Page Swatches
   ============================================ */

.was-catalog-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0;
    align-items: center;
}

.was-catalog-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    text-decoration: none;
}

/* Catalog Color Swatches */
.was-catalog-swatches .was-catalog-color {
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: none;
}

.was-catalog-swatches.was-shape-round .was-catalog-color,
.was-catalog-swatches.was-shape-round .was-catalog-image {
    border-radius: 50%;
}

.was-catalog-swatches.was-shape-rounded .was-catalog-color,
.was-catalog-swatches.was-shape-rounded .was-catalog-image {
    border-radius: 4px;
}

.was-catalog-swatches.was-shape-square .was-catalog-color,
.was-catalog-swatches.was-shape-square .was-catalog-image {
    border-radius: 0;
}

/* Catalog Image Swatches */
.was-catalog-swatches .was-catalog-image {
    border: 1px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.was-catalog-swatches .was-catalog-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Catalog Label Swatches */
.was-catalog-swatches .was-catalog-label {
    padding: 2px 8px;
    border: 1px solid #ddd;
    font-size: 11px;
    font-weight: 500;
    color: #555;
    text-decoration: none;
    background: #fff;
}

.was-catalog-swatches.was-shape-round .was-catalog-label {
    border-radius: 999px;
}

.was-catalog-swatches.was-shape-rounded .was-catalog-label {
    border-radius: 4px;
}

/* Catalog Swatch Hover */
.was-catalog-swatch:hover {
    transform: scale(1.15);
    border-color: #333;
}

.was-catalog-label:hover {
    transform: none;
    background: #333;
    border-color: #333;
    color: #fff;
}

/* Catalog "More" indicator */
.was-catalog-more {
    font-size: 11px;
    color: #999;
    padding: 2px 6px;
    font-weight: 500;
}

/* Catalog swatch tooltip */
.was-catalog-swatch[data-tooltip] {
    position: relative;
}

.was-catalog-swatch[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1d2327;
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 50;
}

.was-catalog-swatch[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .was-swatches {
        gap: 6px;
    }

    .was-type-label .was-swatch {
        padding: 5px 12px;
        font-size: 12px;
    }

    .was-swatch[data-tooltip]::before {
        display: none;
    }

    .was-swatch[data-tooltip]::after {
        display: none;
    }

    .was-catalog-swatch[data-tooltip]::before {
        display: none;
    }
}
