/**
 * Product Add-Ons Frontend Styles
 */

/* Main container */
.woo-adst-product-addons {
    display: block;
    clear: both;
    width: 100%;
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Ensure add-ons appear before add-to-cart button */
form.cart .woo-adst-product-addons {
    order: -1; /* For flex layouts */
    margin-bottom: 20px;
}

/* Force block display and full width */
.woo-adst-product-addons,
.woo-adst-addon {
    display: block !important;
    width: 100% !important;
    float: none !important;
}

/* Individual add-on */
.woo-adst-addon {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.woo-adst-addon:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Add-on label */
.woo-adst-addon .addon-label {
    display: block;
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    color: #333;
}

.woo-adst-addon .addon-label .required {
    color: #d63638;
    margin-left: 3px;
}

/* Add-on description */
.woo-adst-addon .addon-description {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 14px;
    font-style: italic;
}

/* Add-on selection info */
.woo-adst-addon .addon-selection-info {
    margin: 0 0 12px 0;
    padding: 8px 12px;
    background: #e7f3ff;
    border-left: 3px solid #2271b1;
    color: #333;
    font-size: 13px;
    border-radius: 3px;
}

.woo-adst-addon .addon-selection-info strong {
    color: #2271b1;
    font-weight: 600;
}

/* Select dropdown */
.woo-adst-addon select.addon-select {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
}

.woo-adst-addon select.addon-select:focus {
    outline: none;
    border-color: #999;
}

/* Options container */
.addon-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Individual option */
.addon-option {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.addon-option:hover {
    border-color: #999;
    background: #f9f9f9;
}

.addon-option input[type="radio"],
.addon-option input[type="checkbox"] {
    margin: 0 10px 0 0;
    cursor: pointer;
}

/* Selected state */
.addon-option:has(input:checked) {
    border-color: #2271b1;
    background: #f0f6fc;
}

/* Option image */
.addon-option-image {
    margin-right: 10px;
    flex-shrink: 0;
}

.addon-option-image img {
    display: block;
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* Option label and price */
.addon-option-label {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.addon-option-price {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

/* Radio buttons specific */
.addon-radio .addon-option {
    flex-direction: row;
}

/* Checkboxes specific */
.addon-checkbox .addon-option {
    flex-direction: row;
}

/* Disabled checkbox state */
.addon-checkbox .addon-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.addon-checkbox .addon-option.disabled:hover {
    border-color: #ddd;
    background: #f5f5f5;
}

.addon-checkbox .addon-option input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

/* Sold out option state */
.addon-option.sold-out {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #ccc;
}

.addon-option.sold-out:hover {
    border-color: #ccc;
    background: #f5f5f5;
}

.addon-option.sold-out input[type="radio"]:disabled,
.addon-option.sold-out input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.addon-option.sold-out .addon-option-image {
    opacity: 0.5;
    filter: grayscale(100%);
}

.addon-sold-out-badge {
    color: #d63638;
    font-weight: 600;
    font-size: 12px;
}

/* Sold out in select dropdown */
select.addon-select option:disabled {
    color: #999;
    font-style: italic;
}

/* Error state */
.woo-adst-addon.addon-error {
    border: 2px solid #d63638;
    padding: 15px;
    border-radius: 4px;
    background: #fff5f5;
}

.woo-adst-addon.addon-error .addon-label {
    color: #d63638;
}

/* Error messages */
.woo-adst-addon-errors {
    margin: 0 0 20px 0;
    padding: 15px;
    background: #fff5f5;
    border-left: 4px solid #d63638;
    border-radius: 3px;
}

.woo-adst-addon-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.woo-adst-addon-errors li {
    margin: 5px 0;
    color: #d63638;
    font-weight: 600;
}

.woo-adst-addon-errors li:before {
    content: "⚠ ";
    margin-right: 5px;
}

/* Responsive design */
@media screen and (max-width: 768px) {
    .woo-adst-product-addons {
        padding: 15px;
    }
    
    .addon-options {
        flex-direction: column;
    }
    
    .addon-option {
        width: 100%;
        min-width: auto;
    }
    
    .woo-adst-addon select.addon-select {
        max-width: 100%;
    }
}

@media screen and (max-width: 480px) {
    .addon-option-image img {
        width: 40px;
        height: 40px;
    }
    
    .addon-option {
        padding: 10px;
    }
    
    .addon-option-label {
        font-size: 13px;
    }
    
    .addon-option-price {
        font-size: 12px;
    }
}

/* Loading state */
.woo-adst-product-addons.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Accessibility improvements */
.addon-option:focus-within {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.addon-option input[type="radio"]:focus,
.addon-option input[type="checkbox"]:focus {
    outline: none;
}

/* Price update animation */
.summary .price .woocommerce-Price-amount {
    transition: all 0.3s ease;
}

.summary .price .woocommerce-Price-amount.price-updating {
    color: #2271b1;
    transform: scale(1.05);
}

/* Empty state */
.woo-adst-product-addons:empty {
    display: none;
}

/* Print styles */
@media print {
    .woo-adst-product-addons {
        border: 1px solid #000;
        background: #fff;
    }
    
    .addon-option {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}
