/* Search Popup Styles */
.search-popup-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
}
.search-popup-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* .search-popup-input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
} */

/* Popup Overlay */
.search-popup-overlay {
    display: none;
    position: absolute;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
    height: fit-content;
    top: 0;
    left: 0;
    width: 100%;
    background-color: transparent; /* No dim */
    z-index: 1050;
    padding: 40px 20px;
    box-sizing: border-box;
}

.search-popup-content {
    background: #fff;
    border-radius: 0;
    max-width: 100%;
    width: 100%;
    margin: 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    /*max-height: 90vh;*/
    display: flex;
    flex-direction: column;
}

/* Anchored mode: show popup under the search field */
.search-popup-content.anchored {
    top: var(--popup-top, 80px);
    background: #fff;
    padding: 30px;
    border-radius: 13px;
    border: 1px solid #d8d8d8;
/*     max-height: 100%; */
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.15);
    margin: 0 auto;
}

.search-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.search-popup-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #343a40;
}

.search-popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #6c757d;
    text-shadow: 0 1px 0 #fff;
    opacity: 0.7;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
    cursor: pointer;
    transition: color 0.15s ease-in-out;
    border-radius: 0.25rem;
}

.search-popup-close:hover {
    color: #495057;
    text-decoration: none;
    opacity: 1;
}

.search-popup-close:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Search Results Container */
.search-results-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.search-results-group {
    margin-bottom: 30px;
}

.search-group-title {
    font-size: 1.1rem;
    color: #495057;
    margin: 20px 0 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.search-result-item {
    display: flex;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    transition: all 0.2s ease-in-out;
    height: 100%;
}

.search-result-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.search-result-image {
    width: 100px;
    min-width: 100px;
    height: 100px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-right: 1px solid #e9ecef;
}

.search-result-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.search-result-details {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.search-result-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: #212529;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.8em; /* Fallback for line-clamp */
    line-clamp: 2; /* Standard property */
    display: -webkit-box; /* Required for WebKit browsers */
}

.search-result-sku {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 8px;
}

.search-result-price {
    font-weight: 600;
    color: #28a745;
    font-size: 1rem;
    margin-bottom: 12px;
}

.search-result-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.view-details {
    font-size: 0.85rem;
    color: #007bff;
    text-decoration: none;
    transition: color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
}

.view-details:hover {
    color: #0056b3;
    text-decoration: none;
}

.add-to-cart {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.add-to-cart:hover {
    background-color: #218838;
    text-decoration: none;
}

/* Loading and No Results */
.loading,
.no-results,
.error {
    text-align: center;
    padding: 40px 20px;
    font-size: 15px;
    color: #7f8c8d;
    grid-column: 1 / -1;
}

.loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .search-results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .search-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .search-popup-overlay {
        padding: 10px;
    }
    
    .search-results-grid {
        grid-template-columns: 1fr;
    }
    
    .search-result-item {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .search-result-item {
        flex-direction: column;
    }
    
    .search-result-image {
        width: 100%;
        height: 150px;
        border-right: none;
        border-bottom: 1px solid #eaeff5;
    }
    
    .search-result-details {
        padding: 15px;
    }
    
    .search-popup-content {
        margin: 20px 0;
        border-radius: 0;
    }
}

.search-popup-results .shop_products {
    padding-bottom: 20px;
    margin: 15px;
}
.search-popup-results .mb-4, .search-popup-results.my-4 {
    margin-bottom: 1.5rem !important;
}

@media (min-width: 768px) {
    .search-popup-results .col-md-4 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 33.333333%;
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}
.search-popup-results .product_main_info {
    border-radius: 8px;
    border: 1px solid #C9C9C9;
    background: #fff;
    box-shadow: 0px 4px 6px -1px rgba(0, 0, 0, 0.10), 0px 2px 4px -2px rgba(0, 0, 0, 0.10);
}
.search-popup-results .product_img {
    position: relative;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.search-popup-results .product_img img {
    width: 292px;
    text-align: center;
    border-radius: 8px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    height: 199px;
}
.search-popup-results .product_detail_info {
    border-top: 1px solid #F3F4F6;
    padding: 16px;
}
.search-popup-results .product-category.single-line-text {
    margin-top: 15px;
}
.search-popup-results .single-line-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 !important;
}
.search-popup-results .product-category a {
    font-size: 0.625rem;
    opacity: 0.8;
    color: #333;
    text-transform: uppercase;
}
.search-popup-results .info_title h3 {
    color: #111827;
    font-family: Poppins;
    font-size: 17.156px;
    font-weight: 700;
    line-height: 28px;
}
.search-popup-results .info_para p {
    color: #020817;
    font-family: Poppins;
    font-size: 13.234px;
    font-weight: 400;
    line-height: 20px;
    margin-bottom: 10px;
}
.search-popup-results .info_display {
    display: flex;
    justify-content: space-between;
}
.search-popup-results .info_display p {
    color: #374151;
    font-family: Poppins;
    font-size: 12.141px;
    font-weight: 400;
    line-height: 20px;
    margin-bottom: 5px;
    width: 50%;
}
.search-popup-results .product_info_price h3 {
    color: #020817;
    font-family: Poppins;
    font-size: 17.188px;
    font-weight: 700;
    line-height: 28px;
    margin: 0;
}
.search-popup-results .ajax_add_to_cart{
    font-size: 100%;
    margin: 0;
    line-height: 1;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    overflow: visible;
    padding: .618em 1em;
    font-weight: 700;
    border-radius: 3px;
    color: #fff;
    background: #F97316;
    border: 0;
    display: inline-block;
    background-image: none;
    box-shadow: none;
    text-shadow: none;
    width: 100%;
    text-align: center;
}
.search-popup-results .info_title h3:hover {
    color: #F37021 !important;
}


.search-popup-container {
    position: relative;
    width: 300px; /* Adjust width */
}

.search-popup-form {
    position: relative;
    width: 100%;
}

.search-popup-input {
    width: 100%;
    padding: 10px 40px 10px 15px; /* add right padding for icon */
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
}

.search-popup-button {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #999;
    font-size: 18px;
}

.search-popup-button:hover {
    color: #ff6600; /* hover effect */
}

.popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-radius: 8px 8px 0 0;
    background: lightgray;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 18px;
    margin-bottom: 18px;
    gap: 0;
}
.popup-header-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.popup-title {
    color: #111827;
    font-family: Inter;
    font-size: 23.625px;
    font-style: normal;
    font-weight: 700;
    line-height: 32px;
}
.popup-results-count {
    font-family: Inter;
    font-size: 14.875px;
    font-style: normal;
    font-weight: 400;
    line-height: 24px;
}
.search_selected_results ul {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}
.search_selected_results li {
    color: #000;
    font-family: Inter;
    font-size: 12px;
    font-style: normal;
    font-weight: 600;
    line-height: normal;
    text-transform: uppercase;
    padding: 10px 0;
}
.search_selected_results li span {
    color: #565656;
    font-family: Inter;
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
}

/* Search Type Tabs */
.search-type-tabs {
    margin: 15px 0;
    display: flex;
    gap: 10px;
    padding: 0 15px;
}

.search-tab-btn {
    background: #f5f5f5;
    border: 1px solid #ddd;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-tab-btn:hover {
    background: #e9e9e9;
}

.search-tab-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Blog Search Results */
.blog-search-results {
    margin-top: 30px;
    padding: 0 15px;
}

.blog-results-title {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
}

.blog-search-item {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-search-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.blog-search-thumbnail {
    display: block;
    height: 180px;
    overflow: hidden;
}

.blog-search-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.blog-search-item:hover .blog-search-thumbnail img {
    transform: scale(1.05);
}

.blog-search-item .blog-category {
    padding: 10px 15px 0;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.blog-search-item .blog-title {
    margin: 10px 15px;
    font-size: 16px;
    line-height: 1.4;
}

.blog-search-item .blog-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.blog-search-item .blog-title a:hover {
    color: #F95416;
}

.blog-search-item .blog-date {
    font-size: 12px;
    color: #888;
    margin: 0 15px 10px;
}

.blog-search-item .blog-excerpt {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    margin: 0 15px 15px;
    flex-grow: 1;
}

.blog-search-item .read-more {
    color: #F95416;
    font-family: Poppins;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
    margin-left: 14px;
    margin-bottom: 10px;
}

.blog-search-item .read-more:hover {
    color: #F95416;
    text-decoration: underline;
}

/* Pagination */
.blog-pagination {
    margin-top: 30px;
    text-align: center;
    padding: 0 15px;
}

.blog-pagination .page-numbers {
    display: inline-block;
    padding: 5px 12px;
    margin: 0 2px;
    border: 1px solid #ddd;
    color: #333;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.blog-pagination .page-numbers.current,
.blog-pagination .page-numbers:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

.blog-pagination .page-numbers.dots {
    border: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .search-type-tabs {
        justify-content: center;
    }
    
    .blog-search-item {
        margin-bottom: 20px;
    }
    
    .blog-search-thumbnail {
        height: 160px;
    }
}

/* Loading State */
.search-loading {
    text-align: center;
    padding: 30px 0;
    color: #666;
}

/* Related Pages Section */
.related-pages-section {
    margin: 20px 0 0;
    padding: 20px 0 0;
    border-top: 1px solid #e0e0e0;
}

.related-pages-title {
    font-size: 18px;
    color: #007565;
    margin: 0 0 10px 0;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.related-pages-container {
    margin-bottom: 0;
}

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

.related-page-item {
    margin: 0;
    padding: 0;
    border: none;
    position: relative;
    padding-left: 15px;
    margin-bottom: 6px;
}

.related-page-item:before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 5px;
    height: 5px;
    background-color: #3d3d3d;
    border-radius: 50%;
}

.related-page-link {
    color: #3d3d3d;
    text-decoration: none;
    display: block;
    font-size: 14px;
    line-height: 1.5;
    transition: color 0.2s ease;
    padding: 2px 0;
}

.related-page-link:hover {
    color: #000;
    text-decoration: underline;
}

.related-page-title {
    font-size: 18px;
    font-weight: 400;
    margin: 0;
    line-height: 1.5;
}

.view-all-pages {
    margin-top: 10px;
    text-align: left;
}

.view-all-pages a {
    color: #3d3d3d;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
    display: inline-block;
    padding: 2px 0 2px 15px;
    position: relative;
}

.view-all-pages a:after {
    content: '→';
    margin-left: 5px;
    position: relative;
    top: 0;
    transition: transform 0.2s ease;
}

.view-all-pages a:hover {
    color: #000;
    text-decoration: none;
}

.view-all-pages a:hover:after {
    transform: translateX(3px);
}

.view-all-container {
    margin-top: 20px;
    text-align: center;
}

.view-all-button {
    display: inline-block;
    padding: 8px 20px;
    background-color: #F95416;;
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.view-all-button:hover {
    background-color: #F95416;
    color: #fff;
    text-decoration: none;
}

.search-loading:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #333;
    animation: spin 0.8s ease-in-out infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

@media (max-width: 767px) {
    .search-popup-content.anchored {
        position: fixed;
        top: 18% !important;
        left: 50% !important;
        transform: translateX(-50%);
        width: 90%;
        max-height: 80vh;
        margin: 0;
        z-index: 1051;
    }

    #searchPopupResults {
        max-height: calc(80vh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure the close button is accessible */
    #searchPopupClose {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 1001;
        background: #fff;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
}