/* ===================================
   PROFESSIONAL LIVE SEARCH STYLES
   =================================== */

/* Search Container Enhancements */
.navbar-search {
    position: relative;
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    background: #fff;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    overflow: visible; /* Changed from hidden to visible for dropdown */
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.search-input-wrapper:focus-within {
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 4px 20px rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
}

/* Category Dropdown */
.search-category {
    position: relative;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
}

.category-select {
    padding: 14px 16px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    min-width: 150px;
    outline: none;
}

.category-select:hover {
    background: #e9ecef;
}

/* Search Input */
.search-input {
    flex: 1;
    padding: 14px 20px;
    border: none;
    font-size: 16px;
    color: #333;
    background: transparent;
    outline: none;
    font-weight: 400;
}

.search-input::placeholder {
    color: #8a8a8a;
    font-weight: 400;
}

.search-input:focus::placeholder {
    opacity: 0.6;
}

/* Search Button */
.search-button {
    background: var(--primary-color, #007bff);
    border: none;
    padding: 14px 24px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-button:hover {
    background: var(--primary-dark, #0056b3);
    transform: scale(1.02);
}

.search-button:active {
    transform: scale(0.98);
}

/* ===================================
   LIVE SEARCH DROPDOWN
   =================================== */

.live-search-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 480px;
    overflow: hidden;
    width: 100%;
}

.live-search-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-dropdown-content {
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

.search-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.search-dropdown-content::-webkit-scrollbar-track {
    background: #f7fafc;
}

.search-dropdown-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.search-dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Search Sections */
.search-section {
    padding: 20px 0;
    border-bottom: 1px solid #f1f3f4;
}

.search-section:last-child {
    border-bottom: none;
}

.search-section-header {
    padding: 0 20px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-section-header i {
    font-size: 12px;
    opacity: 0.7;
}

/* Search History */
.search-history {
    padding: 16px 20px;
}

.search-history-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 12px;
}

.search-history-title {
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-history {
    font-size: 12px;
    color: #dc3545;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.clear-history:hover {
    background: #f8f9fa;
}

/* Search Items */
.search-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
}

.search-item:hover {
    background: #f8f9fa;
    border-left-color: var(--primary-color, #007bff);
    color: inherit;
    text-decoration: none;
}

.search-item:focus {
    outline: none;
    background: #e3f2fd;
    border-left-color: var(--primary-color, #007bff);
}

/* Search Item Content */
.search-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    color: #6c757d;
    flex-shrink: 0;
    overflow: hidden;
}

.category-icon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-meta {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--success-color, #28a745);
    margin-left: 12px;
    flex-shrink: 0;
}

/* Product Search Items */
.product-search-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
}

.product-search-item:hover {
    background: #f8f9fa;
    border-left-color: var(--primary-color, #007bff);
    color: inherit;
    text-decoration: none;
}

.search-product-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 16px;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #ddd;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.product-category {
    font-size: 12px;
    color: #6c757d;
}

.product-price {
    font-size: 16px;
    font-weight: 600;
    color: var(--success-color, #28a745);
    margin-left: 16px;
    flex-shrink: 0;
}

/* Suggestion Highlights */
.search-highlight {
    background: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Loading State */
.search-loading {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.search-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.search-empty-icon {
    font-size: 48px;
    color: #dee2e6;
    margin-bottom: 16px;
}

.search-empty-text {
    font-size: 14px;
    margin-bottom: 8px;
}

.search-empty-suggestion {
    font-size: 12px;
    color: #8a8a8a;
}

/* Quick Actions */
.search-quick-actions {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.quick-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-action-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 12px;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quick-action-btn:hover {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: white;
    text-decoration: none;
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Specific fixes for navbar positioning */
.navbar-main .navbar-search {
    position: relative;
    z-index: 10;
}

.navbar-main .search-form {
    position: relative;
    z-index: 10;
}

.navbar-main .live-search-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 9999;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

@media (max-width: 768px) {
    .navbar-search {
        max-width: none;
        margin: 0;
    }
    
    .search-input-wrapper {
        border-radius: 8px;
    }
    
    .category-select {
        min-width: 100px;
        padding: 12px 8px;
        font-size: 13px;
    }
    
    .search-input {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .search-button {
        padding: 12px 20px;
    }
    
    .live-search-dropdown {
        border-radius: 0 0 12px 12px;
        max-height: 360px;
    }
    
    .search-section {
        padding: 16px 0;
    }
    
    .search-item,
    .product-search-item {
        padding: 12px 16px;
    }
    
    .search-product-image {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }
    
    .product-name {
        font-size: 13px;
    }
    
    .product-price {
        font-size: 14px;
        margin-left: 12px;
    }
}

@media (max-width: 480px) {
    .search-input-wrapper {
        flex-direction: column;
    }
    
    .search-category {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .category-select {
        padding: 10px 12px;
        min-width: auto;
        width: 100%;
    }
    
    .search-input {
        padding: 10px 12px;
    }
    
    .search-button {
        padding: 10px 16px;
        margin-top: 1px;
    }
}

/* ===================================
   ACCESSIBILITY ENHANCEMENTS
   =================================== */

.search-item:focus,
.product-search-item:focus {
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: -2px;
}

.search-dropdown-content {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    .live-search-dropdown,
    .search-item,
    .product-search-item,
    .search-button {
        transition: none;
    }
    
    .search-loading-spinner {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-input-wrapper {
        border-width: 3px;
        border-color: #000;
    }
    
    .search-input-wrapper:focus-within {
        border-color: #0066cc;
    }
    
    .search-item:hover,
    .product-search-item:hover {
        background: #e6f3ff;
        border-left-color: #000;
    }
}

/* ===================================
   SEARCH ANIMATIONS
   =================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-item,
.product-search-item {
    animation: fadeInUp 0.3s ease-out;
}

.search-item:nth-child(1) { animation-delay: 0.05s; }
.search-item:nth-child(2) { animation-delay: 0.1s; }
.search-item:nth-child(3) { animation-delay: 0.15s; }
.search-item:nth-child(4) { animation-delay: 0.2s; }
.search-item:nth-child(5) { animation-delay: 0.25s; }

/* Keyboard navigation highlight */
.search-item.keyboard-focused,
.product-search-item.keyboard-focused {
    background: #e3f2fd;
    border-left-color: var(--primary-color, #007bff);
}