/* ============================================
   Cri SmartSearch - Styles
   ============================================ */

/* --- Search Results Header --- */
.smart-search-results {
    padding: 0 0 40px;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.search-results-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.search-results-title .result-count {
    font-size: 14px;
    font-weight: 400;
    color: #888;
}

/* --- Sort Bar --- */
.search-sort-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-sort-bar label {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
}

.smart-search-sort {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.smart-search-sort:focus {
    border-color: #2980b9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(41, 128, 185, 0.2);
}

/* --- Active Filters --- */
.active-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.active-filters-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.active-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #eef4f9;
    border: 1px solid #b8d4e8;
    border-radius: 20px;
    font-size: 13px;
    color: #2980b9;
    text-decoration: none;
    transition: background 0.2s;
}

.active-filter-pill:hover {
    background: #d5e8f5;
    text-decoration: none;
    color: #1a5276;
}

.active-filter-pill .remove-filter {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

/* --- Mobile Filter Toggle --- */
.filter-toggle-mobile {
    display: none;
    width: 100%;
    padding: 10px 16px;
    margin-bottom: 15px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: center;
}

.filter-toggle-mobile:hover {
    background: #eee;
}

.filter-toggle-mobile.active {
    background: #2980b9;
    color: #fff;
    border-color: #2980b9;
}

/* --- Product Grid --- */
.search-products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* --- Product Card --- */
.product-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.product-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

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

.product-card-link:hover {
    text-decoration: none;
    color: inherit;
}

.product-card-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f8f8f8;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-info {
    padding: 12px 16px;
}

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

.product-card-price {
    font-size: 18px;
    font-weight: 700;
    color: #2980b9;
}

.product-card-actions {
    padding: 0 16px 16px;
}

.product-card-actions .action.tocart {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: #2980b9;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.product-card-actions .action.tocart:hover {
    background: #1a6da3;
}

/* --- Highlight --- */
mark {
    background: #ffd54f;
    color: #333;
    padding: 1px 2px;
    border-radius: 2px;
}

/* --- No Results --- */
.no-results-message {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-results-message p:first-child {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 10px;
}

/* --- Pagination --- */
.search-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
}

.pagination-link:hover {
    background: #f5f5f5;
    border-color: #2980b9;
    color: #2980b9;
    text-decoration: none;
}

.pagination-current {
    background: #2980b9;
    color: #fff;
    border-color: #2980b9;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    font-size: 14px;
    color: #999;
    letter-spacing: 2px;
}

/* --- Filter Sidebar --- */
.smart-search-filters {
    padding: 0;
}

.filters-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2980b9;
}

.clear-all-filters {
    display: inline-block;
    font-size: 13px;
    color: #e74c3c;
    text-decoration: none;
    margin-bottom: 15px;
}

.clear-all-filters:hover {
    text-decoration: underline;
    color: #c0392b;
}

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

.filter-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px;
}

.filter-group-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-option {
    line-height: 1;
}

.filter-checkbox-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    text-decoration: none;
    color: #555;
    font-size: 14px;
    transition: color 0.2s;
}

.filter-checkbox-link:hover {
    color: #2980b9;
    text-decoration: none;
}

.filter-checkbox-link.active {
    color: #2980b9;
    font-weight: 500;
}

.filter-checkbox {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #bbb;
    border-radius: 3px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.filter-checkbox.checked {
    background: #2980b9;
    border-color: #2980b9;
}

.filter-checkbox.checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* --- Autocomplete Dropdown --- */
.smart-search-autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background: #f5f9fc;
}

.autocomplete-item-image {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.autocomplete-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.autocomplete-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.autocomplete-item-name {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-price {
    font-size: 13px;
    font-weight: 600;
    color: #2980b9;
}

.autocomplete-no-results {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .search-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .search-results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .search-results-title {
        font-size: 20px;
    }

    .search-sort-bar {
        width: 100%;
    }

    .smart-search-sort {
        flex: 1;
    }

    .search-products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filter-toggle-mobile {
        display: block;
    }

    /* Sidebar hidden by default on mobile */
    .sidebar-main .smart-search-filters {
        display: none;
    }

    .sidebar-main .smart-search-filters.filters-visible {
        display: block;
    }

    .product-card-name {
        font-size: 13px;
    }

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

    .pagination-link {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
    }
}
