/**
 * Frontend Styles for Otopist Attribute Swatches
 */

/* Main wrapper */
.otopist-swatches-wrapper {
    margin-bottom: 20px;
}

/* Container for swatches */
.otopist-swatches-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

/* Individual swatch item */
.otopist-swatch-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.otopist-swatch-item:hover {
    transform: translateY(-2px);
}

/* Base swatch styles */
.otopist-swatch {
    display: inline-block;
    position: relative;
    background-size: cover;
    background-position: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Shape variants */
.otopist-shape-circle {
    border-radius: 50%;
}

.otopist-shape-square {
    border-radius: 0;
}

.otopist-shape-rounded {
    border-radius: 8px;
}

/* Border */
.otopist-swatch.otopist-has-border {
    border: 2px solid #ddd;
}

/* Color swatch specific */
.otopist-swatch-color {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Image swatch specific */
.otopist-swatch-image {
    background-size: cover;
    background-position: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Label swatch specific */
.otopist-swatch-label {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    background: #fff;
    transition: all 0.3s ease;
}

.otopist-swatch-label:hover {
    border-color: #999;
}

/* Selected state - Border style */
.otopist-swatch-item.selected .otopist-swatch.otopist-has-border {
    border-color: #000;
    border-width: 3px;
}

/* Selected state - Shadow style */
.otopist-swatch-item.selected .otopist-swatch {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Selected state - Checkmark style */
.otopist-swatch-item.selected .otopist-swatch::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Selected label swatch */
.otopist-swatch-item.selected .otopist-swatch-label {
    border-color: #000;
    background: #000;
    color: #fff;
}

/* Swatch label below */
.otopist-swatch-label {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    text-align: center;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.otopist-swatch-item.selected .otopist-swatch-label {
    color: #000;
    font-weight: 600;
}

/* Tooltip */
.otopist-swatch-item::before {
    content: attr(data-tooltip);
    position: absolute;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.otopist-swatch-item::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
    pointer-events: none;
}

/* Tooltip positions */
/* Top */
.otopist-swatch-item[data-tooltip]::before {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
}

.otopist-swatch-item[data-tooltip]::after {
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* Show tooltip on hover */
.otopist-swatch-item:hover::before,
.otopist-swatch-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Disabled/out of stock state */
.otopist-swatch-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.otopist-swatch-item.disabled:hover {
    transform: none;
}

.otopist-swatch-item.disabled .otopist-swatch {
    filter: grayscale(100%);
}

/* Out of stock overlay */
.otopist-swatch-item.out-of-stock .otopist-swatch::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #d00;
    transform: translateY(-50%) rotate(-45deg);
}

/* Hidden select (for WooCommerce compatibility) */
.otopist-hidden-select {
    display: none !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .otopist-swatches-container {
        gap: 10px;
    }
    
    .otopist-swatch-item::before {
        font-size: 11px;
        padding: 4px 8px;
    }
}

/* Animation for selection */
@keyframes otopist-swatch-select {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.otopist-swatch-item.selecting .otopist-swatch {
    animation: otopist-swatch-select 0.3s ease;
}

/* Loading state */
.otopist-swatches-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Variation description */
.woocommerce-variation-description {
    margin-top: 15px;
}

/* Reset table */
.reset_variations {
    margin-top: 10px;
}

/* Clear button styling */
.reset_variations {
    font-size: 12px;
    text-decoration: underline;
}

/* Gradient examples for reference */
/* Two colors gradient */
.otopist-gradient-two {
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
}

/* Three colors gradient */
.otopist-gradient-three {
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #4ecdc4);
}

/* Accessibility */
.otopist-swatch-item:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.otopist-swatch-item:focus:not(:focus-visible) {
    outline: none;
}

