/**
 * Matching Products CSS
 * Styles for the matching products tab and functionality
 */

/* Matching Products Tab */
.ts-products-tab {
    display: inline-block;
    padding: 10px 20px;
    margin-right: 5px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-bottom: none;
    text-decoration: none;
    color: #333;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
}

.ts-products-tab:hover,
.ts-products-tab.active {
    background: #fff;
    color: #0073aa;
    border-color: #0073aa;
}

.ts-products-tab.active {
    font-weight: bold;
}

/* Matching Products Content */
.ts-products-content {
    border: 1px solid #ddd;
    padding: 20px;
    background: #fff;
    margin-top: -1px;
    min-height: 200px;
}

.ts-products-content.loading {
    position: relative;
    opacity: 0.7;
}

.ts-products-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Filters */
.ts-products-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}

.ts-products-filter {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

/* Filter Buttons */
.ts-products-filter-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    user-select: none;
}

.ts-products-filter-btn:hover {
    border-color: #0073aa;
    color: #0073aa;
    background: #f0f8ff;
}

.ts-products-filter-btn.active {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.ts-products-filter-btn.active:hover {
    background: #005a87;
    border-color: #005a87;
}
.ts-products-list{
    max-height: 90vh;
    overflow-y: auto;
}

.ts-products-search {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Products Grid */
.ts-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ts-product {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    padding: 5px 10px;
    margin: 0 -10px;
    transition: all 0.3s ease;
    position: relative;
    align-items: center;
}

.ts-product:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.ts-product-image {
    width: 100px;
    object-fit: cover;
    border-radius: 4px;
}
.ts-product-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
}

.ts-product-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
}

.ts-product-title a {
    color: #333;
    text-decoration: none;
}

.ts-product-title a:hover {
    color: #0073aa;
}

.ts-product-price {
    font-size: 16px;
    font-weight: bold;
    color: #0073aa;
}

.ts-product-price del {
    color: #999;
    font-size: 14px;
    margin-right: 8px;
}

.ts-product-sku{
    width: 120px;
}
.ts-product-qty-toggles{
    width: 120px;
}
.ts-product-price{
    width: 160px;
}

.ts-product-actions {
    padding-left: 15px;
    text-align: right;
    width: 200px;
    display: flex
;
    justify-content: center;
}
.ts-product-actions .added_to_cart {
    display: none !important;
}

.ts-product-quantity {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ts-product-quantity input {
    width: 60px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.ts-product-add-to-cart,
.ts-product-quick-view {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.ts-product-add-to-cart {
    background: #0073aa;
    color: #fff;
    flex: 1;
}

.ts-product-add-to-cart:hover {
    background: #005a87;
}

.ts-product-add-to-cart:disabled,
.ts-product-add-to-cart.loading {
    background: #ccc;
    cursor: not-allowed;
}

.ts-product-quick-view {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.ts-product-quick-view:hover {
    background: #e0e0e0;
}

.ts-product-quick-view.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Quantity Widget */
.ts-product-quantity-widget {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    max-width: 120px;
}
.cmtsfwc-Result .ts-product-quantity-widget{
    position: absolute;
}
body ul.products li.product .ts-product-actions .add_to_cart_button{
    display: block;
}
body ul.products li.product .ts-product-actions:not(.switched) .ts-product-quantity-widget,
.ts-products-list .ts-product-actions:not(.switched) .ts-product-quantity-widget{
    display: none;
}
body ul.products li.product .ts-product-actions.switched .add_to_cart_button,
.ts-products-list .ts-product-actions.switched .add_to_cart_button{
    display: none;
}

.ts-product-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f8f8f8;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    user-select: none;
}

.ts-product-qty-btn:hover:not(:disabled) {
    background: #e0e0e0;
    color: #0073aa;
}

.ts-product-qty-btn:disabled {
    background: #f0f0f0;
    color: #ccc;
    cursor: not-allowed;
}

.ts-product-qty-decrease {
    border-right: 1px solid #ddd;
}

.ts-product-qty-increase {
    border-left: 1px solid #ddd;
}

.ts-product-qty-input {
    width: 56px;
    height: 32px;
    border: none;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: #fff;
    outline: none;
    -moz-appearance: textfield; /* Firefox */
}

.ts-product-qty-input::-webkit-outer-spin-button,
.ts-product-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ts-product-qty-input:focus {
    background: #f8f9fa;
}

/* Quantity Widget States */
.ts-product-quantity-widget.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.ts-product-quantity-widget.loading .ts-product-qty-btn {
    cursor: not-allowed;
}

.ts-product-quantity-widget.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Pagination */
.ts-products-pagination {
    text-align: center;
    margin-top: 30px;
}

.ts-products-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 2px;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.ts-products-pagination .page-numbers:hover,
.ts-products-pagination .page-numbers.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.ts-products-pagination .page-numbers.dots {
    border: none;
    cursor: default;
}

.ts-products-pagination .page-numbers.dots:hover {
    background: transparent;
    color: #333;
}

/* Notices */
.ts-products-notice {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-weight: 500;
}

.ts-products-notice-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ts-products-notice-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ts-products-notice-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Quick View Modal */
.ts-products-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.ts-products-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-products-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.ts-products-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.ts-products-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    z-index: 1;
}

.ts-products-modal-close:hover {
    color: #333;
}

.ts-products-modal-body {
    padding: 30px;
}
.product-details-wrapper.ts-products-tab-content{
    padding: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ts-products-filters {
        padding: 0;
        gap: 5px;
    }

    .ts-product{
        display: block;
        padding: 10px 10px 10px 90px;
        margin: 0;
        font-size: 12px;
    }
    .ts-product-image{
        position: absolute;
        top: 0;
        left: 0;
        width: 90px;
        height: 80px;
        object-fit: cover;
    }
    .ts-product-title{
        font-size: 12px;
    }
    
    .ts-products-search {
        min-width: 100%;
    }
    
    .ts-products-filter-btn {
        padding: 3px 10px;
        font-size: 12px;
        border-radius: 50%;
    }
    
    .ts-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .ts-product-actions {
        padding-left: 0;
        width: 100%;
        display: block;
        text-align: left;
    }
    
    .ts-product-quantity {
        justify-content: center;
    }
    
    .ts-product-quantity-widget {
        max-width: 100px;
    }
    
    .ts-product-qty-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .ts-product-qty-input {
        width: 44px;
        height: 28px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ts-products-grid {
        grid-template-columns: 1fr;
    }
    
    .ts-products-modal-content {
        max-width: 95%;
        margin: 20px;
    }
    
    .ts-products-modal-body {
        padding: 20px;
    }
}

/* Loading States */
.ts-product-add-to-cart.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Empty State */
.ts-products-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.ts-products-empty h3 {
    margin-bottom: 10px;
    color: #333;
}

.ts-products-empty p {
    margin-bottom: 20px;
}

/* WooCommerce Integration */
.woocommerce .ts-products-content {
    margin-top: 20px;
}

.woocommerce .ts-product-price {
    font-size: 16px;
}

.woocommerce .ts-product-add-to-cart {
    background: var(--wc-primary-color, #0073aa);
}

.woocommerce .ts-product-add-to-cart:hover {
    background: var(--wc-primary-color-dark, #005a87);
}
