/**
 * Custom Swatches System - Stili CSS
 * Sistema personalizzato per sostituire TAWCVS
 */

/* Container principale degli swatches */
.meow-custom-swatches-wrapper {
    margin: 20px 0;
}

.meow-swatches-container {
    margin-bottom: 24px;
}

.meow-swatches-label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 12px;
    color: #333;
    display: block;
}

.meow-swatches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Stili base per tutti gli swatches */
.meow-swatch {
    position: relative;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    background: #fff;
    user-select: none;
    outline: none;
}

.meow-swatch:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
}

.meow-swatch.selected {
    border-color: #007cba;
    background-color: #f0f8ff;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.meow-swatch.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.meow-swatch.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Swatches di colore */
.meow-swatch-color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.meow-swatch.selected .meow-swatch-color {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3);
}

/* Swatches di immagine */
.meow-swatch-image {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid #e0e0e0;
}

.meow-swatch.selected .meow-swatch-image {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3);
}

/* Swatches di etichetta */
.meow-swatch-label {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #333;
    text-align: center;
    white-space: nowrap;
    min-width: 40px;
}

.meow-swatch.selected .meow-swatch-label {
    color: #007cba;
    font-weight: 600;
}

/* Tooltip */
.meow-swatch-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    margin-bottom: 8px;
}

.meow-swatch-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
}

.meow-swatch:hover .meow-swatch-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Indicatore di selezione */
.meow-swatch.selected::before {
    content: '✓';
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #007cba;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
}

/* Responsive Design */
@media (max-width: 768px) {
    .meow-swatches-list {
        gap: 6px;
    }
    
    .meow-swatch {
        min-width: 36px;
        min-height: 36px;
    }
    
    .meow-swatch-color {
        width: 28px;
        height: 28px;
    }
    
    .meow-swatch-image {
        width: 36px;
        height: 36px;
    }
    
    .meow-swatch-label {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .meow-swatches-list {
        gap: 4px;
    }
    
    .meow-swatch {
        min-width: 32px;
        min-height: 32px;
    }
    
    .meow-swatch-color {
        width: 24px;
        height: 24px;
    }
    
    .meow-swatch-image {
        width: 32px;
        height: 32px;
    }
    
    .meow-swatch-label {
        padding: 4px 8px;
        font-size: 10px;
    }
}

/* Animazioni */
@keyframes meow-swatch-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 124, 186, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 124, 186, 0);
    }
}

.meow-swatch.loading {
    animation: meow-swatch-pulse 1.5s infinite;
}

/* Stati speciali */
.meow-swatch.out-of-stock {
    opacity: 0.4;
    position: relative;
}

.meow-swatch.out-of-stock::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 2px;
    height: 100%;
    background: #ff0000;
    z-index: 5;
}

.meow-swatch.out-of-stock::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 2px;
    height: 100%;
    background: #ff0000;
    z-index: 5;
}

/* Integrazione con il tema esistente */
.woocommerce .meow-custom-swatches-wrapper {
    margin: 16px 0;
}

.woocommerce .meow-swatches-container {
    margin-bottom: 20px;
}

/* Layout 2 specifico */
.layout2 .meow-swatches-list {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.layout2 .meow-swatch {
    width: 100%;
    justify-content: flex-start;
    padding: 12px;
    min-height: 48px;
}

.layout2 .meow-swatch-color {
    width: 24px;
    height: 24px;
    margin-right: 12px;
}

.layout2 .meow-swatch-image {
    width: 32px;
    height: 32px;
    margin-right: 12px;
}

.layout2 .meow-swatch-label {
    font-size: 14px;
    padding: 0;
}

/* Quick View specifico */
.quick-view-wrapper .meow-custom-swatches-wrapper {
    margin: 12px 0;
}

.quick-view-wrapper .meow-swatches-list {
    gap: 6px;
}

.quick-view-wrapper .meow-swatch {
    min-width: 36px;
    min-height: 36px;
}

/* Accessibilità */
.meow-swatch:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.meow-swatch[aria-pressed="true"] {
    border-color: #007cba;
    background-color: #f0f8ff;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .meow-swatches-label {
        color: #fff;
    }
    
    .meow-swatch {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .meow-swatch-label {
        color: #fff;
    }
    
    .meow-swatch.selected {
        background-color: #1a3a5c;
    }
}

/* Print styles */
@media print {
    .meow-swatch {
        border: 1px solid #000;
        background: #fff !important;
    }
    
    .meow-swatch-color {
        border: 1px solid #000;
    }
    
    .meow-swatch-tooltip {
        display: none;
    }
}
