/**
 * JD Product Manager - Frontend Swatch Styles
 */

/* Force vertical layout for variations */
.variations {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px;
}

.variations tbody,
.variations tr {
    display: block !important;
    width: 100%;
}

.variations tr {
    margin-bottom: 15px;
}

.variations th.label,
.variations td.label {
    display: block !important;
    width: 100%;
    text-align: left;
    padding: 0 0 8px 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

.variations td.value {
    display: block !important;
    width: 100%;
    padding: 0;
}

.jdpm-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 10px 0;
    align-items: center;
}

.jdpm-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.jdpm-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.jdpm-swatch.selected {
    border-color: #00798c;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #00798c;
}

/* Tooltip on hover */
.jdpm-swatch::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    margin-bottom: 8px;
    pointer-events: none;
}

.jdpm-swatch:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Checkmark for selected */
.jdpm-swatch.selected::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Light color adjustment */
.jdpm-swatch.light-color.selected::before {
    color: #333;
    text-shadow: none;
}

/* Out of stock swatch */
.jdpm-swatch.out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
}

.jdpm-swatch.out-of-stock::after {
    content: 'Out of Stock';
}

/* ======================= */
/* SIZE SWATCHES (Buttons) */
/* ======================= */

.jdpm-size-swatch {
    width: auto !important;
    height: auto !important;
    border-radius: 4px !important;
    padding: 8px 16px;
    min-width: 44px;
    background: #f5f5f5;
    border: 1px solid #ddd !important;
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    text-align: center;
    box-shadow: none;
}

.jdpm-size-swatch:hover {
    background: #fff;
    border-color: #00798c !important;
    color: #00798c;
    transform: none;
    box-shadow: none;
}

.jdpm-size-swatch.selected {
    background: #00798c;
    border-color: #00798c !important;
    color: #fff;
    box-shadow: none;
}

/* Remove checkmark for size swatches */
.jdpm-size-swatch.selected::before {
    display: none;
}

/* Hide tooltip for size swatches (text is already visible) */
.jdpm-size-swatch::after {
    display: none;
}

/* ========================== */
/* IMAGE-BASED COLOR SWATCHES */
/* ========================== */

.jdpm-img-swatch {
    background: none !important;
    overflow: hidden;
    padding: 0;
}

.jdpm-img-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    pointer-events: none;
}

/* Image swatches don't need the checkmark (image itself shows the color) */
.jdpm-img-swatch.selected::before {
    display: none;
}