/**
 * Live Search Autocomplete Styles
 * Modern, clean autocomplete dropdown for track suggestions
 * Positioned vertically next to the sidebar
 */

/* Main Container - Positioned next to sidebar */
.live-search-autocomplete {
    display: none;
    position: fixed;
    top: 70px;
    left: 280px;
    z-index: 9999;
    background: var(--card-bg, #ffffff);
    border-radius: 0 12px 12px 0;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: visible;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-left: none;
    width: 380px;
    max-height: calc(100vh - 160px);
    flex-direction: column;
    box-sizing: border-box;
}

/* Dark mode support */
[data-theme="dark"] .live-search-autocomplete,
.dark-mode .live-search-autocomplete,
body.night .live-search-autocomplete {
    background: var(--dark-card-bg, #1e1e2d);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.live-search-autocomplete.active {
    display: flex !important;
}

/* Header */
.live-search-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary-color, #6366f1) 0%, var(--secondary-color, #8b5cf6) 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
}

.live-search-header svg {
    opacity: 0.9;
}

.live-search-title {
    flex: 1;
}

.live-search-count {
    font-size: 12px;
    opacity: 0.8;
    font-weight: 500;
}

/* Results Container */
.live-search-results {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 100px;
    max-height: calc(100vh - 280px);
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 8px 0;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    position: relative;
    /* Scrollbar styling for webkit browsers (Chrome, Edge, Safari) */
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

/* Custom scrollbar for webkit browsers */
.live-search-results::-webkit-scrollbar {
    width: 8px;
}

.live-search-results::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.live-search-results::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.live-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* Dark mode scrollbar */
[data-theme="dark"] .live-search-results::-webkit-scrollbar-thumb,
.dark-mode .live-search-results::-webkit-scrollbar-thumb,
body.night .live-search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .live-search-results::-webkit-scrollbar-thumb:hover,
.dark-mode .live-search-results::-webkit-scrollbar-thumb:hover,
body.night .live-search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Firefox scrollbar */
[data-theme="dark"] .live-search-results,
.dark-mode .live-search-results,
body.night .live-search-results {
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Scroll hint indicator */
.live-search-scroll-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(to top, var(--card-bg, #ffffff), transparent);
    color: var(--text-secondary, #6b7280);
    font-size: 12px;
    font-weight: 500;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
    animation: bounce-hint 2s infinite;
}

[data-theme="dark"] .live-search-scroll-hint,
.dark-mode .live-search-scroll-hint,
body.night .live-search-scroll-hint {
    background: linear-gradient(to top, var(--dark-card-bg, #1e1e2d), transparent);
    color: rgba(255, 255, 255, 0.6);
}

.live-search-autocomplete.has-scroll .live-search-scroll-hint {
    display: flex;
}

.live-search-scroll-hint svg {
    animation: bounce-arrow 1.5s ease-in-out infinite;
}

@keyframes bounce-hint {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

@keyframes bounce-arrow {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(4px);
    }
}

/* Scroll indicator - gradient shadow at bottom to show more content */
.live-search-autocomplete::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, transparent, var(--card-bg, #ffffff));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

[data-theme="dark"] .live-search-autocomplete::after,
.dark-mode .live-search-autocomplete::after,
body.night .live-search-autocomplete::after {
    background: linear-gradient(to bottom, transparent, var(--dark-card-bg, #1e1e2d));
}

/* Show scroll indicator when there's scrollable content */
.live-search-autocomplete.has-scroll::after {
    opacity: 1;
}

/* Individual Result Item */
.live-search-item {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.05));
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: hidden;
}

.live-search-item:last-child {
    border-bottom: none;
}

.live-search-item:hover,
.live-search-item.focused {
    background: var(--hover-bg, rgba(99, 102, 241, 0.08));
}

[data-theme="dark"] .live-search-item:hover,
[data-theme="dark"] .live-search-item.focused,
.dark-mode .live-search-item:hover,
.dark-mode .live-search-item.focused,
body.night .live-search-item:hover,
body.night .live-search-item.focused {
    background: rgba(255, 255, 255, 0.05);
}

/* Thumbnail */
.live-search-thumbnail {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--placeholder-bg, #f0f0f0);
}

.live-search-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.live-search-item:hover .live-search-thumbnail img {
    transform: scale(1.05);
}

.live-search-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.live-search-play-overlay svg {
    color: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.live-search-item:hover .live-search-play-overlay,
.live-search-item.focused .live-search-play-overlay {
    opacity: 1;
}

/* Track Info */
.live-search-info {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.live-search-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    flex-wrap: nowrap;
}

.live-search-track-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #1a1a2e);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

[data-theme="dark"] .live-search-track-title,
.dark-mode .live-search-track-title,
body.night .live-search-track-title {
    color: #ffffff;
}

/* Trend Badges */
.trend-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.trend-badge.hot {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: #ffffff;
    animation: pulse-hot 2s infinite;
}

.trend-badge.up {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: #ffffff;
}

.trend-badge.down {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

@keyframes pulse-hot {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 107, 107, 0);
    }
}

/* Artist Name */
.live-search-artist {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

[data-theme="dark"] .live-search-artist,
.dark-mode .live-search-artist,
body.night .live-search-artist {
    color: rgba(255, 255, 255, 0.6);
}

.verified-badge {
    flex-shrink: 0;
}

/* Stats Row */
.live-search-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    width: 100%;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-tertiary, #9ca3af);
}

.stat-item svg {
    opacity: 0.7;
}

.stat-item.views svg {
    color: var(--primary-color, #6366f1);
}

.stat-item.likes svg {
    color: #ef4444;
}

.stat-item.downloads svg {
    color: #10b981;
}

/* Meta (Duration) */
.live-search-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    min-width: 50px;
}

.live-search-duration {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    background: var(--badge-bg, rgba(0, 0, 0, 0.05));
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

[data-theme="dark"] .live-search-duration,
.dark-mode .live-search-duration,
body.night .live-search-duration {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

/* Loading State */
.live-search-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary, #6b7280);
    gap: 12px;
}

.live-search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, rgba(0, 0, 0, 0.1));
    border-top-color: var(--primary-color, #6366f1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.live-search-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary, #6b7280);
    gap: 12px;
    text-align: center;
}

.live-search-empty svg {
    opacity: 0.4;
}

/* Simplebar customization inside autocomplete */
.live-search-results .simplebar-scrollbar::before {
    background: var(--primary-color, #6366f1);
    opacity: 0.5;
}

.live-search-results .simplebar-scrollbar.simplebar-visible::before {
    opacity: 0.7;
}

/* Mobile Responsive - Hide autocomplete on mobile devices */
@media (max-width: 991px) {
    .live-search-autocomplete {
        display: none !important;
    }
    
    .live-search-autocomplete.active {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 992px) and (max-width: 1200px) {
    .live-search-autocomplete {
        width: 340px;
    }
}

/* Visual connector to sidebar */
.live-search-autocomplete::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color, #6366f1) 0%, var(--secondary-color, #8b5cf6) 50%, transparent 100%);
    opacity: 0.8;
}

/* Animation for appearing */
.live-search-autocomplete.active {
    animation: slideInFromSidebar 0.25s ease-out;
}

@keyframes slideInFromSidebar {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Smooth transition for container positioning */
.sfy_search,
.head_search_cont {
    position: relative;
}

/* Ensure search form has relative positioning for dropdown */
.search_cont {
    position: relative;
}

/* Sidebar specific adjustments - fixed position next to sidebar */
.ma_sidebar .sfy_search {
    position: static;
    z-index: 100;
}

/* Header search specific adjustments - dropdown below */
.head_search_cont .live-search-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    min-width: 400px;
    max-width: 500px;
    border-radius: 12px;
    border-left: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
}

.head_search_cont .live-search-autocomplete::before {
    display: none;
}
