/* Enhanced Search Overlay Styles */

/* Search Overlay Header */
.search-overlay-header {
    position: absolute;
    top: 20px;
    right: 20px;
    left: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1001;
}

.search-back-btn,
.search-close-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.search-back-btn:hover,
.search-close-btn:hover {
    background: #fff;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Search Results Header */
.search-results-header {
    margin-bottom: 20px;
}

.search-query-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border-right: 4px solid var(--primary-color, #007bff);
}

.search-query-display h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-query-display h3::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--primary-color, #007bff);
}

.results-count {
    font-size: 14px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Search Tabs */
.search-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 5px;
}

.search-tab {
    padding: 10px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    background: #fff;
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.search-tab:hover {
    border-color: var(--primary-color, #007bff);
    color: var(--primary-color, #007bff);
    transform: translateY(-2px);
}

.search-tab.active {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.tab-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.search-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.3);
}

/* Enhanced Result Cards */
.search-result-item {
    margin-bottom: 16px;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.result-card {
    display: flex;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0; /* Prevents flex container from overflowing */
}

.search-result-item:hover .result-card {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* Result Image Container */
.result-image-container {
    position: relative;
    width: 140px;
    min-width: 140px;
    height: 140px;
    overflow: hidden;
}

.result-image {
    width: 100%;
    height: 100%;
    position: relative;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.search-result-item:hover .result-image img {
    transform: scale(1.05);
}

.no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #6c757d;
    font-size: 32px;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    transition: all 0.3s ease;
}

.no-image:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #495057;
    transform: scale(1.02);
}

.result-image {
    position: relative;
    overflow: hidden;
}

.result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.result-image img[style*="display: none"] + .no-image {
    display: flex !important;
}

/* Badges */
.stock-status {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(10px);
}

.stock-status.in-stock {
    background: rgba(40, 167, 69, 0.9);
    color: #fff;
}

.stock-status.out-of-stock {
    background: rgba(220, 53, 69, 0.9);
    color: #fff;
}

.type-badge {
    position: absolute;
    bottom: 5px;
    right: 8px;
    padding: 5px 11px 0px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(10px);
    margin: 20px 0px 50px 0px;
}
#suggestions-box {
/* margin-top: 0.75rem !important;
    background: rgba(44, 44, 44, 0.7); 
    border: 1px solid #ca8749 !important;*/
    border-radius: 12px;
    padding: 0.25rem 0px ;
    max-height: 240px !important;
    overflow-y: auto;
    display: block;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-bottom: 1px !important;
    padding: 11px 11px !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border-radius: 12px;
    border-right: 4px solid var(--primary-color, #007bff) !important;
    flex-wrap: wrap !important;
    align-content: center !important;
    /* margin-left: 5% !important;
    margin-right: 3% !important; */
}
.product-badge {
    background: rgb(255 113 0 / 24%);
    color: #fff;
}

.post-badge {
    background: rgba(108, 117, 125, 0.9);
    color: #fff;
}

/* Result Content */
.result-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex item from overflowing */
    overflow: hidden; /* Prevents content overflow */
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.result-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.4;
    flex: 1;
    min-width: 0; /* Allows text to wrap properly */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.search-result-item:hover .result-title {
    color: var(--primary-color, #007bff);
}

.result-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-top: 4px;
    flex-shrink: 0; /* Prevents price from shrinking */
}

.price-amount {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color, #007bff);
}

.price-currency {
    font-size: 12px;
    color: #6c757d;
    font-weight: 500;
}

.result-excerpt {
    margin: 0 0 12px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #6c757d;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Categories */
.result-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.category-badge {
    padding: 4px 10px;
    background: #f8f9fa;
    color: #495057;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.category-badge:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
    border-color: var(--primary-color, #007bff);
}

.more-categories {
    padding: 4px 8px;
    background: #6c757d;
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Hover Overlay */
.result-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 123, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 16px;
}

.search-result-item:hover .result-hover-overlay {
    opacity: 1;
}

.hover-content {
    color: #fff;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.hover-content i {
    font-size: 24px;
}

/* Loading and No Results */
.search-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--primary-color, #007bff);
}

.loading-spinner i {
    font-size: 24px;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.no-results-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-results h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #495057;
}

.no-results p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Enhanced Trending Hashtags */
.trending-hashtags {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
}

.trending-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #495057;
}

.trending-title i {
    color: #ff6b35;
}

.hashtags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hashtags-list a {
    padding: 8px 12px;
    background: #fff;
    color: var(--primary-color, #007bff);
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.hashtags-list a:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* Load More Button */
.load-more-btn {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid var(--primary-color, #007bff);
    border-radius: 12px;
    background: #fff;
    color: var(--primary-color, #007bff);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.load-more-btn:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
    transform: translateY(-2px);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Highlight Search Terms */
mark {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
    color: #856404;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .search-overlay {
        padding: 10px;
    }
    
    .search-overlay-header {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .result-card {
        padding: 16px;
    }
    
    .result-image-container {
        width: 120px;
        height: 120px;
    }
    
    .search-tabs {
        gap: 8px;
    }
    
    .search-tab {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .search-overlay {
        padding: 0;
        border-radius: 0;
        align-items: stretch; /* کشیدن محتوا در تمام ارتفاع */
    }
    
    .search-overlay-header {
        top: 0;
        right: 0;
        left: 0;
        padding: 15px;
        border-radius: 0;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    .search-back-btn,
    .search-close-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .search-results-container {
        padding-top: 80px; /* Account for fixed header */
    }
    
    .result-card {
        flex-direction: column;
        padding: 16px;
        margin-bottom: 12px;
    }
    
    .result-image-container {
        width: 100%;
        height: 200px;
        margin-bottom: 12px;
    }
    
    .result-content {
        width: 100%;
        min-width: 0;
    }
    
    .search-query-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 15px;
    }
    
    .search-tabs {
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 15px;
    }
    
    .search-tab {
        font-size: 13px;
        padding: 8px 12px;
        min-width: auto;
        flex: none;
    }
    
    .result-title {
        font-size: 16px;
        line-height: 1.4;
    }
    
    .result-excerpt {
        font-size: 13px;
        line-height: 1.5;
        -webkit-line-clamp: 2;
    }
    
    .price-amount {
        font-size: 18px;
    }
    
    .category-badges {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .category-badge {
        font-size: 11px;
        padding: 3px 8px;
    }
}

@media (max-width: 480px) {
    .search-overlay-header {
        padding: 12px;
    }
    
    .search-results-container {
        padding-top: 0px;
    }
    
    .result-card {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .result-image-container {
        height: 160px;
        margin-bottom: 10px;
    }
    
    .result-content {
        padding: 0;
    }
    
    .result-title {
        font-size: 15px;
        margin-bottom: 6px;
    }
    
    .result-excerpt {
        font-size: 12px;
        margin-bottom: 8px;
        -webkit-line-clamp: 2;
    }
    
    .price-amount {
        font-size: 16px;
    }
    
    .price-currency {
        font-size: 12px;
    }
    
    .search-query-display {
        padding: 10px 12px;
    }
    
    .search-tabs {
        padding: 0 12px;
        gap: 4px;
    }
    
    .search-tab {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .tab-count {
        font-size: 10px;
        min-width: 16px;
        height: 16px;
        line-height: 16px;
    }
    
    .category-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .stock-status {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .type-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .result-card {
        flex-direction: row;
    }
    
    .result-image-container {
        width: 140px;
        height: 100px;
        margin-bottom: 0;
        margin-left: 12px;
    }
    
    .result-content {
        flex: 1;
        min-width: 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .result-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-overlay {
        background: rgba(30, 30, 30, 0.98);
        color: #e0e0e0;
    }
    
    .search-overlay-header {
        background: rgba(40, 40, 40, 0.95);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .result-card {
        background: rgba(50, 50, 50, 0.8);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .result-card:hover {
        background: rgba(60, 60, 60, 0.9);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .search-tab {
        background: rgba(60, 60, 60, 0.8);
        color: #e0e0e0;
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .search-tab.active {
        background: var(--primary-color, #007bff);
        color: #fff;
    }
    
    .no-image {
        background: linear-gradient(135deg, rgba(80, 80, 80, 0.8) 0%, rgba(60, 60, 60, 0.9) 100%);
        color: #b0b0b0;
    }
}