/**
 * OptionBay - Product Options and Addons Frontend Styles
 *
 * Minimal CSS for the product page option fields.
 * Uses CSS variables for easy customization.
 *
 * @since 1.0.0
 */

/* ─── Variables & Wrapper ─────────────────────────────────────────── */
.opopw-options-wrapper {
    /* Colors */
    --opopw-primary: #007cba;
    --opopw-success: #77a464;
    --opopw-error: #e2401c;
    --opopw-border: #ddd;
    --opopw-border-light: #e5e5e5;
    --opopw-text-main: #444;
    --opopw-text-muted: #666;
    --opopw-text-light: #999;
    --opopw-bg: #fff;
    --opopw-bg-alt: #f7f7f7;
    --opopw-bg-placeholder: #f0f0f1;
    
    /* Shapes & Shadows */
    --opopw-radius: 4px;
    --opopw-radius-swatch: 8px;
    --opopw-shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --opopw-shadow-focus: 0 0 0 1px var(--opopw-primary);
    --opopw-shadow-swatch-checked: 0 0 0 2px rgba(0, 124, 186, 0.2), 0 1px 3px rgba(0,0,0,0.1);
    
    /* Sizes */
    --opopw-swatch-size: 32px;
    --opopw-swatch-image-size: 64px;
    --opopw-swatch-radius: 4px;
    --opopw-swatch-image-radius: 4px;
    
    /* Layout Spacing */
    --opopw-gap-group: 20px;
    --opopw-gap-field: 24px;
    --opopw-gap-option: 8px;
    --opopw-gap-swatch: 12px;

    /* Typography */
    --opopw-font-size-title: inherit;
    --opopw-font-size-label: inherit;
    --opopw-font-size-input: inherit;
    --opopw-font-size-description: inherit;
    --opopw-font-size-total: inherit;
    --opopw-font-size-swatch: inherit;

    margin: 16px 0;
    padding: 0;
}

/* ─── Group ────────────────────────────────────────────────────────── */
.opopw-group {
    margin-bottom: var(--opopw-gap-group);
}

.opopw-group__title {
    font-size: var(--opopw-font-size-title);
    font-weight: 600;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--opopw-border-light);
    color: var(--opopw-text-main);
}

/* ─── Field Wrapper ────────────────────────────────────────────────── */
.opopw-field {
    margin-bottom: var(--opopw-gap-field);
}

.opopw-field.opopw-hidden {
    display: none;
}

/* ─── Label ────────────────────────────────────────────────────────── */
.opopw-field__label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: var(--opopw-font-size-label);
    color: var(--opopw-text-main);
}

.opopw-required {
    color: var(--opopw-error);
    font-weight: 700;
    text-decoration: none;
    border: none;
}

/* ─── Inputs ───────────────────────────────────────────────────────── */
.opopw-input {
    width: 100%;
    box-sizing: border-box;
}

.opopw-input--text,
.opopw-input--email,
.opopw-input--textarea,
.opopw-input--number,
.opopw-input--select {
    padding: 8px 12px;
    border: 1px solid var(--opopw-border);
    border-radius: var(--opopw-radius);
    font-size: var(--opopw-font-size-input);
    line-height: 1.5;
    background: var(--opopw-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    color: var(--opopw-text-main);
}

.opopw-input--text:focus,
.opopw-input--email:focus,
.opopw-input--textarea:focus,
.opopw-input--number:focus,
.opopw-input--select:focus {
    border-color: var(--opopw-primary);
    outline: none;
    box-shadow: var(--opopw-shadow-focus);
}

.opopw-input--textarea {
    resize: vertical;
    min-height: 80px;
}

.opopw-input--number {
    width: auto;
    min-width: 100px;
}

.opopw-input--file {
    padding: 6px 0;
}

/* ─── Radio & Checkbox Groups ─────────────────────────────────────── */
.opopw-radio-group,
.opopw-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Horizontal Orientation */
[data-orientation="horizontal"] .opopw-radio-group,
[data-orientation="horizontal"] .opopw-checkbox-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.opopw-radio-option,
.opopw-checkbox-option,
.opopw-checkbox-single {
    display: flex;
    align-items: center;
    gap: var(--opopw-gap-option);
    cursor: pointer;
    font-size: var(--opopw-font-size-input);
    color: var(--opopw-text-main);
}

.opopw-radio-option.opopw-option-disabled,
.opopw-checkbox-option.opopw-option-disabled,
.opopw-checkbox-single.opopw-option-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    color: var(--opopw-text-light);
}

.opopw-radio-option input,
.opopw-checkbox-option input,
.opopw-checkbox-single input {
    width: 1.2em;
    height: 1.2em;
    margin: 0;
    flex-shrink: 0;
}
.opopw-radio-option input:focus,
.opopw-checkbox-option input:focus,
.opopw-checkbox-single input:focus {
    outline: none;
}

/* ─── Description ──────────────────────────────────────────────────── */
.opopw-field__description {
    margin: 4px 0 0;
    font-size: var(--opopw-font-size-description);
    color: var(--opopw-text-muted);
    line-height: 1.4;
}


.opopw-field__file-info {
    margin: 4px 0 0;
    font-size: var(--opopw-font-size-description);
    color: var(--opopw-text-light);
}

/* ─── Live Pricing ─────────────────────────────────────────────────── */
.opopw-live-total {
    margin-top: var(--opopw-gap-field);
    padding: 10px 14px;
    background: var(--opopw-bg-alt);
    border: 1px solid var(--opopw-border-light);
    border-radius: var(--opopw-radius);
    font-size: var(--opopw-font-size-total);
    color: var(--opopw-text-main);
}

.opopw-total-label {
    font-weight: 600;
}

.opopw-live-total .amount {
    font-weight: 700;
    color: var(--opopw-success);
}

.opopw-price-adjustment {
    font-size: 0.9em;
    color: var(--opopw-success);
    font-weight: 500;
    margin-left: 2px;
}

.opopw-btn-disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* ─── Stock Badges ─────────────────────────────────────────────────── */
.opopw-stock-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    margin-left: 6px;
    vertical-align: middle;
}

.opopw-stock-badge.out-of-stock {
    background: #fff5f5;
    color: var(--opopw-error);
    border: 1px solid #fed7d7;
}

.opopw-stock-badge.low-stock {
    background: #fffaf0;
    color: #c05621;
    border: 1px solid #feebc8;
}

/* ─── Swatch Groups ────────────────────────────────────────────────── */
.opopw-swatch-group {
    display: flex;
    flex-direction: column;
    gap: var(--opopw-gap-swatch);
    margin-top: 4px;
}

/* Horizontal Orientation */
[data-orientation="horizontal"] .opopw-swatch-group,
.opopw-swatch-group[data-display-style="swatch_only"] {
    flex-direction: row !important;
    flex-wrap: wrap;
}

.opopw-swatch-option {
    position: relative;
}

.opopw-swatch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.opopw-swatch-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--opopw-gap-option);
    cursor: pointer;
    font-size: var(--opopw-font-size-swatch);
    margin: 0 !important;
}

.opopw-swatch-visual {
    width: var(--opopw-swatch-size, 32px);
    height: var(--opopw-swatch-size, 32px);
    border-radius: var(--opopw-swatch-radius, 4px);
    border: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--opopw-shadow-sm);
}

.opopw-swatch-group--image .opopw-swatch-visual {
    width: var(--opopw-swatch-image-size);
    height: var(--opopw-swatch-image-size);
    border-radius: var(--opopw-swatch-image-radius, 4px);
}

.opopw-swatch-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.opopw-swatch-visual .opopw-swatch-placeholder {
    background: var(--opopw-bg-placeholder);
    width: 100%;
    height: 100%;
}

.opopw-swatch-input:checked + .opopw-swatch-label .opopw-swatch-visual {
    border-color: var(--opopw-primary);
    box-shadow: var(--opopw-shadow-swatch-checked);
}

.opopw-swatch-check {
    position: absolute;
    width: var(--opopw-swatch-size, 32px);
    margin-left: 2px;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: rgba(0,0,0,0.15);
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.opopw-swatch-group--image .opopw-swatch-check{
    width: var(--opopw-swatch-image-size, 32px);
}

.opopw-swatch-check::after {
    content: '';
    width: 14px;
    height: 7px;
    border-left: 3px solid #fff;
    border-bottom: 3px solid #fff;
    transform: rotate(-45deg);
    margin-top: -4px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.opopw-swatch-input:checked + .opopw-swatch-label .opopw-swatch-check {
    opacity: 1;
}

.opopw-swatch-text {
    font-weight: 500;
    color: var(--opopw-text-main);
}

.opopw-swatch-visual:hover {
    border-color: var(--opopw-primary);
}

/* Disabled/Out of Stock Swatches */
.opopw-option-disabled .opopw-swatch-visual {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--opopw-bg-placeholder);
    position: relative;
}

.opopw-option-disabled .opopw-swatch-visual::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -10%;
    width: 120%;
    height: 2px;
    background: #ff0000;
    transform: rotate(-45deg);
    opacity: 0.6;
    pointer-events: none;
}

.opopw-option-disabled .opopw-swatch-text {
    color: var(--opopw-text-light);
    text-decoration: line-through;
}

/* ─── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .opopw-radio-group,
    .opopw-checkbox-group {
        gap: 8px;
    }
}

/* ─── Image Swap Transition ────────────────────────────────────────── */
.woocommerce-product-gallery__image img:not(.zoomImg) {
    transition: opacity 0.2s ease-in-out;
}
.woocommerce-product-gallery__image img.opopw-image-swapping {
    opacity: 0.2;
}

/* ─── Custom Gallery Thumbnails ────────────────────────────────────── */
.opopw-custom-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 0;
    list-style: none;
}

.opopw-custom-thumbs li {
    width: 60px;
    height: 60px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: var(--opopw-radius);
    overflow: hidden;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.opopw-custom-thumbs li:hover {
    transform: scale(1.05);
}

.opopw-custom-thumbs li.active {
    border-color: var(--opopw-primary);
}

.opopw-custom-thumbs li img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
