/* =================================================================
   Aivaro Switcher - Stock Indicator & Price Surcharge Styles
   ================================================================= */

/* --- Base swatch block sizing (text swatches) --- */
.swatch-attribute .swatch-option.text {
    min-width: 36px;
    height: auto;
    min-height: 30px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-width: 2px;
    border-style: solid;
    border-radius: 3px;
    cursor: pointer;
    margin: 2px;
    transition: border-color 0.15s, background-color 0.15s;
    box-sizing: border-box;
}

/* Wider swatches when showing price delta */
.swatch-option.text.has-price-delta {
    min-width: 70px;
    padding: 4px 6px;
}

/* --- In Stock --- */
.swatch-option.stock-available {
    border-color: #80cc28 !important;
    background-color: #EBFBEB !important;
}

.swatch-option.text.stock-available {
    color: #2d5a2d !important;
}

/* --- Out of Stock --- */
.swatch-option.stock-unavailable {
    border-color: #FF8080 !important;
    background-color: #FFD9D9 !important;
}

.swatch-option.text.stock-unavailable {
    color: #8b2635 !important;
}

/* --- Selected states --- */
.swatch-option.selected.stock-available {
    border-color: #80cc28 !important;
    background-color: #d4f5d4 !important;
    font-weight: bold !important;
}

.swatch-option.selected.stock-unavailable {
    border-color: #c04040 !important;
    background-color: #ffe0e0 !important;
    font-weight: bold !important;
}

/* --- Hover effects --- */
.swatch-option.stock-available:hover {
    border-color: #80cc28 !important;
    background-color: #d4f5d4 !important;
}

.swatch-option.stock-unavailable:hover {
    border-color: #e06060 !important;
    background-color: #ffe0e0 !important;
}

/* --- Color swatch specifics (non-text) --- */
.swatch-option.color.stock-available {
    border: 3px solid #80cc28 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.swatch-option.color.stock-unavailable {
    border: 3px solid #FF8080 !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
    opacity: 0.7;
}

.swatch-option.color.selected.stock-available,
.swatch-option.color.selected.stock-unavailable {
    border: 3px solid #444 !important;
    opacity: 1;
}

/* --- Price surcharge --- */
.aivaro-price-delta {
    display: block;
    font-size: 10px;
    font-weight: normal;
    margin-top: 1px;
    white-space: nowrap;
    line-height: 1.2;
}

.stock-available .aivaro-price-delta {
    color: #2d5a2d;
}

.stock-unavailable .aivaro-price-delta {
    color: #8b4040;
}

/* --- Stock legend --- */
.aivaro-stock-legend {
    margin: 10px 0 5px;
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}

.aivaro-stock-legend .legend-item {
    display: inline-block;
    margin-right: 20px;
}

.aivaro-stock-legend .legend-in-stock {
    color: #80cc28;
}

.aivaro-stock-legend .legend-out-of-stock {
    color: #c04040;
}

.aivaro-stock-legend .legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 3px;
    border: 2px solid;
}

.aivaro-stock-legend .legend-in-stock .legend-swatch {
    border-color: #80cc28;
    background-color: #EBFBEB;
}

.aivaro-stock-legend .legend-out-of-stock .legend-swatch {
    border-color: #FF8080;
    background-color: #FFD9D9;
}

/* --- Porto theme compatibility --- */
.product-info-main .swatch-attribute .swatch-option.stock-available {
    border-color: #80cc28 !important;
    background-color: #EBFBEB !important;
}

.product-info-main .swatch-attribute .swatch-option.stock-unavailable {
    border-color: #FF8080 !important;
    background-color: #FFD9D9 !important;
}

/* Override Porto's default disabled styling */
.product-info-main .swatch-option.stock-unavailable.disabled:after {
    display: none;
}

/* --- Responsive --- */
@media (max-width: 767px) {
    .swatch-attribute .swatch-option.text {
        min-width: 32px;
        min-height: 28px;
        padding: 3px 6px;
        font-size: 11px;
        margin: 2px;
    }

    .swatch-option.text.has-price-delta {
        min-width: 60px;
    }

    .aivaro-price-delta {
        font-size: 9px;
    }

    .aivaro-stock-legend .legend-item {
        margin-right: 12px;
    }
}

/* --- Accessibility --- */
.swatch-option.stock-available:focus,
.swatch-option.stock-unavailable:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .swatch-option.stock-available,
    .swatch-option.stock-unavailable {
        transition: none !important;
    }
}
