/* MCI AI Search Widget Styles for WooCommerce */

/* Modal Overlay */
.ai-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
    background: rgba(0, 0, 0, 0.5);
}

/* Modal Content */
.ai-search-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: calc(100vh - 150px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.ai-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    flex-wrap: wrap;
    gap: 15px;
}

.ai-search-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-search-header-left h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.ai-search-result-count {
    color: #666;
    font-size: 0.9rem;
    font-weight: normal;
}

.ai-search-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Sort Dropdown */
.ai-search-sort-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-search-sort-wrapper label {
    font-size: 0.9rem;
    color: #666;
    white-space: nowrap;
}

.ai-search-sort {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-width: 160px;
}

.ai-search-sort:focus {
    outline: none;
    border-color: #7952b3;
}

.ai-search-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    color: #999;
    transition: color 0.2s;
    padding: 0;
    width: 32px;
    height: 32px;
}

.ai-search-close:hover {
    color: #333;
}

/* Spelling Suggestion ("Did you mean?") */
.ai-search-spelling {
    padding: 12px 30px;
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
}

.ai-search-spelling p {
    margin: 0;
    color: #5d4037;
    font-size: 0.95rem;
}

.ai-search-spelling a {
    color: #7952b3;
    font-weight: 600;
    text-decoration: none;
}

.ai-search-spelling a:hover {
    text-decoration: underline;
}

/* Body Layout */
.ai-search-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Filters Sidebar */
.ai-search-filters {
    width: 250px;
    padding: 20px;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    background: #fafafa;
    flex-shrink: 0;
}

.ai-search-filters h4 {
    margin: 0 0 15px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-group h5 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-option {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-option input[type="checkbox"] {
    margin-right: 8px;
}

.filter-option span {
    color: #666;
}

.filter-option:hover span {
    color: #333;
}

.no-filters {
    color: #999;
    font-style: italic;
}

/* Results Grid */
.ai-search-results {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    align-content: start;
}

/* Product Card */
.ai-search-product {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    background: white;
    display: flex;
    flex-direction: column;
}

.ai-search-product:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.ai-search-product .product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Product Image */
.ai-search-product .product-image {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #f5f5f5;
}

.ai-search-product .product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.product-image .no-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 0.9rem;
}

/* Badges */
.badge-sale,
.badge-out-of-stock {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-sale {
    background: #ff4444;
    color: white;
}

.badge-out-of-stock {
    background: #999;
    color: white;
}

/* Product Info */
.product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 0.95rem;
    margin: 0 0 10px 0;
    line-height: 1.4;
    font-weight: 500;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.price-sale {
    color: #ff4444;
    font-weight: 600;
    font-size: 1.1rem;
}

.price-original {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9rem;
}

.price {
    color: #333;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Buttons */
.btn-add-to-cart,
.btn-out-of-stock {
    width: calc(100% - 30px);
    margin: 0 15px 15px;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-add-to-cart {
    background: #7952b3;
    color: white;
}

.btn-add-to-cart:hover {
    background: #5e3d8f;
}

.btn-add-to-cart:active {
    transform: scale(0.98);
}

.btn-add-to-cart:disabled {
    background: #ccc;
    cursor: wait;
}

.btn-out-of-stock {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

/* Loading State */
.ai-search-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #7952b3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Error State */
.ai-search-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #d9534f;
}

/* No Results */
.ai-search-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.ai-search-no-results p {
    margin: 10px 0;
}

/* Placeholder */
.ai-search-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

/* Shortcode Form Styles */
.mci-ai-search-shortcode {
    max-width: 600px;
}

.mci-ai-search-shortcode .search-field-wrapper {
    display: flex;
    gap: 10px;
}

.mci-ai-search-shortcode .search-field {
    flex: 1;
    padding: 12px 15px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mci-ai-search-shortcode .search-submit {
    padding: 12px 25px;
    background: #7952b3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.mci-ai-search-shortcode .search-submit:hover {
    background: #5e3d8f;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-search-modal {
        padding-top: 60px;
    }

    .ai-search-modal-content {
        width: 100%;
        max-height: calc(100vh - 70px);
        border-radius: 0;
        margin: 0;
    }

    .ai-search-header {
        padding: 15px 20px;
    }

    .ai-search-header h3 {
        font-size: 1.2rem;
    }

    .ai-search-body {
        flex-direction: column;
    }

    .ai-search-filters {
        width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 15px;
    }

    .ai-search-results {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 15px;
    }

    .ai-search-product .product-image {
        height: 150px;
    }

    .product-info {
        padding: 10px;
    }

    .product-name {
        font-size: 0.85rem;
    }

    .btn-add-to-cart,
    .btn-out-of-stock {
        width: calc(100% - 20px);
        margin: 0 10px 10px;
        padding: 8px;
        font-size: 0.8rem;
    }
}

/* Scrollbar Styling */
.ai-search-filters::-webkit-scrollbar,
.ai-search-results::-webkit-scrollbar {
    width: 8px;
}

.ai-search-filters::-webkit-scrollbar-track,
.ai-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-search-filters::-webkit-scrollbar-thumb,
.ai-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ai-search-filters::-webkit-scrollbar-thumb:hover,
.ai-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Zero Results Experience */
.ai-search-zero-results {
    grid-column: 1 / -1;
    padding: 20px;
}

.zero-results-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.zero-results-header h4 {
    margin: 0 0 10px 0;
    font-size: 1.3rem;
    color: #333;
}

.zero-results-header p {
    margin: 0;
    color: #666;
}

/* Category Pills */
.zero-results-categories {
    margin-bottom: 30px;
}

.zero-results-categories h5 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #555;
    font-weight: 600;
}

.category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-pill {
    display: inline-block;
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.category-pill:hover {
    background: #7952b3;
    border-color: #7952b3;
    color: white;
}

/* Popular Products in Zero Results */
.zero-results-products {
    margin-top: 20px;
}

.zero-results-products h5 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    color: #555;
    font-weight: 600;
}

.popular-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

/* Mobile Responsive - Additional Rules for New Elements */
@media (max-width: 768px) {
    .ai-search-header-left,
    .ai-search-header-right {
        flex-wrap: wrap;
    }

    .ai-search-sort-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .ai-search-sort {
        min-width: 140px;
    }

    .ai-search-spelling {
        padding: 10px 15px;
    }

    .category-pills {
        gap: 8px;
    }

    .category-pill {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .popular-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
}
