/* ===== SEARCH MOBILE DISPLAY FIX ===== */

/* Fix search results display on mobile screens */
@media (max-width: 768px) {
    /* Search Section Mobile Optimization */
    .search-section {
        padding: 15px 0;
        position: relative;
        z-index: 999;
    }
    
    .search-container {
        position: relative;
        max-width: 100%;
        margin: 0 15px;
        z-index: 1000;
    }
    
    /* Search Results Mobile Fix */
    .search-results {
        position: absolute;
        top: calc(100% + 10px);
        left: 15px;
        right: 15px;
        width: calc(100vw - 30px);
        max-width: calc(100vw - 30px);
        background: white;
        border-radius: 12px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
        max-height: 70vh;
        overflow-y: auto;
        z-index: 1001;
        margin: 0;
        border: 1px solid rgba(252, 108, 133, 0.2);
        -webkit-overflow-scrolling: touch;
    }
    
    /* Search Result Items Mobile */
    .search-result-item {
        display: flex;
        align-items: center;
        padding: 15px;
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
        transition: all 0.3s ease;
        min-height: 80px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(252, 108, 133, 0.1);
    }
    
    .search-result-item:hover,
    .search-result-item:active {
        background: rgba(252, 108, 133, 0.05);
        transform: none; /* Remove transform on mobile for better performance */
    }
    
    .search-result-item:last-child {
        border-bottom: none;
    }
    
    /* Search Result Image Mobile */
    .search-result-image {
        width: 60px;
        height: 60px;
        object-fit: cover;
        border-radius: 8px;
        margin-right: 15px;
        flex-shrink: 0;
    }
    
    /* Search Result Info Mobile */
    .search-result-info {
        flex: 1;
        min-width: 0; /* Prevent text overflow */
    }
    
    .search-result-name {
        font-weight: 600;
        color: #333;
        margin-bottom: 5px;
        font-size: 15px;
        line-height: 1.3;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .search-result-price {
        color: #FC6C85;
        font-weight: 600;
        font-size: 14px;
        margin-bottom: 2px;
    }
    
    .search-result-category {
        color: #666;
        font-size: 12px;
        text-transform: capitalize;
    }
    
    /* No Results Mobile */
    .no-results {
        padding: 40px 20px;
        text-align: center;
        color: #666;
        font-style: italic;
    }
    
    .no-results i {
        font-size: 48px;
        color: #ddd;
        margin-bottom: 15px;
        display: block;
    }
    
    .no-results p {
        margin: 10px 0 5px 0;
        font-size: 16px;
        font-weight: 500;
    }
    
    .no-results small {
        font-size: 14px;
        color: #999;
    }
    
    /* Search Input Mobile */
    .search-input {
        padding: 14px 20px;
        font-size: 16px;
        border-radius: 25px;
        width: 100%;
        box-sizing: border-box;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    /* Search Button Mobile */
    .search-btn {
        padding: 14px 18px;
        min-width: 48px;
        height: 48px;
        border-radius: 25px;
        margin-right: 3px;
    }
    
    /* Ensure search results are above other content */
    .search-results {
        z-index: 1002 !important;
    }
    
    /* Fix for search results positioning relative to viewport */
    .search-section .container {
        position: relative;
    }
    
    /* Backdrop for search results */
    .search-results::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.1);
        z-index: -1;
        pointer-events: none;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .search-results {
        left: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        border-radius: 10px;
    }
    
    .search-result-item {
        padding: 12px;
        min-height: 70px;
    }
    
    .search-result-image {
        width: 50px;
        height: 50px;
        margin-right: 12px;
    }
    
    .search-result-name {
        font-size: 14px;
    }
    
    .search-result-price {
        font-size: 13px;
    }
    
    .search-result-category {
        font-size: 11px;
    }
    
    .search-input {
        padding: 12px 18px;
        font-size: 16px;
    }
    
    .search-btn {
        padding: 12px 16px;
        min-width: 44px;
        height: 44px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .search-results {
        max-height: 50vh;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .search-result-item {
        -webkit-tap-highlight-color: rgba(252, 108, 133, 0.2);
        touch-action: manipulation;
    }
    
    .search-result-item:active {
        background: rgba(252, 108, 133, 0.1);
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
}

/* Ensure search works properly on all mobile browsers */
.search-input:focus {
    outline: none;
    border-color: #FC6C85;
    box-shadow: 0 0 0 3px rgba(252, 108, 133, 0.2);
}

/* Fix for iOS zoom prevention */
@supports (-webkit-touch-callout: none) {
    .search-input {
        font-size: 16px !important;
        transform: translateZ(0);
        -webkit-appearance: none;
        border-radius: 25px;
    }
}

/* Performance optimizations for mobile search */
.search-results {
    contain: layout style paint;
    will-change: transform, opacity;
}

.search-result-item {
    contain: layout style;
}

/* Smooth scrolling for search results */
.search-results {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Loading state for search */
.search-results.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.search-results.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #FC6C85;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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