/**
 * Soda Form Image Fields Styles
 * Styling for radio buttons and checkboxes with images
 */

/* Container Layouts */
.soda-image-field-options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
}

.soda-image-field-options.layout-horizontal {
    flex-direction: row;
}

.soda-image-field-options.layout-vertical {
    flex-direction: column;
}

.soda-image-field-options.layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--image-size, 100px), 1fr));
}

/* Individual Option */
.soda-image-field-option {
    position: relative;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Hide native input */
.soda-image-field-option input[type="radio"],
.soda-image-field-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Label Container */
.soda-image-field-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.soda-image-field-option label:hover {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Images */
.soda-image-field-option img {
    width: var(--image-size, 100px);
    height: var(--image-size, 100px);
    object-fit: cover;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* Option Label Text */
.soda-image-field-option .option-label {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: #333;
    line-height: 1.4;
    transition: color 0.3s ease;
}

/* Selected State */
.soda-image-field-option input:checked + label {
    border-color: #0073aa;
    background: #f0f8ff;
    box-shadow: 0 0 0 1px #0073aa;
}

.soda-image-field-option input:checked + label .option-label {
    color: #0073aa;
    font-weight: 600;
}

.soda-image-field-option input:checked + label img {
    transform: scale(1.05);
}

/* Selected Visual Indicator */
.soda-image-field-option input:checked + label::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #0073aa;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Focus State */
.soda-image-field-option input:focus + label {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Disabled State */
.soda-image-field-option input:disabled + label {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Hide labels when show_labels is off */
.soda-image-field-options[data-show-labels="false"] .option-label {
    display: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .soda-image-field-options.layout-horizontal {
        flex-direction: column;
    }
    
    .soda-image-field-options.layout-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .soda-image-field-option img {
        width: 80px;
        height: 80px;
    }
    
    .soda-image-field-option .option-label {
        font-size: 12px;
    }
}

/* Animation for selection */
@keyframes checkmark {
    0% {
        transform: scale(0) rotate(0deg);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

.soda-image-field-option input:checked + label::after {
    animation: checkmark 0.4s ease;
}

/* Error State */
.elementor-field-group.error .soda-image-field-options {
    border: 1px solid #d9534f;
    padding: 10px;
    border-radius: 4px;
}

.elementor-field-group.error .soda-image-field-option label {
    border-color: #d9534f;
}

/* Loading State */
.soda-image-field-option img[src=""] {
    background: #f0f0f0;
    position: relative;
}

.soda-image-field-option img[src=""]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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