/**
 * ICW Extra Product Options - Frontend Styles
 * Updated: Table-like layout with inline color swatches
 */

/* Options container - Table layout */
.icw-epo-options {
    margin: 20px 0;
    border-top: 1px solid #e5e5e5;
}

/* Single option field - Table row style */
.icw-epo-field {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e5e5e5;
    padding: 0;
    min-height: 48px;
}

.icw-epo-field:last-child {
    border-bottom: none;
}

/* Label - Left column */
.icw-epo-label {
    width: 40%;
    min-width: 150px;
    padding: 12px 15px 12px 0;
    font-weight: 400;
    font-size: 14px;
    color: #1a1a1a;
    margin: 0;
    display: flex;
    align-items: center;
}

.icw-epo-label .required {
    color: #8b0000;
    margin-left: 3px;
}

.icw-epo-price-badge {
    font-weight: normal;
    color: #666;
    font-size: 0.85em;
    margin-left: 8px;
}

/* Description - Hide or show as tooltip */
.icw-epo-description {
    display: none;
}

/* Right column wrapper */
.icw-epo-field-input {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Input fields */
.icw-epo-input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-left: 1px solid #e5e5e5;
    font-size: 14px;
    background: transparent;
    text-align: left;
}

.icw-epo-input:focus {
    outline: none;
    background: #fafafa;
}

/* Select dropdown */
.icw-epo-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 15px center;
    padding-right: 40px;
    cursor: pointer;
}

.icw-epo-select:hover {
    background-color: #fafafa;
}

.icw-epo-textarea {
    min-height: 80px;
    resize: vertical;
    border: 1px solid #e5e5e5 !important;
    margin: 10px 0;
}

/* Custom Select with Color Swatches */
.icw-epo-custom-select {
    position: relative;
    flex: 1;
    border-left: 1px solid #e5e5e5;
}

.icw-epo-custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    cursor: pointer;
    min-height: 48px;
}

.icw-epo-custom-select-trigger:hover {
    background: #fafafa;
}

.icw-epo-select-value {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.icw-epo-select-placeholder {
    color: #666;
}

.icw-epo-select-arrow {
    width: 12px;
    height: 12px;
    color: #666;
    transition: transform 0.2s;
}

.icw-epo-custom-select.open .icw-epo-select-arrow {
    transform: rotate(180deg);
}

.icw-epo-custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: -1px;
    right: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-top: none;
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.icw-epo-custom-select.open .icw-epo-custom-select-dropdown {
    display: block;
}

.icw-epo-custom-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.15s;
}

.icw-epo-custom-option:hover {
    background: #f5f5f5;
}

.icw-epo-custom-option.selected {
    background: #f0f0f0;
}

.icw-epo-option-label {
    flex: 1;
    font-size: 14px;
}

.icw-epo-option-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.icw-epo-selected-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.icw-epo-selected-text {
    font-size: 14px;
    color: #1a1a1a;
}

/* Radio and Checkbox groups - Inline style */
.icw-epo-radio-group,
.icw-epo-checkbox-group {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-left: 1px solid #e5e5e5;
    padding: 5px 0;
}

.icw-epo-radio-label,
.icw-epo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 15px;
    border: none;
    border-radius: 0;
    transition: all 0.2s;
    font-size: 14px;
}

.icw-epo-radio-label:hover,
.icw-epo-checkbox-label:hover {
    background: #f5f5f5;
}

.icw-epo-radio,
.icw-epo-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #1a1a1a;
}

.icw-epo-radio-label input:checked+.icw-epo-radio-text,
.icw-epo-checkbox-label input:checked+.icw-epo-checkbox-text {
    font-weight: 500;
}

/* Color Swatches - Inline row */
.icw-epo-color-swatches {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-left: 1px solid #e5e5e5;
}

.icw-epo-color-swatch {
    cursor: pointer;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
}

.icw-epo-color-swatch:hover {
    background: #f5f5f5;
}

.icw-epo-color-swatch input {
    display: none;
}

.icw-epo-color-box {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    transition: all 0.2s;
}

.icw-epo-color-swatch input:checked+.icw-epo-color-box {
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #1a1a1a;
}

.icw-epo-color-label {
    font-size: 14px;
    color: #1a1a1a;
}

.icw-epo-color-swatch .icw-epo-price-badge {
    font-size: 12px;
    margin-left: auto;
}

/* Image Swatches - Grid style */
.icw-epo-image-swatches {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border-left: 1px solid #e5e5e5;
    padding: 10px 15px;
}

.icw-epo-image-swatch {
    cursor: pointer;
    text-align: center;
    max-width: 80px;
}

.icw-epo-image-swatch input {
    display: none;
}

.icw-epo-swatch-img {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 2px solid transparent;
    border-radius: 4px;
    margin: 0 auto 5px;
    transition: all 0.2s;
}

.icw-epo-image-swatch:hover .icw-epo-swatch-img {
    border-color: #ccc;
}

.icw-epo-image-swatch input:checked+.icw-epo-swatch-img {
    border-color: #1a1a1a;
}

.icw-epo-image-label {
    display: block;
    font-size: 11px;
    color: #666;
}

/* File Upload */
.icw-epo-file-wrapper {
    flex: 1;
    border-left: 1px solid #e5e5e5;
    padding: 10px 15px;
}

.icw-epo-file {
    padding: 12px;
    border: 1px dashed #ddd;
    border-radius: 4px;
    width: 100%;
    cursor: pointer;
    font-size: 13px;
}

.icw-epo-file:hover {
    border-color: #999;
}

.icw-epo-file-hint {
    margin-top: 5px;
    font-size: 11px;
    color: #999;
}

/* Number Input with +/- buttons */
.icw-epo-number-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    border-left: 1px solid #e5e5e5;
    padding: 0 15px;
}

.icw-epo-number-input-group {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
}

.icw-epo-number-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.15s;
}

.icw-epo-number-btn:hover {
    background: #e5e5e5;
    color: #1a1a1a;
}

.icw-epo-number {
    width: 60px;
    text-align: center;
    border: none;
    border-left: 1px solid #e5e5e5;
    border-right: 1px solid #e5e5e5;
    padding: 8px;
    font-size: 14px;
    appearance: textfield;
    -moz-appearance: textfield;
}

.icw-epo-number::-webkit-outer-spin-button,
.icw-epo-number::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.icw-epo-number-hint {
    margin-left: 15px;
    font-size: 12px;
    color: #999;
}

/* Validation errors */
.icw-epo-field.has-error {
    background: #fff5f5;
}

.icw-epo-field.has-error .icw-epo-label {
    color: #8b0000;
}

.icw-epo-error-message {
    color: #8b0000;
    font-size: 12px;
    padding: 5px 15px;
    width: 100%;
}

/* Hidden by conditional logic */
.icw-epo-field[style*="display: none"] {
    display: none !important;
}

/* Responsive */
@media (max-width: 767px) {
    .icw-epo-field {
        flex-direction: column;
        align-items: stretch;
    }

    .icw-epo-label {
        width: 100%;
        padding: 12px 15px;
        border-bottom: 1px solid #f0f0f0;
    }

    .icw-epo-input,
    .icw-epo-custom-select,
    .icw-epo-radio-group,
    .icw-epo-checkbox-group,
    .icw-epo-color-swatches,
    .icw-epo-image-swatches,
    .icw-epo-file-wrapper,
    .icw-epo-number-wrapper {
        border-left: none;
        width: 100%;
    }

    .icw-epo-color-swatches {
        flex-direction: column;
    }

    .icw-epo-color-swatch {
        width: 100%;
    }
}

/* Cart item options */
.icw-epo-item-meta {
    margin-top: 10px;
    font-size: 0.9em;
}

.icw-epo-item-meta li {
    margin-bottom: 3px;
}

/* Order item options */
.icw-epo-order-options {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}

.icw-epo-order-options p {
    margin: 5px 0;
    font-size: 0.9em;
}

.icw-epo-price {
    color: #666;
}

.icw-product-gallery-wrapper {
    padding: 0 !important;
}

.woocommerce .wp-block-woocommerce-product-image-gallery {
    width: 100%;
    text-align: center;
    align-items: center;
    justify-content: center;
    display: flex;
    max-width: 100%;
}

.woocommerce div.product div.images.woocommerce-product-gallery {
    margin-bottom: 0;
}