/**
 * Image Select Component Styles
 */

.tpo-field-image_select {
    margin-bottom: 20px;
}

.tpo-field-image_select label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.tpo-field-image_select .required {
    color: #e2401c;
}

/* Hidden native select */
.tpo-image-select-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* Custom Dropdown Container */
.tpo-image-select-custom-dropdown {
    position: relative;
    width: 100%;
}

/* Dropdown Trigger */
.tpo-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.tpo-dropdown-trigger:hover {
    border-color: #007cba;
}

.tpo-dropdown-trigger:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

.tpo-dropdown-selected {
    display: flex;
    align-items: center;
    flex: 1;
}

.tpo-dropdown-selected img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

.tpo-dropdown-text {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.tpo-dropdown-price {
    font-size: 12px;
    color: #96588a;
    font-weight: 500;
    margin-left: 8px;
}

.tpo-dropdown-placeholder {
    color: #999;
}

/* Dropdown option focus state for keyboard navigation */
.tpo-dropdown-option:focus {
    outline: none;
    background-color: #e8f4fc;
}

.tpo-dropdown-option:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

.tpo-dropdown-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.tpo-image-select-custom-dropdown.open .tpo-dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.tpo-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.tpo-image-select-custom-dropdown.open .tpo-dropdown-menu {
    display: block;
}

/* Dropdown Option */
.tpo-dropdown-option {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.tpo-dropdown-option:last-child {
    border-bottom: none;
}

.tpo-dropdown-option:hover {
    background-color: #f5f5f5;
}

.tpo-dropdown-option.selected {
    background-color: #e8f4fc;
}

.tpo-option-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

.tpo-option-image.tpo-image-small {
    width: 40px;
    height: 40px;
}

.tpo-option-image.tpo-image-medium {
    width: 50px;
    height: 50px;
}

.tpo-option-image.tpo-image-large {
    width: 70px;
    height: 70px;
}

.tpo-option-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tpo-option-label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.tpo-option-price {
    font-size: 12px;
    color: #96588a;
    font-weight: 500;
    margin-top: 2px;
}

/* 下拉选项中的价格样式 - 统一使用 tpo-field-price */
.tpo-dropdown-option .tpo-field-price {
    font-size: 12px;
    color: #96588a;
    font-weight: 500;
    margin-left: 8px;
}

/* Image Preview Container */
.tpo-image-preview-container {
    margin-top: 15px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    text-align: center;
}

.tpo-image-preview {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tpo-image-preview.tpo-image-small {
    max-width: 100px;
}

.tpo-image-preview.tpo-image-medium {
    max-width: 150px;
}

.tpo-image-preview.tpo-image-large {
    max-width: 200px;
}

/* Grid Layout */
.tpo-image-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

/* List Layout */
.tpo-image-select-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Option Styles for Grid/List */
.tpo-image-select-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #fff;
}

.tpo-image-select-option:hover {
    border-color: #007cba;
}

.tpo-image-select-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.tpo-image-select-option:has(input[type="radio"]:checked) {
    border-color: #007cba;
    background-color: #f0f7fc;
}

.tpo-image-select-option img {
    width: 100%;
    height: auto;
    object-fit: contain;
    margin-bottom: 8px;
}

.tpo-image-select-label {
    font-size: 14px;
    text-align: center;
    color: #333;
}

.tpo-image-select-price {
    font-size: 12px;
    color: #e2401c;
    margin-top: 4px;
}

/* Description */
.tpo-field-image_select .tpo-field-description {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
}
