/* ===================================================================
 * BINGO E-Commerce Search Styles - Complete Version with Header Fixes
 * ------------------------------------------------------------------- */

/* ===================================================================
 * 1. Header Actions & Icons Layout Fixes
 * ------------------------------------------------------------------- */

/* Fix header actions layout to prevent wrapping */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap; /* Prevent wrapping to new line */
    gap: 20px; /* Consistent spacing between icons */
    margin-left: auto; /* Push to the right side */
}

/* Reset any conflicting margins */
.header-actions > * {
    margin: 0;
    position: relative;
    flex-shrink: 0; /* Prevent excessive shrinking */
}

/* Ensure cart container doesn't collapse or wrap */
.cart-container {
    position: relative;
}

/* Consistent badge positioning for cart and wishlist counts */
.cart-count, .wishlist-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--color-secondary, #c9a980);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 5; /* Ensure badge appears above icons */
}

/* ===================================================================
 * 2. Search Dropdown in Header
 * ------------------------------------------------------------------- */

/* Search Container */
.search-container {
    position: relative;
    z-index: 1001; /* Ensure dropdown appears above other elements */
    flex-shrink: 0; /* Prevent excessive shrinking */
}

/* Search Toggle Button */
.search-toggle {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: var(--color-primary, #0a0a0a);
    transition: color 0.3s ease;
}

.search-toggle:hover {
    color: var(--color-secondary, #c9a980);
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    right: -150px; /* Position from right side */
    width: 400px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    padding: 20px;
    
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: none; /* Start with display none for JS control */
}

/* Show dropdown when active class is applied */
.search-container.active .search-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(10px);
    display: block;
}

/* Search Form */
.search-form {
    position: relative;
    margin-bottom: 20px;
}

.search-form input[type="text"] {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 1px solid var(--color-border, #e5e5e5);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.search-form input[type="text"]:focus {
    border-color: var(--color-secondary, #c9a980);
    outline: none;
}

.search-form button {
    position: absolute;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text, #666);
    transition: color 0.3s ease;
}

.search-form button[type="submit"] {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
}

.search-form .clear-search {
    right: 35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: #ccc;
}

.search-form button:hover {
    color: var(--color-dark, #333);
}

/* Search Suggestions */
.search-suggestions {
    display: none; /* Hidden by default, shown via JS */
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.suggestions-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-dark, #333);
}

.view-all, .clear-recent {
    font-size: 0.8rem;
    color: var(--color-text, #666);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.3s ease;
}

.view-all:hover, .clear-recent:hover {
    color: var(--color-secondary, #c9a980);
    text-decoration: underline;
}

/* Suggestions Items */
.suggestions-items {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 10px;
    text-decoration: none;
    color: var(--color-dark, #333);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.suggestion-item:hover {
    background-color: var(--color-light, #f8f8f8);
}

.suggestion-image {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
}

.suggestion-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.suggestion-content h4 {
    font-size: 0.9rem;
    margin: 0 0 5px;
    font-weight: 500;
}

.suggestion-price {
    font-weight: 600;
    color: var(--color-dark, #333);
    font-size: 0.9rem;
}

/* Recent Searches */
.recent-searches {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.recent-search-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--color-text, #666);
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.recent-search-item:hover {
    background-color: var(--color-light, #f8f8f8);
    color: var(--color-dark, #333);
}

.recent-search-item i {
    margin-right: 10px;
    font-size: 0.8rem;
    opacity: 0.6;
}

/* No Results and Loading States */
.no-suggestions, .searching {
    text-align: center;
    padding: 20px 0;
}

.no-suggestions p, .searching p {
    margin-bottom: 15px;
    color: var(--color-text, #666);
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--color-border, #eee);
    border-top: 3px solid var(--color-primary, #333);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Quick Links */
.quick-links {
    margin-top: 15px;
}

.quick-links h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
}

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

.tags a {
    font-size: 0.75rem;
    padding: 5px 10px;
    background-color: var(--color-light, #f8f8f8);
    border-radius: 30px;
    text-decoration: none;
    color: var(--color-text, #666);
    transition: all 0.2s ease;
}

.tags a:hover {
    background-color: var(--color-primary, #333);
    color: #fff;
}

/* Suggestions Footer */
.suggestions-footer {
    text-align: center;
}

/* ===================================================================
 * 3. Search Results Page
 * ------------------------------------------------------------------- */
.search-page {
    padding: 60px 0;
}

/* Search Results Header */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
}

.search-info {
    font-size: 1rem;
    color: var(--color-text, #666);
    flex: 1;
}

.search-info span {
    font-weight: 600;
    color: var(--color-dark, #333);
}

.search-filter {
    width: 200px;
}

.form-select {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--color-border, #eee);
    border-radius: 4px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6' fill='none'%3E%3Cpath fill='%23333' d='M6 6 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-color: #fff;
}

/* Search Results */
.search-results {
    margin-bottom: 40px;
}

.search-result-item {
    display: flex;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--color-border, #eee);
}

.result-image {
    width: 180px;
    height: 180px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 25px;
}

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

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

.result-content {
    flex: 1;
}

.result-title {
    font-size: 1.2rem;
    margin: 0 0 10px;
}

.result-title a {
    color: var(--color-dark, #333);
    text-decoration: none;
    transition: color 0.2s;
}

.result-title a:hover {
    color: var(--color-secondary, #c9a980);
}

.result-category {
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.result-category-link {
    color: var(--color-text, #666);
    text-decoration: none;
    transition: color 0.2s;
}

.result-category-link:hover {
    color: var(--color-secondary, #c9a980);
}

.result-description {
    color: var(--color-text, #666);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.result-price {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-dark, #333);
    margin-bottom: 15px;
}

.old-price {
    text-decoration: line-through;
    color: var(--color-text, #666);
    opacity: 0.7;
    margin-right: 8px;
    font-size: 0.9375rem;
    font-weight: 400;
}

.result-actions {
    display: flex;
    gap: 10px;
}

/* Highlight matched search terms */
.highlight {
    background-color: rgba(201, 169, 128, 0.2);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 500;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 0;
}

.no-results i {
    font-size: 3rem;
    color: var(--color-border, #ddd);
    margin-bottom: 20px;
}

.no-results h3 {
    margin-bottom: 15px;
}

.no-results p {
    color: var(--color-text, #666);
    margin-bottom: 20px;
}

/* Related Searches */
.related-searches-container {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--color-border, #eee);
    display: none; /* Hidden by default, shown via JS when results exist */
}

.related-searches-container h3 {
    margin-bottom: 20px;
}

.related-searches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.related-search-tag {
    padding: 8px 15px;
    background-color: var(--color-light, #f8f8f8);
    border-radius: 30px;
    text-decoration: none;
    color: var(--color-text, #666);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.related-search-tag:hover {
    background-color: var(--color-primary, #333);
    color: #fff;
}

/* ===================================================================
 * 4. Responsive Styles
 * ------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .search-dropdown {
        right: -100px;
        width: 350px;
    }
    
    .header-actions {
        gap: 18px; /* Slightly reduce space between icons */
    }
}

@media (max-width: 992px) {
    .search-result-item {
        flex-direction: column;
    }
    
    .result-image {
        width: 100%;
        height: 250px;
        margin-right: 0;
        margin-bottom: 20px;
    }
    
    .search-dropdown {
        width: 320px;
        right: -50px;
    }
    
    .header-actions {
        gap: 15px; /* Further reduce gap on smaller screens */
    }
}

@media (max-width: 768px) {
    .search-page {
        padding: 40px 0;
    }
    
    .search-dropdown {
        position: fixed;
        top: 70px; /* Match your header height */
        left: 0;
        right: 0;
        width: 100%;
        height: calc(100vh - 70px);
        border-radius: 0;
    }
    
    .suggestions-items {
        max-height: calc(100vh - 230px);
    }
    
    .search-results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-filter {
        width: 100%;
    }
    
    .search-actions {
        width: 100%;
    }
    
    .search-actions .btn {
        width: 100%;
        text-align: center;
    }
    
    .header-actions {
        gap: 12px; /* Minimal spacing on mobile */
    }
}

@media (max-width: 576px) {
    .search-page {
        padding: 30px 0;
    }
    
    .search-result-item {
        margin-bottom: 20px;
        padding-bottom: 20px;
    }
    
    .result-image {
        height: 200px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    /* Fix extremely small screens */
    .header-actions {
        gap: 10px;
    }
    
    /* Make icons slightly smaller on mobile */
    .header-actions i {
        font-size: 0.9rem;
    }
}