/**
 * AJAX Product Search Styles
 */

/* Search Container */
.ajax-product-search-container {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Search Form */
.ajax-product-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

/* Search Input Wrapper */
.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.ajax-search-input {
    width: 100%;
    padding: 12px 50px 12px 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}

.ajax-search-input:focus {
    outline: none;
    border-color: #A7144C;
    box-shadow: 0 0 0 3px rgba(167, 20, 76, 0.1);
}

.ajax-search-input::placeholder {
    color: #999;
}

/* Search Button */
.ajax-search-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #A7144C;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ajax-search-button:hover {
    background: #8a103f;
}

.ajax-search-button svg {
    color: #fff;
}

/* Category Filter */
.category-filter-wrapper {
    min-width: 200px;
}

.ajax-category-filter {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.ajax-category-filter:focus {
    outline: none;
    border-color: #A7144C;
}

/* Search Suggestions Dropdown */
.ajax-search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.suggestion-item:hover {
    background: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
}

.suggestion-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-title {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    line-height: 1.3;
}

.suggestion-price {
    color: #A7144C;
    font-weight: 600;
    font-size: 13px;
}

.view-all-results {
    padding: 12px 15px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.view-all-btn {
    color: #A7144C;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.view-all-btn:hover {
    text-decoration: underline;
}

.no-suggestions {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* Results Count */
.search-results-count {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.search-results-count:empty {
    display: none;
}

.results-text {
    color: #666;
    font-size: 14px;
}

.clear-filters {
    background: none;
    border: 1px solid #A7144C;
    color: #A7144C;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-filters:hover {
    background: #A7144C;
    color: #fff;
}

/* Loader */
.ajax-search-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 15px;
}

.loader-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e0e0e0;
    border-top-color: #A7144C;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* No Products Found */
.no-products-found {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.no-products-found p {
    color: #666;
    font-size: 18px;
    margin: 0;
}

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

.ajax-pagination a,
.ajax-pagination span {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 3px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.ajax-pagination a:hover {
    background: #A7144C;
    border-color: #A7144C;
    color: #fff;
}

.ajax-pagination .current {
    background: #A7144C;
    border-color: #A7144C;
    color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .ajax-product-search-container {
        padding: 15px;
    }

    .ajax-product-search-form {
        flex-direction: column;
    }

    .search-input-wrapper,
    .category-filter-wrapper {
        width: 100%;
        min-width: auto;
    }

    .search-results-count {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Integration with existing theme */
.woocommerce .ajax-product-search-container {
    margin-bottom: 30px;
}

/* Hide default WooCommerce search if needed */
.woocommerce .woocommerce-product-search {
    /* Uncomment to hide default search */
    /* display: none; */
}

/* ================================================
 * Product Grid Layout Fix - Ensures consistent sizing
 * after AJAX filtering and clear filters
 * ================================================ */

/* Force consistent product grid layout */
.woocommerce ul.products,
.woocommerce-page ul.products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

/* Product item styling */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    clear: none !important;
    box-sizing: border-box !important;
}

/* Product inner content */
.woocommerce ul.products li.product .woocommerce-loop-product__link,
.woocommerce ul.products li.product a.woocommerce-LoopProduct-link {
    display: block;
}

/* Product images - consistent sizing */
.woocommerce ul.products li.product img,
.woocommerce ul.products li.product .attachment-woocommerce_thumbnail {
    width: 100% !important;
    height: auto !important;
    object-fit: contain;
    max-height: 200px;
}

/* Product title */
.woocommerce ul.products li.product .woocommerce-loop-product__title,
.woocommerce ul.products li.product h2 {
    font-size: 14px !important;
    line-height: 1.4 !important;
    min-height: 40px;
    margin-top: 10px !important;
}

/* Product price */
.woocommerce ul.products li.product .price {
    font-size: 14px !important;
    margin-top: 5px !important;
}

/* Add to cart button */
.woocommerce ul.products li.product .button,
.woocommerce ul.products li.product .add_to_cart_button {
    margin-top: 10px !important;
}

/* Responsive grid */
@media (max-width: 992px) {
    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {
    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: 1fr !important;
    }
}

/* Remove any float-based layout conflicts */
.woocommerce ul.products::before,
.woocommerce ul.products::after {
    display: none !important;
}

/* Fix for columns class variations */
.woocommerce ul.products.columns-3,
.woocommerce ul.products.columns-4,
.woocommerce ul.products.columns-5 {
    grid-template-columns: repeat(3, 1fr) !important;
}
