/**
 * Product Tones Frontend Styles
 * Styles for tone selection in product page
 */

/* Fix for product image gallery thumbnails */
#product-image-thumbs [data-swiper-slide-index] {
    transition: all 0.3s ease;
}

#product-image-thumbs [data-swiper-slide-index="1"] {
    /* Ensure slide 1 is always visible and clickable in thumbnails */
    pointer-events: auto !important;
}

/* Smooth transitions for main gallery */
.woocommerce-product-gallery__image {
    transition: opacity 0.3s ease;
}

/* Ensure variation images can change the main gallery */
.woocommerce-product-gallery__wrapper {
    /* Allow natural image swapping from WooCommerce */
}

.atlas-tone-selector-wrapper {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.atlas-tone-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Search Bar */
.atlas-tone-search-wrapper {
    margin-bottom: 15px;
    position: relative;
}

.atlas-tone-search-wrapper::before {
    content: "🔍";
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

.atlas-tone-search {
    width: 100%;
    padding: 12px 15px;
    padding-left: 45px;
    padding-right: 140px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.atlas-tone-search:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.1);
}

.atlas-tone-count {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #666;
    font-weight: 600;
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 12px;
    pointer-events: none;
}

/* Tones List */
.atlas-tones-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
}

/* Custom Scrollbar */
.atlas-tones-list::-webkit-scrollbar {
    width: 8px;
}

.atlas-tones-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.atlas-tones-list::-webkit-scrollbar-thumb {
    background: #2271b1;
    border-radius: 4px;
}

.atlas-tones-list::-webkit-scrollbar-thumb:hover {
    background: #135e96;
}

.atlas-tone-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.atlas-tone-option:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
    transform: translateY(-2px);
}

.atlas-tone-option.selected {
    border-color: #2271b1;
    background: #f0f6fc;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
}

/* Tone Image/Color */
.atlas-tone-image,
.atlas-tone-color,
.atlas-tone-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 10px;
    overflow: hidden;
    border: 2px solid #eee;
}

.atlas-tone-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.atlas-tone-color {
    border: 2px solid #ddd;
}

.atlas-tone-placeholder {
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.atlas-tone-placeholder svg {
    width: 100%;
    height: 100%;
    opacity: 0.4;
}

/* Tone Info */
.atlas-tone-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

.atlas-tone-code {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.atlas-tone-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
}

.atlas-tone-price {
    font-size: 16px;
    font-weight: 700;
    color: #2271b1;
}

/* Messages */
.atlas-tone-no-results,
.atlas-tone-error {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.atlas-tone-error {
    color: #d63638;
}

/* Responsive */
@media (max-width: 768px) {
    .atlas-tones-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .atlas-tone-option {
        padding: 10px;
    }

    .atlas-tone-image,
    .atlas-tone-color,
    .atlas-tone-placeholder {
        width: 50px;
        height: 50px;
    }

    .atlas-tone-name {
        font-size: 13px;
    }

    .atlas-tone-price {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .atlas-tones-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .atlas-tone-selector-wrapper {
        padding: 15px;
    }
}

/* Variation Price Override */
.single_variation .woocommerce-variation-price {
    margin-top: 15px;
}

.single_variation .atlas-tone-price {
    color: #666;
    font-size: 14px;
    font-style: italic;
}

/* Loading State */
.atlas-tone-selector-wrapper.loading {
    opacity: 0.6;
    pointer-events: none;
}

.atlas-tone-selector-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tone Gallery Slide Styles */
.atlas-tone-slide {
    background: #f8f9fa;
}

.atlas-tone-slide .atlas-tone-color-display {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.atlas-tone-slide .atlas-tone-color-display:hover {
    transform: scale(1.02);
}

/* Tone Thumbnail in Gallery */
.atlas-tone-thumb {
    position: relative;
}

.atlas-tone-thumb.swiper-slide-thumb-active {
    opacity: 1 !important;
    border: 2px solid #2271b1;
    border-radius: 4px;
}

.atlas-tone-thumb div {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Smooth transition for tone slide */
#product-image .atlas-tone-slide,
#product-image-thumbs .atlas-tone-thumb {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loader */
.atlas-tone-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.atlas-tone-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #666;
}

.atlas-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Variation Selector Loading State */
#variation-selector-button .variation-selector-content,
#variation-selector-button .variation-selector-arrow,
#variation-selector-button .variation-selector-loader {
    transition: opacity 0.2s ease;
}
