/**
 * WPCVS Dual Selection Styles
 * Styles for dropdown + grid dual selection interface
 */

/* Main wrapper */
.wpcvs-dual-selection .wpcvs-dual-attribute {
    margin-bottom: 20px;
}

.wpcvs-dual-selection .wpcvs-dual-value {
    display: flex;
    flex-direction: column;
}

/* Custom Dropdown with Images/Colors */
.wpcvs-dual-dropdown-wrapper {
    width: 100%;
    position: relative;
    z-index: 1;
}

.wpcvs-dual-dropdown-hidden {
    display: none !important;
}

.wpcvs-dual-dropdown-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.wpcvs-custom-dropdown {
    position: relative;
    width: 100%;
    z-index: 10;
    cursor: pointer;
}

.wpcvs-custom-dropdown-selected {
    width: 100%;
    padding: 0 10px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    line-height: 1.5;
    background-color: transparent;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    position: relative;
    z-index: 1;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
    border: 1px solid;
    border-radius: 10px;
    margin-top: 9px;
}

.wpcvs-custom-dropdown-selected:hover {
    border-color: #999;
}

.wpcvs-custom-dropdown.active .wpcvs-custom-dropdown-selected {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.wpcvs-custom-dropdown-text {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    color: #333;
}

.wpcvs-dropdown-color-preview,
.wpcvs-dropdown-image-preview {
    display: inline-block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.wpcvs-dropdown-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.wpcvs-dropdown-name {
    flex: 1;
}

.wpcvs-custom-dropdown-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 10px;
}

.wpcvs-custom-dropdown.active .wpcvs-custom-dropdown-arrow {
    transform: rotate(180deg);
}

.wpcvs-custom-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1002 !important;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: -1px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: auto;
}

.wpcvs-custom-dropdown.active .wpcvs-custom-dropdown-options {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.wpcvs-custom-dropdown-option {
    padding: 10px 12px;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.wpcvs-custom-dropdown-option:last-child {
    border-bottom: none;
}

.wpcvs-custom-dropdown-option:hover {
    background-color: #f5f5f5;
}

.wpcvs-custom-dropdown-option.selected {
    background-color: #e8f4f8;
    font-weight: 600;
}

.wpcvs-dropdown-option-color {
    display: inline-block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.wpcvs-dropdown-option-image {
    display: inline-block;
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.wpcvs-dropdown-option-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpcvs-dropdown-option-text {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
    text-align: center;
    padding: 2px;
    word-break: break-word;
}

.wpcvs-dropdown-option-name {
    flex: 1;
    color: #333;
    font-size: 16px;
}

/* Grid wrapper - Hidden by default */
/**
.wpcvs-dual-grid-wrapper.wpcvs-dual-grid-collapsed {
    display: none;
}
*/
.wpcvs-dual-grid {
    display: grid;
    // grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 10px;
    margin-top: 10px;
}

/* Grid item */
.wpcvs-dual-grid-item {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 8px;
    background: transparent;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
//    overflow: hidden;
}
/**
.wpcvs-dual-grid-item:hover {
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
*/

.wpcvs-dual-grid-item.wpcvs-dual-grid-selected {
    border: 1.4px solid #000000;
    background-color: #000000;
//    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.wpcvs-dual-grid-item.wpcvs-dual-grid-selected::after {
    content: "✓";
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background-color: #0073aa;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
}

.wpcvs-dual-grid-item.wpcvs-dual-grid-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.wpcvs-dual-grid-item.wpcvs-dual-grid-item-hidden {
    display: none;
}

/* Grid item inner */
.wpcvs-dual-grid-item-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Color swatch */
.wpcvs-dual-grid-color {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid #ddd;
    display: block;
    margin: 0 auto;
}

/* Image swatch */
.wpcvs-dual-grid-image {
    width: 86px;
    height: 86px;
    border-radius: 4px;
    overflow: hidden;
    display: block;
    margin: 0 auto;
}

.wpcvs-dual-grid-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Text swatch */
.wpcvs-dual-grid-text {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    margin: 0 auto;
    padding: 4px;
    text-align: center;
    word-break: break-word;
}

/* Label below swatch */
.wpcvs-dual-grid-label {
    font-size: 12px;
    color: #333;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

.wpcvs-dual-grid-item.wpcvs-dual-grid-selected .wpcvs-dual-grid-label {
    color: #0073aa;
    font-weight: 600;
}

/* Accordion Toggle Button */
.wpcvs-dual-accordion-toggle {
    display: inline-block;
    margin: 10px;
    padding: 10px 0;
    background-color: transparent;
    border: none !important;
    outline: none !important;
    border-bottom: 1.5px solid black !important;
    border-radius: 0;
    box-shadow: none;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    text-align: left;
    max-width: 200px;
    min-width: 113px;
    position: relative;
    pointer-events: auto;
}

.wpcvs-dual-accordion-toggle:hover {
    background: none !important;
    background-color: transparent;
    color: black !important;
}

.wpcvs-dual-accordion-toggle:focus {
    outline: none;
    box-shadow: none;
    background-color: transparent;
    color: black;
}

.wpcvs-dual-accordion-toggle::after {
    content: "▼";
    position: absolute;
    right: 0px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    transition: transform 0.3s ease;
}

.wpcvs-dual-accordion-toggle[aria-expanded="true"]::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Show More button within grid */
.wpcvs-dual-show-more {
    display: inline-block;
    padding: 8px 16px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    text-align: center;
    width: 100%;
}

.wpcvs-dual-show-more:hover {
    background-color: #e5e5e5;
    border-color: #999;
}

.wpcvs-dual-show-more:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Hidden grid items */
.wpcvs-dual-grid-item-hidden {
    display: none !important;
}

/* Clear button wrapper */
.wpcvs-dual-clear-wrapper {
    margin-top: 0px;
    text-align: right;
}

.wpcvs-dual-clear-wrapper .reset_variations {
    color: #666;
    text-decoration: underline;
    font-size: 13px;
}

.wpcvs-dual-clear-wrapper .reset_variations:hover {
    color: #000;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wpcvs-dual-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 10px;
    }
    
    .wpcvs-dual-grid-color,
    .wpcvs-dual-grid-image,
    .wpcvs-dual-grid-text {
        width: 45px;
        height: 45px;
    }
    
    .wpcvs-dual-grid-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .wpcvs-dual-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    .wpcvs-dual-grid-color,
    .wpcvs-dual-grid-image,
    .wpcvs-dual-grid-text {
        width: 40px;
        height: 40px;
    }
}

/* Stacked layout adjustments */
.wpcvs-attributes-stacked .wpcvs-dual-attribute {
    margin-bottom: 25px;
}

.wpcvs-attributes-stacked .wpcvs-attribute-label {
    margin-bottom: 10px;
}

.wpcvs-attributes-stacked .wpcvs-attribute-selected {
    font-weight: 600;
    color: #0073aa;
    margin-left: 8px;
}

span.wpcvs-dropdown-name {
    font-size: 16px;
}
