/* ===================================
   Search Box - Remove ALL nested borders
   =================================== */

.search-box,
.search-box *,
.search-box > div,
.search-box > div > div,
.search-box div {
    border: none !important;
    outline: none !important;
}

/* Re-apply only the outer border we want */
.search-box {
    border: 1.5px solid transparent !important;
    transition: border-color 0.2s ease;
}

.search-box:has(#searchInput:focus) {
    border: 1.5px solid #7275F2 !important;
}

.search-box.focused {
    border: 1.5px solid #7275F2 !important;
}

/* ===================================
   Search Input - Remove ALL borders
   =================================== */

#searchInput,
#headerSearchInput,
#mobileSearchInput {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

#searchInput:focus,
#searchInput:active,
#searchInput:hover,
#searchInput:focus-visible,
#searchInput:focus-within,
#headerSearchInput:focus,
#headerSearchInput:active,
#mobileSearchInput:focus,
#mobileSearchInput:active {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* ===================================
   Header Search Box
   =================================== */

.header-search-box {
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
}

.header-search-box:hover {
    background: #f3f4f6;
}

.header-search-box.focused {
    background: white;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#header-search-wrapper,
#mobile-search-wrapper {
    position: relative;
}

/* ===================================
   Search Dropdown (Header & Mobile)
   =================================== */

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    max-height: 520px;
    overflow-y: auto;
    z-index: 9999;
}

/* Header search dropdown */
#header-search-wrapper .search-dropdown {
    left: auto;
    right: 0;
    min-width: 320px;
}

/* Home page search - appended to body */
body > .search-dropdown-home {
    position: fixed;
    z-index: 99999;
    max-height: 520px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Mobile search dropdown */
#mobile-search-wrapper .search-dropdown {
    left: 0;
    right: 0;
    max-height: 300px;
}

/* Section Headers */
.search-section {
    padding: 0;
}

.search-section:not(:first-child) {
    border-top: 1px solid #f3f4f6;
}

.search-section-header {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #fafafa;
}

/* Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.search-result-item:hover,
.search-result-item.selected {
    background: #f8fafc;
}

/* Category Items */
.search-category-icon {
    width: 20px;
    height: 20px;
    color: #9ca3af;
    flex-shrink: 0;
}

.search-category-item:hover .search-category-icon,
.search-category-item.selected .search-category-icon {
    color: #6366f1;
}

/* Product Items */
.search-product-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.search-product-logo img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* Item Name */
.search-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-item:hover .search-item-name,
.search-result-item.selected .search-item-name {
    color: #6366f1;
}

/* No Results */
.search-no-results {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 18px;
    color: #9ca3af;
}

.search-no-results svg {
    color: #d1d5db;
    flex-shrink: 0;
}

.search-no-results span {
    font-size: 14px;
    font-weight: 500;
}

/* Loading Skeleton */
.search-loading {
    padding: 6px 0;
}

.search-loading .skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}

.search-loading .skeleton-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    flex-shrink: 0;
}

.search-loading .skeleton-text {
    height: 14px;
    width: 60%;
    border-radius: 6px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ===================================
   Home Page Autocomplete (Legacy)
   =================================== */

.autocomplete-suggestions {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background: #ffffff;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 9999;
    box-sizing: border-box;
}

.autocomplete-suggestions:empty {
    display: none !important;
}

.autocomplete-suggestion {
    padding: 0;
    cursor: pointer;
    border: none !important;
    border-bottom: 1px solid #f3f4f6 !important;
}

.autocomplete-suggestion:last-child {
    border-bottom: none !important;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background: #f8fafc;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: none !important;
    outline: none !important;
}

.autocomplete-item-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.autocomplete-item-logo img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border: none !important;
}

.autocomplete-item-name {
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading Skeleton */
.autocomplete-loading-skeleton {
    padding: 6px 0;
}

.skeleton-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
}

.skeleton-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    flex-shrink: 0;
}

.skeleton-text {
    height: 16px;
    width: 60%;
    border-radius: 6px;
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    animation-delay: 0.1s;
}

.skeleton-item:nth-child(2) .skeleton-text {
    width: 45%;
    animation-delay: 0.2s;
}

.skeleton-item:nth-child(3) .skeleton-text {
    width: 55%;
    animation-delay: 0.3s;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* No Results */
.autocomplete-no-suggestion {
    padding: 0;
}

.autocomplete-no-results {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 18px;
    color: #9ca3af;
}

.autocomplete-no-results svg {
    color: #d1d5db;
    flex-shrink: 0;
}

.autocomplete-no-results span {
    font-size: 14px;
    font-weight: 500;
}

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

@media (max-width: 1024px) {
    #header-search-wrapper .header-search-box {
        width: 240px;
    }
}

@media (max-width: 900px) {
    #header-search-wrapper .header-search-box {
        width: 200px;
    }
    
    #header-search-wrapper .header-search-box input::placeholder {
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .search-dropdown {
        border-radius: 10px;
    }
    
    #header-search-wrapper .search-dropdown {
        min-width: 0;
        left: 0;
        right: 0;
    }
    
    .search-section-header {
        padding: 8px 14px 5px;
        font-size: 10px;
    }
    
    .search-result-item {
        padding: 10px 14px;
        gap: 10px;
    }
    
    .search-product-logo {
        width: 28px;
        height: 28px;
    }
    
    .search-product-logo img {
        width: 18px;
        height: 18px;
    }
    
    .search-item-name {
        font-size: 13px;
    }
    
    .search-category-icon {
        width: 18px;
        height: 18px;
    }
    
    .autocomplete-suggestions {
        border-radius: 10px;
        margin-top: 6px;
    }
    
    .autocomplete-item {
        padding: 12px 14px;
        gap: 12px;
    }
    
    .autocomplete-item-logo {
        width: 36px;
        height: 36px;
    }
    
    .autocomplete-item-logo img {
        width: 24px;
        height: 24px;
    }
    
    .autocomplete-item-name {
        font-size: 14px;
    }
    
    .skeleton-item {
        padding: 12px 14px;
        gap: 12px;
    }
    
    .skeleton-logo {
        width: 36px;
        height: 36px;
    }
}

/* ===================================
   Scrollbar Styling
   =================================== */

.search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}