/* Taxonomy Dropdown & Swatches - Frontend Styles */

.tds-frontend-container {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
}

/* Step wrappers and labels */
.tds-step {
    transition: opacity 0.35s ease, max-height 0.4s ease-out;
    max-height: 800px;
    overflow: visible;
}

.tds-step-label {
    font-weight: 600;
    font-size: 1em;
    margin: 0 0 10px 0;
    color: #333;
}

.tds-step-hidden {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
    visibility: hidden;
}

.tds-step-hidden .tds-step-label {
    margin: 0;
}

.tds-taxonomy-dropdown {
    margin: 15px 0;
    padding: 10px;
    background: none;
    border: none;
}

.tds-taxonomy-swatches {
    margin: 15px 0;
    padding: 10px;
    background: none;
    border: none;
}

/* Debug styles */
.tds-debug {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 10px;
    margin: 10px 0;
    border-radius: 3px;
    font-size: 12px;
}

.tds-taxonomy-dropdown label,
.tds-taxonomy-swatches label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.tds-taxonomy-select {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    font-size: 14px;
}

.tds-taxonomy-select:focus {
    border-color: #000000;
    outline: none;
    box-shadow: 0 0 0 1px #000000;
}

/* Select2 styling for taxonomy dropdowns */
.select2-container--default .select2-selection--single {
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-left: 12px;
    padding-right: 20px;
    color: #333;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
    right: 8px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #000000;
    outline: none;
    box-shadow: 0 0 0 1px #000000;
}

.select2-dropdown {
    border: 1px solid #ddd;
    border-radius: 3px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 8px 12px;
    font-size: 14px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #000000;
    color: white;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #f0f0f0;
    color: #333;
}

/* Ensure Select2 dropdowns are responsive */
.select2-container {
    width: 100% !important;
    max-width: 300px;
}

.tds-frontend-container {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.tds-taxonomy-dropdown {
    margin: 15px 0;
    padding: 10px;
    background: none;
    border: none;
}

.tds-taxonomy-swatches {
    margin: 15px 0;
    padding: 10px;
    background: none;
    border: none;
}

/* Swatches Container */
.tds-swatches-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
form.cart{
    flex-wrap:wrap !important;
}
.select2-selection__arrow{
    top:10px !important;
}
.tds-swatch {
    display: inline-block;
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    width: 75px;
    height: 75px;
    background: white;
    padding: 5px;
}

.tds-swatch:hover {
    border-color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tds-swatch.tds-swatch-active {
    border-color: #000000;
    background-color: #000000aa;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tds-swatch.tds-swatch-hover {
    border-color: #000000;
    transform: translateY(-1px);
}

/* Color Swatches */
.tds-color-swatch {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: block;
    transition: all 0.3s ease;
    position: relative;
}
form .select2-selection{
    height:auto !important;
}

/* Image Swatches */
.tds-image-swatch {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Hide labels for image and color swatches */
.tds-swatch:not(.tds-swatch-text) .tds-swatch-label {
    display: none;
}
.tds-color-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.tds-swatch.tds-swatch-active .tds-color-swatch::after {
    width: 20px;
    height: 20px;
}

.tds-swatch.tds-swatch-active .tds-color-swatch::before {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000000;
    font-weight: bold;
    font-size: 14px;
    z-index: 1;
}

/* Image Swatches */
.tds-swatch img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    object-position: center center;
}

.tds-swatch.tds-swatch-active img {
    opacity: 0.7;
}

.tds-swatch.tds-swatch-active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    z-index: 1;
}

/* Text Swatches */
.tds-text-swatch {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 3px;
    background: #f9f9f9;
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    min-width: 60px;
    transition: all 0.3s ease;
}

.tds-swatch.tds-swatch-active .tds-text-swatch {
    background: #000000aa;
    color: white;
    border-color: #000000;
}

/* Loading States */
.tds-swatch.tds-swatch-loading {
    opacity: 0.6;
    pointer-events: none;
}

.tds-swatch.tds-swatch-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #000000;
    border-radius: 50%;
    animation: tds-spin 1s linear infinite;
}

@keyframes tds-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Error States */
.tds-swatch.tds-swatch-error {
    border-color: #dc3232;
    background-color: #fbeaea;
}

.tds-swatch.tds-swatch-error::after {
    content: '!';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #dc3232;
    font-weight: bold;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tds-swatches-container {
        gap: 8px;
    }
    
    .tds-color-swatch,
    .tds-swatch img {
        width: 35px;
        height: 35px;
    }
    
    .tds-text-swatch {
        padding: 6px 10px;
        font-size: 11px;
        min-width: 50px;
    }
    
    .tds-taxonomy-dropdown,
    .tds-taxonomy-swatches {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .tds-swatches-container {
        gap: 6px;
    }
    
    .tds-color-swatch,
    .tds-swatch img {
        width: 30px;
        height: 30px;
    }
    
    .tds-text-swatch {
        padding: 4px 8px;
        font-size: 10px;
        min-width: 40px;
    }
}

/* Accessibility */
.tds-swatch:focus {
    outline: none;
}

.tds-swatch[aria-pressed="true"] {
    border-color: #FFBD59;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tds-swatch {
        border-width: 3px;
    }
    
    .tds-swatch.tds-swatch-active {
        border-color: #000;
        background-color: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tds-swatch,
    .tds-color-swatch,
    .tds-text-swatch {
        transition: none;
    }
    
    .tds-swatch:hover {
        transform: none;
    }
}

/* Variation Gallery Images */
.tds-variation-gallery-images {
    margin-top: 10px;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 0;
    position: relative;
    z-index: 999;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    clear: both;
}

.tds-variation-gallery-images h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.tds-variation-gallery-thumbnails {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 1000;
}

.tds-gallery-thumbnail {
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 3px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    display: inline-block;
    margin-right: 5px;
    margin-bottom: 5px;
}

.tds-gallery-thumbnail:hover {
    border-color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tds-gallery-thumbnail.tds-active {
    border-color: #000000;
    background: #000000aa;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tds-gallery-thumbnail img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    display: block;
}

.tds-gallery-thumbnail .tds-thumbnail-label {
    padding: 5px;
    background: white;
    font-size: 11px;
    text-align: center;
    color: #666;
    font-weight: 500;
}

.tds-gallery-thumbnail.tds-active .tds-thumbnail-label {
    color: white;
    background: transparent;
}

/* Responsive gallery thumbnails */
@media (max-width: 768px) {
    .tds-variation-gallery-thumbnails {
        gap: 8px;
    }
    
    .tds-gallery-thumbnail img {
        width: 50px;
        height: 50px;
    }
    
    .tds-gallery-thumbnail .tds-thumbnail-label {
        font-size: 10px;
        padding: 3px;
    }
}
