/**
 * AnySell Frontend Styles — Safe Version
 *
 * All styles are scoped under .anysell-product-form
 * to avoid any conflict with theme or other plugins.
 * No global resets, no !important, no generic tag selectors.
 */

/* ============ Container ============ */
.anysell-product-form {
    margin-top: 15px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
}

/* Ensure product price above AnySell form stays prominent */
.anysell-product-form ~ .price,
.entry-summary .price,
.summary .price,
.product .price {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.3;
}

.anysell-product-form ~ .price del,
.entry-summary .price del,
.summary .price del,
.product .price del {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.6;
}

.anysell-product-form ~ .price ins,
.entry-summary .price ins,
.summary .price ins,
.product .price ins {
    font-size: 26px;
    font-weight: 700;
    text-decoration: none;
}

.anysell-product-form *,
.anysell-product-form *::before,
.anysell-product-form *::after {
    box-sizing: border-box;
}

/* ============ Mode Toggle ============ */
.anysell-product-form .anysell-mode-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.anysell-product-form .anysell-mode-btn {
    display: inline-flex;
    align-items: center;
    padding: 9px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    color: #555;
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.anysell-product-form .anysell-mode-btn:hover {
    border-color: #007cba;
    color: #007cba;
    background: #f8fcff;
}

.anysell-product-form .anysell-mode-btn.active {
    border-color: #007cba;
    background: #007cba;
    color: #fff;
}

/* ============ Single Mode — Attributes ============ */
.anysell-product-form .anysell-single-mode {
    margin-bottom: 10px;
}

.anysell-product-form .anysell-attribute-row {
    margin-bottom: 16px;
}

.anysell-product-form .anysell-attribute-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

/* Color Swatches */
.anysell-product-form .anysell-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.anysell-product-form .anysell-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.anysell-product-form .anysell-color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.anysell-product-form .anysell-color-swatch.selected {
    border-color: #333;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
    transform: scale(1.1);
}

.anysell-product-form .anysell-swatch-check {
    display: none;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    line-height: 1;
}

.anysell-product-form .anysell-color-swatch.selected .anysell-swatch-check {
    display: block;
}

/* Size Swatches */
.anysell-product-form .anysell-size-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.anysell-product-form .anysell-size-swatch {
    min-width: 40px;
    height: 36px;
    padding: 0 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    color: #333;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.anysell-product-form .anysell-size-swatch:hover {
    border-color: #007cba;
    color: #007cba;
}

.anysell-product-form .anysell-size-swatch.selected {
    border-color: #333;
    background: #333;
    color: #fff;
}

.anysell-product-form .anysell-size-swatch.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* Select dropdown */
.anysell-product-form .anysell-attribute-select {
    width: 100%;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    outline: none;
}

/* Clear link */
.anysell-product-form .anysell-clear-selection {
    font-size: 12px;
    color: #999;
    text-decoration: none;
    margin-left: 4px;
}

.anysell-product-form .anysell-clear-selection:hover {
    color: #007cba;
    text-decoration: underline;
}

/* Variation Info (single mode) */
.anysell-product-form .anysell-single-variation-info {
    margin: 12px 0;
    padding: 10px 0;
    border-top: 1px solid #f0f0f0;
}

.anysell-product-form .anysell-variation-price-single {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.anysell-product-form .anysell-variation-stock {
    font-size: 13px;
    color: #46b450;
}

.anysell-product-form .anysell-variation-stock.out-of-stock {
    color: #dc3232;
}

/* Quantity + Cart (Single) */
.anysell-product-form .anysell-single-cart {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-top: 16px;
}

.anysell-product-form .anysell-quantity-wrap label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
}

.anysell-product-form .anysell-qty-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.anysell-product-form .anysell-single-qty-minus,
.anysell-product-form .anysell-single-qty-plus {
    width: 36px;
    height: 38px;
    border: none;
    background: #f7f7f7;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    color: #333;
}

.anysell-product-form .anysell-single-qty-minus:hover,
.anysell-product-form .anysell-single-qty-plus:hover {
    background: #e0e0e0;
}

.anysell-product-form .anysell-single-qty-input {
    width: 48px;
    height: 38px;
    border: none;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    -moz-appearance: textfield;
    outline: none;
    background: #fff;
    color: #333;
}

.anysell-product-form .anysell-single-qty-input::-webkit-outer-spin-button,
.anysell-product-form .anysell-single-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.anysell-product-form .anysell-single-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 600;
    height: 40px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    text-decoration: none;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    white-space: nowrap;
}

.anysell-product-form .anysell-single-add-btn:hover {
    background: #555;
}

.anysell-product-form .anysell-single-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.anysell-product-form .anysell-single-add-btn.anysell-btn-success {
    background: #46b450;
}

/* ============ BUNDLE MODE ============ */
.anysell-product-form .anysell-bundle-mode {
    margin-top: 10px;
}

/* Bundle Progress */
.anysell-product-form .anysell-bundle-progress {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.anysell-product-form .anysell-progress-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.anysell-product-form .anysell-progress-fill {
    height: 100%;
    background: #007cba;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.2s ease;
    width: 0%;
}

.anysell-product-form .anysell-progress-fill.complete {
    background: #46b450;
}

.anysell-product-form .anysell-progress-fill.over {
    background: #dc3232;
}

.anysell-product-form .anysell-progress-text {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    text-align: center;
}

.anysell-product-form .anysell-progress-message {
    text-align: center;
    margin-top: 4px;
    font-size: 12px;
    color: #888;
}

.anysell-product-form .anysell-progress-message.ready {
    color: #46b450;
    font-weight: 700;
    font-size: 13px;
}

.anysell-product-form .anysell-progress-message.error {
    color: #dc3232;
    font-weight: 600;
}

/* Bundle Picker Items */
.anysell-product-form .anysell-bundle-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}

.anysell-product-form .anysell-bundle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
}

.anysell-product-form .anysell-bundle-item:hover {
    border-color: #ccc;
}

.anysell-product-form .anysell-bundle-item.has-qty {
    border-color: #007cba;
    background: #f7fbff;
}

.anysell-product-form .anysell-bundle-item[data-in-stock="0"] {
    opacity: 0.4;
    pointer-events: none;
}

.anysell-product-form .anysell-bundle-item-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.anysell-product-form .anysell-bundle-item-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.anysell-product-form .anysell-bundle-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.anysell-product-form .anysell-bundle-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anysell-product-form .anysell-bundle-item-price {
    font-size: 18px !important;
    color: #999;
}

.anysell-product-form .anysell-bundle-item-price *,
.anysell-product-form .anysell-bundle-item-price del,
.anysell-product-form .anysell-bundle-item-price ins,
.anysell-product-form .anysell-bundle-item-price .woocommerce-Price-amount,
.anysell-product-form .anysell-bundle-item-price .amount,
.anysell-product-form .anysell-bundle-item-price bdi,
.anysell-product-form .anysell-bundle-item-price span {
    font-size: inherit !important;
}

.anysell-product-form .anysell-bundle-item-price del {
    color: #ccc;
}

/* Bundle Qty Controls */
.anysell-product-form .anysell-bundle-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.anysell-product-form .anysell-bqty-minus,
.anysell-product-form .anysell-bqty-plus {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    border-radius: 50%;
    background: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
    padding: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    color: #333;
}

.anysell-product-form .anysell-bqty-minus:hover,
.anysell-product-form .anysell-bqty-plus:hover {
    background: #007cba;
    border-color: #007cba;
    color: #fff;
}

.anysell-product-form .anysell-bqty-value {
    font-size: 14px;
    font-weight: 700;
    width: 20px;
    text-align: center;
    color: #333;
    display: inline-block;
}

/* Bundle Footer */
.anysell-product-form .anysell-bundle-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 14px;
    border-top: 1px solid #e5e5e5;
}

.anysell-product-form .anysell-bundle-total {
    display: flex;
    flex-direction: column;
}

.anysell-product-form .anysell-bundle-total-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.anysell-product-form .anysell-bundle-total-value {
    font-size: 20px;
    font-weight: 700;
    color: #007cba;
}

.anysell-product-form #anysell-bundle-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    text-decoration: none;
}

.anysell-product-form #anysell-bundle-add-btn:hover {
    background: #555;
}

.anysell-product-form #anysell-bundle-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.anysell-product-form #anysell-bundle-add-btn.anysell-btn-success {
    background: #46b450;
}

/* ============ Responsive ============ */
@media screen and (max-width: 768px) {
    .anysell-product-form .anysell-mode-toggle {
        flex-direction: column;
    }

    .anysell-product-form .anysell-single-cart {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .anysell-product-form .anysell-single-add-btn {
        width: 100%;
        justify-content: center;
    }

    .anysell-product-form .anysell-bundle-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .anysell-product-form .anysell-bundle-total {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .anysell-product-form #anysell-bundle-add-btn {
        width: 100%;
        justify-content: center;
    }

    .anysell-product-form .anysell-color-swatch {
        width: 32px;
        height: 32px;
    }

    .anysell-product-form .anysell-bundle-picker {
        max-height: 250px;
    }
}

@media screen and (max-width: 480px) {
    .anysell-product-form .anysell-mode-btn {
        font-size: 12px;
        padding: 8px 12px;
    }

    .anysell-product-form .anysell-bundle-item {
        padding: 8px 10px;
        gap: 8px;
    }

    .anysell-product-form .anysell-bundle-item-img {
        width: 32px;
        height: 32px;
    }

    .anysell-product-form .anysell-bundle-item-name {
        font-size: 12px;
    }
}

/* Shake animation (scoped) */
@keyframes anysell-item-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    60% { transform: translateX(3px); }
}

.anysell-product-form .anysell-shake {
    animation: anysell-item-shake 0.3s ease;
}
