/**
 * Swatch-Based Product Selection & Swatch Images CSS
 * Supports rich image swatches, color swatches, active badges, tooltips & catalog card swatches
 */

.bb-product-attribute-swatch.visual-swatches-wrapper {
    margin-bottom: 1.25rem;
}

.bb-product-attribute-swatch-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.65rem;
    line-height: 1.4;
}

.bb-product-attribute-swatch-title .bb-swatch-set-label {
    color: #475569;
    font-weight: 500;
}

.bb-product-attribute-swatch-title .bb-selected-swatch-value {
    display: inline-block;
    padding: 2px 10px;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

.bb-product-attribute-swatch-list.visual-swatch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Individual Swatch Item */
.bb-product-attribute-swatch-list.visual-swatch .bb-product-attribute-swatch-item {
    position: relative;
    list-style: none;
    margin: 0;
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bb-product-attribute-swatch-list.visual-swatch .bb-product-attribute-swatch-item label.bb-swatch-label {
    display: block;
    margin: 0;
    cursor: pointer;
    position: relative;
}

.bb-product-attribute-swatch-list.visual-swatch input[type="radio"],
.bb-product-attribute-swatch-list.visual-swatch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* --- IMAGE SWATCH STYLES --- */
.bb-product-attribute-swatch-item.has-swatch-image .bb-product-attribute-swatch-display.bb-swatch-display-image {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-color: #f8fafc;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.bb-product-attribute-swatch-item.has-swatch-image:hover:not(.disabled) .bb-swatch-display-image {
    border-color: #94a3b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.bb-product-attribute-swatch-item.has-swatch-image input:checked ~ .bb-swatch-display-image {
    border-color: var(--primary-color, #0989FF) !important;
    box-shadow: 0 0 0 3px rgba(9, 137, 255, 0.25), 0 4px 12px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

/* Active checkmark badge for image swatches */
.bb-product-attribute-swatch-item.has-swatch-image .bb-swatch-check-icon {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color, #0989FF);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: scale(0.4);
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
}

.bb-product-attribute-swatch-item.has-swatch-image .bb-swatch-check-icon svg {
    width: 9px;
    height: 9px;
    stroke-width: 3;
}

.bb-product-attribute-swatch-item.has-swatch-image input:checked ~ .bb-swatch-display-image .bb-swatch-check-icon {
    opacity: 1;
    transform: scale(1);
}

/* --- COLOR SWATCH STYLES (Pure Color without Image) --- */
.bb-product-attribute-swatch-item.has-swatch-color .bb-product-attribute-swatch-display.bb-swatch-display-color {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px #cbd5e1, 0 1px 3px rgba(15, 23, 42, 0.1);
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bb-product-attribute-swatch-item.has-swatch-color:hover:not(.disabled) .bb-swatch-display-color {
    transform: scale(1.1);
    box-shadow: 0 0 0 1px #94a3b8, 0 3px 8px rgba(15, 23, 42, 0.15);
}

.bb-product-attribute-swatch-item.has-swatch-color input:checked ~ .bb-swatch-display-color {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--primary-color, #0989FF), 0 2px 8px rgba(15, 23, 42, 0.18) !important;
    transform: scale(1.05);
}

.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-check-icon {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
    opacity: 0;
    transform: scale(0.4);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-check-icon svg {
    width: 12px;
    height: 12px;
    stroke-width: 3.2;
}

.bb-product-attribute-swatch-item.has-swatch-color input:checked ~ .bb-swatch-display-color .bb-swatch-check-icon {
    opacity: 1;
    transform: scale(1);
}

/* Light background contrast enhancement for white/pale color swatches */
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#fff"],
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#FFF"],
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#ffffff"],
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#FFFFFF"] {
    box-shadow: 0 0 0 1px #94a3b8, 0 1px 3px rgba(0, 0, 0, 0.08);
}

.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#fff"] .bb-swatch-check-icon,
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#FFF"] .bb-swatch-check-icon,
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#ffffff"] .bb-swatch-check-icon,
.bb-product-attribute-swatch-item.has-swatch-color .bb-swatch-display-color[style*="#FFFFFF"] .bb-swatch-check-icon {
    color: #0f172a !important;
    filter: none;
}

/* --- DISABLED / OUT OF STOCK STATE --- */
.bb-product-attribute-swatch-item.disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
    pointer-events: none;
    filter: grayscale(85%);
}

.bb-product-attribute-swatch-item.disabled label {
    cursor: not-allowed !important;
}

.bb-product-attribute-swatch-item.disabled .bb-product-attribute-swatch-display::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -2px;
    right: -2px;
    height: 2px;
    background: #ef4444;
    transform: rotate(-45deg);
    z-index: 5;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

/* --- TOOLTIPS --- */
.bb-product-attribute-swatch-item-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0f172a;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1;
    padding: 5px 9px;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    z-index: 100;
}

.bb-product-attribute-swatch-item-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #0f172a transparent transparent transparent;
}

.bb-product-attribute-swatch-item:hover .bb-product-attribute-swatch-item-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --- PRODUCT CARD / CATALOG SWATCHES --- */
.bb-product-card-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0 6px 0;
    flex-wrap: wrap;
    min-height: 24px;
}

.bb-card-swatch-item {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid #ffffff;
    box-shadow: 0 0 0 1px #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}

.bb-card-swatch-item:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px var(--primary-color, #0989FF), 0 3px 6px rgba(0, 0, 0, 0.15);
    z-index: 3;
}

.bb-card-swatch-item.active {
    box-shadow: 0 0 0 2px var(--primary-color, #0989FF), 0 2px 4px rgba(0, 0, 0, 0.12);
    transform: scale(1.12);
}

.bb-card-swatch-more {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-left: 2px;
    line-height: 18px;
    display: inline-block;
    text-decoration: none;
}

.bb-card-swatch-more:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Smooth gallery swapping transitions */
.bb-product-gallery-images img,
.tp-product-thumb img,
.tp-product-thumb-2 img {
    transition: opacity 0.25s ease-in-out;
}

.bb-image-swapping {
    opacity: 0.75;
}
