/**
 * QC Technologies - AI Search Styles (Simple Dropdown)
 * No overlay - just a dropdown like Google!
 */

/* Header Layout Adjustments for Search */
.header__inner {
    display: grid !important;
    grid-template-columns: auto auto 1fr auto auto;
    gap: 1rem;
    align-items: center;
}

@media (max-width: 1023px) {
    .header__inner {
        grid-template-columns: auto 1fr auto;
    }
}

/* Search Bar in Header */
.header-search {
    position: relative;
    flex: 1;
    max-width: 500px;
    z-index: 10004; /* High enough to be above video */
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper svg {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: #999;
    pointer-events: none;
    z-index: 2;
}

#aiSearchInput {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 1rem;
    transition: all 0.3s;
    background: #f9fafb;
    position: relative;
    z-index: 2;
}

#aiSearchInput:focus {
    outline: none;
    border-color: #FF6B00;
    background: white;
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.1);
    border-radius: 24px 24px 0 0;
}

#aiSearchInput::placeholder {
    color: #9ca3af;
}

/* Search Dropdown (appears below input) - FIXED positioning to avoid scrollbar issues */
.search-dropdown {
    position: fixed; /* Changed from absolute to fixed */
    /* top, left, width set by JavaScript for precise positioning */
    background: white;
    border: 2px solid #FF6B00;
    border-top: none;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    max-height: calc(100vh - 100px); /* Limit height to viewport - 100px to prevent overflow */
    overflow-y: auto;
    display: none;
    z-index: 10005; /* Above video and all other content */
}

.search-dropdown.active {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Aussie Intro Message */
.search-intro {
    padding: 1rem;
    background: linear-gradient(135deg, #FF6B00 0%, #e55f00 100%);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

/* Search Results List - Scrollable with max 10 items visible */
.search-results-list {
    padding: 0.5rem;
    max-height: 450px; /* Approximately 10 items at ~45px each */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #FF6B00 #f1f1f1;
}

/* Custom scrollbar for webkit browsers */
.search-results-list::-webkit-scrollbar {
    width: 8px;
}

.search-results-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: #FF6B00;
    border-radius: 4px;
}

.search-results-list::-webkit-scrollbar-thumb:hover {
    background: #e55f00;
}

/* Scroll hint at bottom */
.search-scroll-hint {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: #FF6B00;
    background: #fff8f0;
    border-top: 1px solid #ffe4cc;
    font-weight: 600;
    position: sticky;
    bottom: 0;
}

/* Individual Result */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.search-result-item:hover {
    background: #f9fafb;
    transform: translateX(4px);
}

.search-result-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.search-result-placeholder {
    font-size: 1.5rem;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-brand {
    font-size: 0.7rem;
    color: #FF6B00;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-name mark {
    background: #fef3c7;
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-arrow {
    color: #FF6B00;
    font-size: 1.2rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s;
}

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

/* No Results */
.search-no-results {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

.search-no-results p {
    margin: 0.5rem 0;
}

/* ===== MOBILE SEARCH BAR (outside header) ===== */
.mobile-search-bar {
    display: none; /* Hidden on desktop */
}

@media (max-width: 1024px) {
    /* Hide desktop header search on mobile */
    .header-search {
        display: none !important;
    }
    
    /* Mobile search bar is now INSIDE header - no fixed positioning needed */
    .mobile-search-bar {
        display: block !important;
        position: relative !important;
        background: #1a1a1a; /* Match dark header */
        padding: 0.35rem 0 0.75rem 0;
        margin: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .mobile-search-bar .container {
        padding: 0 1rem;
    }
    
    .mobile-search-bar .search-input-wrapper {
        position: relative;
        display: flex;
        align-items: center;
    }
    
    .mobile-search-bar .search-input-wrapper svg {
        position: absolute;
        left: 12px;
        width: 18px;
        height: 18px;
        fill: rgba(255, 255, 255, 0.6);
        pointer-events: none;
        z-index: 2;
    }
    
    .mobile-search-bar input {
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.5rem 1rem 0.5rem 2.5rem;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: #fff;
        outline: none;
    }
    
    .mobile-search-bar input::placeholder {
        color: rgba(255, 255, 255, 0.5);
    }
    
    .mobile-search-bar input:focus {
        background: rgba(255, 255, 255, 0.15);
        border-color: #FF6B00;
        border-radius: 24px 24px 0 0;
    }
    
    /* Mobile search dropdown */
    .mobile-search-bar .search-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border: 2px solid #FF6B00;
        border-top: none;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 8px 24px rgba(0,0,0,0.15);
        max-height: 60vh;
        overflow-y: hidden; /* Let inner list scroll */
        display: none;
        z-index: 10005;
    }
    
    .mobile-search-bar .search-results-list {
        max-height: calc(60vh - 80px); /* Account for intro and scroll hint */
        overflow-y: auto;
    }
    
    .mobile-search-bar .search-dropdown.active {
        display: block;
    }
    
    /* Hide mobile menu search (we're using the new mobile search bar) */
    .mobile-menu__search {
        display: none;
    }
    
    /* No extra body padding needed - search bar is part of header now */
}

@media (max-width: 480px) {
    #aiSearchInput {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    .search-result-item {
        padding: 0.5rem;
    }
    
    .search-result-image {
        width: 40px;
        height: 40px;
    }
    
    .search-result-name {
        font-size: 0.85rem;
    }
}

/* PWA Standalone Mode Fixes */
@media (display-mode: standalone) {
    /* Add safe area padding for notched devices */
    @supports (padding: max(0px)) {
        .header {
            padding-top: max(0px, env(safe-area-inset-top));
        }
    }
}

/* Fix for PWA on mobile */
@media (max-width: 1024px) and (display-mode: standalone) {
    /* Search bar is inside header - no gap possible */
    .mobile-search-bar {
        display: block !important;
        position: relative !important;
    }
    
    /* Ensure hamburger menu works in PWA */
    .menu-toggle {
        display: flex !important;
        z-index: 1001;
        pointer-events: all;
        touch-action: manipulation;
    }
    
    .mobile-menu {
        z-index: 1000;
        pointer-events: all;
    }
}
