/* General Styles */
html {
    height: 100%;
    overflow-x: hidden; /* Prevent horizontal overscroll globally */
}

/* --- Advanced Analytics Section Styles --- */
.analytics-section {
    background: rgba(30, 12, 60, 0.92);
    border-radius: 18px;
    margin: 2rem auto 2rem auto;
    padding: 2rem 1.5rem 2rem 1.5rem;
    max-width: 650px;
    box-shadow: 0 8px 32px 0 rgba(93, 24, 220, 0.18);
    border: 1.5px solid rgba(147, 51, 234, 0.18);
    color: #e0e0ff;
}

.stats-container {
    margin-bottom: 1.5rem;
}

.export-history-btn, .export-btn {
    background: linear-gradient(90deg, #9333ea 0%, #a5b4fc 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.15);
}
.export-history-btn:hover, .export-btn:hover {
    background: linear-gradient(90deg, #a5b4fc 0%, #9333ea 100%);
    box-shadow: 0 4px 16px rgba(147, 51, 234, 0.22);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.2rem;
    margin-bottom: 1.2rem;
    background: rgba(26, 0, 51, 0.7);
    border-radius: 8px;
    overflow: hidden;
}
.history-table th, .history-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(147, 51, 234, 0.12);
    color: #e0e0ff;
    text-align: left;
}
.history-table th {
    background: rgba(147, 51, 234, 0.12);
    font-weight: 700;
}

@media (max-width: 700px) {
    .analytics-section {
        padding: 1rem 0.5rem;
        max-width: 98vw;
    }
    .history-table th, .history-table td {
        padding: 6px 5px;
        font-size: 0.93rem;
    }
}

/* Chart.js overrides for dark mode */
.analytics-section canvas {
    background: transparent !important;
    border-radius: 10px;
    margin-bottom: 1.2rem;
}

body {
    font-family: 'Orbitron', 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #0d0d1f 0%, #1a0033 100%);
    color: #e0e0ff;
    min-height: 100vh;
    overflow-x: hidden; /* Reinforce horizontal containment */
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Navbar Styles */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(90deg, rgba(17, 24, 39, 0.95), rgba(49, 46, 129, 0.9));
    backdrop-filter: blur(15px) saturate(150%);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 3px 15px rgba(147, 51, 234, 0.3);
    border-bottom: 1px solid rgba(147, 51, 234, 0.2);
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent navbar horizontal scroll */
}

.site-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #d8b4fe;
}

.nav-links {
    display: flex;
    gap: 2rem;
    margin-left: auto;
}

.nav-links a {
    color: #d8b4fe;
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    position: relative;
    transition: all 0.4s ease;
}

.nav-links a::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, #9333ea, #a5b4fc);
    opacity: 0;
    border-radius: 5px;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.nav-links a:hover::before {
    opacity: 0.2;
}

.nav-links a:hover {
    color: #fff;
    transform: translateY(-2px);
    text-shadow: 0 0 8px rgba(147, 51, 234, 0.7);
}

/* Mobile Navbar Fix */
@media (max-width: 768px) {
    .navbar {
        flex-direction: row !important;
        padding: 0.5rem; /* Reduced from 1rem */
        gap: 1rem;
    }
    
    .nav-links {
        margin-left: auto;
        font-size: 0.9rem;
        gap: 0.75rem;
    }
    
    .site-name {
        display: none;
    }
    
    .nav-links a {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Main Content Styles */
main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    overflow-x: hidden; /* Prevent horizontal overscroll */
    overflow-y: auto; /* Scroll vertically within main */
    box-sizing: border-box;
}

/* Horizontal Scroll Sections */
.song-section {
    margin: 3rem 0;
    padding: 0.75rem;
    background: rgba(17, 24, 39, 0.5);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(147, 51, 234, 0.2);
    overflow: visible; /* Allow scroll-container to extend beyond bounds */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
    position: sticky; /* Keep header fixed */
    left: 0;
    top: 0; /* Stick to the top of the section */
    background: rgba(17, 24, 39, 0.5); /* Match section background */
    z-index: 10; /* Ensure header stays above scrolling tiles */
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, #9333ea, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text; /* Added standard property for compatibility */
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.4);
    padding: 0.3rem;
    position: relative;
}

.scroll-container {
    display: flex;
    flex-wrap: nowrap; /* Prevent wrapping */
    overflow-x: auto; /* Enable horizontal scroll */
    gap: 1.5rem; /* 24px gap between items */
    padding: 1rem 25rem 1rem 1rem; /* Default padding, overridden for desktop */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
    scrollbar-width: none; /* Hide scrollbar */
    overscroll-behavior-x: contain; /* Limit horizontal overscroll */
    box-sizing: border-box; /* Ensure padding is included in width calculations */
    white-space: nowrap; /* Ensure content doesn't wrap */
}

/* Hide scrollbar */
.scroll-container::-webkit-scrollbar {
    display: none;
}

/* Add buffer space after last item */
.scroll-container::after {
    content: '';
    display: block;
    width: 25rem; /* Default buffer, overridden for desktop */
    flex-shrink: 0;
}

/* Desktop-specific adjustments to prevent overscrolling */
@media (min-width: 769px) {
    .scroll-container {
        padding: 1rem 100px 1rem 1rem; /* Reduced to minimize extra space */
    }
    
    .scroll-container::after {
        width: 0; /* No buffer to avoid extra scrolling */
    }
}

/* Song Item Styles */
.song-item {
    flex: 0 0 200px; /* Fixed width, no shrinking or growing */
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(49, 46, 129, 0.4), rgba(17, 24, 39, 0.6));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.4s ease;
}

.song-item:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 40px rgba(147, 51, 234, 0.5);
}

.thumbnail-container {
    position: relative;
    width: 100%; /* Match song-item width */
    height: 200px;
    aspect-ratio: 1;
    overflow: hidden;
}

.thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.5s ease;
}

.song-item:hover .thumbnail {
    transform: scale(1.15) rotate(3deg);
    filter: brightness(1.3) contrast(1.1);
}

.song-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e0e0ff;
    background: linear-gradient(to top, rgba(17, 24, 39, 0.9), transparent);
    text-shadow: 0 0 8px rgba(147, 51, 234, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

.song-item:hover .song-title {
    background: linear-gradient(to top, rgba(147, 51, 234, 0.8), transparent);
}

.hover-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    background: rgba(147, 51, 234, 0.8);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.6);
}

.song-item:hover .hover-play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Song Actions Toggle Bar */
.song-actions-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px; /* Reduced width for single button */
    padding: 8px;
    background: linear-gradient(270deg, rgba(0,0,0,0.8), rgba(0,0,0,0.4), transparent);
    display: flex;
    justify-content: center; /* Center the single button */
    align-items: center;
    z-index: 20;
    opacity: 1;
    border-radius: 0 8px 0 0;
}

/* Only hide on PC/Desktop, but not on mobile */
@media (min-width: 769px) {
    .song-actions-toggle {
        opacity: 0;
    }
    
    .song-item:hover .song-actions-toggle {
        opacity: 1;
    }
}

.song-menu-btn {
    background: linear-gradient(45deg, #9333ea, #a5b4fc);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px; /* Slightly bigger font */
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background 0.2s ease;
}

.song-menu-btn:hover {
    transform: scale(1.15);
    background: linear-gradient(45deg, #a5b4fc, #9333ea);
}

/* Mobile Adjustments for Song Actions */
@media (max-width: 768px) {
    .song-actions-toggle {
        width: 40px; /* Reduced width for single button */
        opacity: 1;
        padding: 5px;
    }
    
    .song-menu-btn {
        width: 28px; /* Slightly larger for better visibility/tappability on mobile */
        height: 28px;
        font-size: 16px;
    }
}

/* Search Components */
.search-section {
    padding: 1rem 2rem;
    background: rgba(15, 15, 30, 0.8);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

#search-bar {
    width: 100%;
    padding: 1rem;
    margin: 2rem 0;
    border: none;
    border-radius: 25px;
    background: rgba(49, 46, 129, 0.4);
    color: #e0e0ff;
    font-size: 1rem;
    box-shadow: 0 3px 15px rgba(147, 51, 234, 0.2);
    z-index: 101; /* Ensure above navbar */
    pointer-events: auto; /* Ensure interactivity */
    box-sizing: border-box;
}

#search-bar:focus {
    outline: none;
    box-shadow: 0 3px 20px rgba(147, 51, 234, 0.5);
    background: rgba(49, 46, 129, 0.6);
    transform: scale(1.02);
}

#search-results-container {
    display: none;
    position: relative;
    z-index: 1001; /* Higher than navbar */
    background: rgba(15, 15, 30, 0.95);
    border-radius: 0 0 10px 10px;
    margin: -1rem 2rem 2rem;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#search-results-container .scroll-container {
    overscroll-behavior-x: contain;
    padding-bottom: 10px;
}

/* Music Player Styles */
#music-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 2000;
    backdrop-filter: blur(10px);
    height: 80px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: hidden;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 250px;
    flex-shrink: 1;
}

#player-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-grow: 1;
    justify-content: center;
}

.player-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: opacity 0.3s;
    width: 20px;
    height: 20px;
}

.player-controls button:hover {
    opacity: 0.8;
}

/* Custom seek bar styling */
#seek-bar {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    margin: 0 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
    position: relative;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    /* Add some space for the thumb to move */
    margin: 10px 1rem;
}

/* Progress fill for Webkit */
#seek-bar::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    height: 4px;
    background: linear-gradient(to right, #9333ea 0%, #9333ea var(--progress, 0%), rgba(255, 255, 255, 0.2) var(--progress, 0%));
    border-radius: 2px;
}

/* Progress fill for Firefox */
#seek-bar::-moz-range-track {
    -moz-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

#seek-bar::-moz-range-progress {
    background-color: #9333ea;
    height: 4px;
    border-radius: 2px;
}

/* Thumb styling */
#seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #9333ea;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -5px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.1s;
    transform: scale(0.8);
}

#seek-bar:hover::-webkit-slider-thumb,
#seek-bar:active::-webkit-slider-thumb,
#seek-bar:focus::-webkit-slider-thumb {
    opacity: 1;
    transform: scale(1);
}

#seek-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #9333ea;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.1s;
}

#seek-bar:hover::-moz-range-thumb,
#seek-bar:active::-moz-range-thumb,
#seek-bar:focus::-moz-range-thumb {
    opacity: 1;
    transform: scale(1.2);
}

/* For Firefox progress fill */
#seek-bar.seeking::-moz-range-progress {
    background-color: #7b1fa2; /* Slightly darker purple when seeking */
}

/* Explicitly Hide All Volume Elements */
.volume-controls, 
#volume-controls, 
.volume-slider, 
#volume-bar, 
#volume-label, 
.volume-icon, 
#volume-percentage {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(90deg, rgba(17, 24, 39, 0.9), rgba(49, 46, 129, 0.85));
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.3);
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow-x: hidden; /* Prevent footer horizontal scroll */
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Navbar */
    .navbar {
        padding: 0.5rem; /* Reduced from 1rem */
    }

    /* Main (only adjusted for song-section spacing) */
    main {
        padding: 2rem;
        padding-bottom: 80px; /* Space for music player */
        flex: 1 0 auto;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain; /* Reinforce no bounce */
    }

    /* Song Sections (Haryanvi Collection, Trending Bhojpuri) */
    .song-section {
        margin: 1rem 0; /* Reduced from 3rem */
        padding: 0.5rem; /* Reduced from 0.75rem */
    }

    .section-header {
        margin-bottom: 1rem; /* Reduced from 1.5rem */
        padding: 0 0.75rem; /* Reduced from 0 1rem */
    }

    .scroll-container {
        padding: 0.75rem 30rem 0.75rem 1rem; /* Reduced vertical padding from 1rem */
    }

    /* Search Bar */
    .search-section {
        padding: 0.5rem 1rem;
    }
    
    #search-bar {
        padding: 0.75rem; /* Reduced from 1rem */
        margin: 1rem 0; /* Reduced from 2rem 0 */
    }

    /* Footer */
    footer {
        padding: 1rem; /* Reduced from 2rem */
        margin-top: 0;
    }

    /* Unchanged Mobile Styles */
    .song-item {
        flex: 0 0 150px; /* Adjusted for smaller screens */
    }

    .thumbnail-container {
        width: 150px;
        height: 150px;
    }

    .scroll-container::after {
        width: 30rem; /* Retains perfect fit for Android */
    }

    /* Fix Overscroll (Mobile) */
    html, body {
        height: 100%;
        overflow-x: hidden; /* Reinforce horizontal containment */
    }

    body {
        overflow-y: auto; /* Allow vertical scroll */
        overscroll-behavior-y: contain; /* Prevent vertical overscroll */
    }

    /* Mobile Music Player Fix */
    #music-player {
        flex-wrap: nowrap;
        padding: 0.5rem 0.5rem;
        gap: 0.5rem;
        height: 80px;
        max-width: 412px;
        z-index: 2000;
    }

    .player-info {
        flex-direction: row;
        min-width: 0;
        gap: 0.3rem;
        flex-shrink: 1;
        max-width: 150px;
    }

    #player-thumbnail {
        width: 40px;
        height: 40px;
    }

    .player-controls {
        flex-grow: 0;
        gap: 1rem;
        justify-content: flex-start;
        margin-left: 0;
        padding-right: 0;
    }

    .player-controls button {
        font-size: 1.5rem;
        padding: 0.4rem;
        width: 30px;
        height: 30px;
    }

    #seek-bar {
        position: absolute;
        top: 5px;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        height: 6px;
        max-width: 412px;
        background: rgba(255, 255, 255, 0.3);
        accent-color: #9333ea;
    }

    .player-info .song-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 90px;
        font-size: 0.85rem;
        position: static;
        background: none;
        padding: 0;
        color: inherit;
    }
}

/* Logo Styling - Keep this as it's used in multiple pages */
.logo {
    width: 100px;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

/* Logo Styling */
.logo {
    width: 100px;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 1024px) { 
    .logo {
        width: 90px;
    }
}

@media (max-width: 768px) {
    .logo {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .logo {
        width: 70px;
    }
}

.site-name {
    display: none !important;
}

/* Mobile First Approach */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(90deg, rgba(17, 24, 39, 0.95), rgba(49, 46, 129, 0.9));
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

.nav-links {
    display: flex;
    gap: 1rem;
    margin-left: auto;
    align-items: center;
}

/* Contact Button Fix */
.nav-links a[href="/contact"] {
    color: #d8b4fe;
    text-decoration: none;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    flex-shrink: 0;
}

/* Search Results Styling */
.no-results, .search-error {
    text-align: center;
    padding: 2rem;
    color: #a0a0c0;
}

.no-results i, .search-error i {
    font-size: 2rem;
    margin-bottom: 1rem;
    display: block;
    color: #7d5fff;
}

.search-error i {
    color: #ff5f5f;
}

/* Mobile Search */
@media (max-width: 768px) {
    #search-results-container {
        margin: -0.5rem 1rem 1rem;
    }
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 1rem;
        flex-wrap: nowrap;
    }
    
    .nav-links {
        gap: 0.75rem;
        font-size: 0.9rem;
        padding-left: 0.5rem;
    }
    
    .nav-links a[href="/contact"] {
        padding: 0.4rem 0.8rem;
        margin-left: auto;
    }
    
    .contact-container {
        margin: 1rem;
        padding: 1.25rem;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .info-item {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }
    
    .social-links {
        margin-top: 1.5rem;
        justify-content: center;
    }
}

/* Desktop Optimization */
@media (min-width: 769px) {
    .navbar {
        padding: 1rem 2rem;
    }
    
    .nav-links {
        gap: 2rem;
    }
    
    .nav-links a[href="/contact"] {
        padding: 0.5rem 1.25rem;
    }
}

/* Adjust player layout for removed controls */
#music-player {
    padding-right: 1rem !important;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .player-controls {
        margin-right: 0 !important;
        padding-right: 0 !important;
    }
    
    #music-player {
        grid-template-columns: [thumbnail] 40px [info] 1fr [controls] auto;
    }
}

.popup-notification {
    position: fixed;
    bottom: 30px; /* Increased from 20px to ensure it’s not cut off */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9); /* Slightly more opaque for visibility */
    color: #ffffff; /* Explicit white */
    padding: 12px 24px; /* Slightly larger padding */
    border-radius: 10px;
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.4); /* Stronger shadow */
    font-size: 18px; /* Larger text */
    font-family: Arial, sans-serif;
    z-index: 9999; /* Very high z-index to ensure it’s on top */
    min-width: 200px; /* Minimum width to avoid shrinking */
    text-align: center; /* Center the text */
    opacity: 0; /* Start invisible */
    animation: fadeInOut 3s ease-in-out forwards; /* Matches JS timeout */
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    90% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(30px); /* Start lower */
    }
    20% {
        opacity: 1;
        transform: translateX(-50%) translateY(0); /* Move up */
    }
    80% {
        opacity: 1;
        transform: translateX(-50%) translateY(0); /* Stay in place */
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px); /* Move up and fade */
    }
}

.nav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #6366f1;
    transition: transform 0.3s ease;
}

.nav-avatar:hover {
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .nav-avatar {
        width: 35px;
        height: 35px;
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 3rem 2rem;
    margin-top: auto;
    background: rgba(17, 24, 39, 0.9);
    position: relative;
    z-index: 2;
    width: 100%;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.footer a {
    display: none;
}

.recently-played-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
}

.control-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.play-all-btn {
    background: rgba(76, 175, 80, 0.3);
}

.play-all-btn:hover {
    background: rgba(76, 175, 80, 0.5);
}

.clear-history-btn {
    background: rgba(244, 67, 54, 0.3);
}

.clear-history-btn:hover {
    background: rgba(244, 67, 54, 0.5);
}

.sort-container, .max-container {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.sort-label, .max-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.sort-select, .max-select {
    background: linear-gradient(to bottom, #1a2a4a, #0a0a15);
    border: 1px solid #2a3a5a;
    border-radius: 4px;
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    width: 80px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 8px;
    padding-right: 20px;
}

.sort-select:hover, .max-select:hover {
    background: linear-gradient(to bottom, #2a3a5a, #1a1a25);
    border-color: #3a4a6a;
}

.sort-select:focus, .max-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

.toggle-button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toggle-button:hover {
    opacity: 1;
}

.song-details-container {
    display: none;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin-top: 5px;
    width: 100%;
}

.song-details-container.expanded {
    display: block;
}

.song-details {
    margin-bottom: 10px;
}

.detail-item {
    margin-bottom: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.detail-label {
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
}

.detail-actions {
    display: flex;
    gap: 10px;
}

.detail-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.detail-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.play-btn {
    background: rgba(76, 175, 80, 0.3);
}

.play-btn:hover {
    background: rgba(76, 175, 80, 0.5);
}

.remove-btn {
    background: rgba(244, 67, 54, 0.3);
}

.remove-btn:hover {
    background: rgba(244, 67, 54, 0.5);
}

#recently-played-section {
    margin: 20px 0;
    padding: 15px;
    background: #1a0e2e;
    border-radius: 8px;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    overflow: visible; /* Prevent clipping of scrollable content */
}

#recently-played-section h2 {
    margin-bottom: 15px;
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#recently-played-container {
    display: flex;
    flex-wrap: nowrap; /* Ensure single row */
    overflow-x: scroll; /* Changed from auto to scroll to ensure scrolling works */
    overflow-y: hidden; /* Prevent vertical scrolling */
    padding: 10px 15px;
    gap: 15px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar */
    white-space: nowrap; /* Ensure content doesn't wrap */
}

#recently-played-container::-webkit-scrollbar {
    display: none; /* Hide scrollbar for WebKit browsers */
}

#recently-played-container .song-card {
    min-width: 180px; /* Match JS inline style */
    max-width: 180px;
    margin: 0 5px;
    transition: transform 0.2s ease;
}

#recently-played-container .song-card:hover {
    transform: scale(1.05);
}

#recently-played-container .song-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #ff5555, #ff9955);
    border-radius: 0 0 5px 5px;
    opacity: 0.7;
}

#recently-played-container .thumbnail {
    width: 100%;
    height: 160px; /* Match JS thumbnailContainer height */
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.no-songs-message {
    display: none; /* Hide the message completely */
}

@media (max-width: 768px) {
    .recently-played-controls {
        gap: 8px;
        padding: 0 0 8px 0;
        margin-bottom: 10px;
    }
    
    .control-button {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .sort-label, .max-label {
        font-size: 11px;
    }
    
    .sort-select, .max-select {
        padding: 3px 6px;
        font-size: 11px;
        width: 60px;
    }
    
    #recently-played-section {
        padding: 10px;
        margin: 10px 0;
        box-sizing: border-box;
        width: 100%;
    }
    
    #recently-played-container {
        width: 100%;
        box-sizing: border-box;
        padding: 10px 15px;
        gap: 10px;
    }
    
    #recently-played-container .song-card {
        min-width: 150px;
        max-width: 150px;
    }
    
    #recently-played-container .thumbnail {
        height: 140px;
    }
    
    .no-songs-message {
        width: 90%;
        margin: 0 auto;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .recently-played-controls {
        gap: 5px;
        padding: 0 0 5px 0;
        margin-bottom: 8px;
    }
    
    .control-button {
        padding: 3px 6px;
        font-size: 10px;
        flex: 1;
        justify-content: center;
    }
    
    .sort-container, .max-container {
        flex: 1;
        min-width: 45%;
        justify-content: space-between;
    }
    
    .sort-label, .max-label {
        font-size: 10px;
    }
    
    .sort-select, .max-select {
        padding: 2px 4px;
        font-size: 10px;
        width: 50px;
    }
    
    .play-count {
        font-size: 8px;
        padding: 1px 4px;
        top: 3px;
        right: 3px;
    }
    
    .last-played {
        font-size: 7px;
        padding: 1px 4px;
        bottom: 3px;
        left: 3px;
    }
    
    .no-songs-message {
        padding: 6px;
        max-width: calc(100vw - 20px);
    }
    
    .no-songs-message p {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .recently-played-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 5px;
    }
    
    .sort-container, .max-container {
        grid-column: span 1;
    }
    
    .sort-select, .max-select {
        width: 50px;
    }
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.section-title h2 {
    margin: 0;
    font-size: 1.2em;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.highlight-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
    margin-top: 10px;
    color: #fff;
}

.notification-box p {
    margin: 0 0 10px 0;
    color: #fff;
}

/* Queue Panel Styles */
#queue-panel {
    position: fixed;
    bottom: 90px; /* Adjusted to sit just above music player */
    right: 15px;
    width: 320px;
    max-height: 450px;
    background: rgba(20, 25, 45, 0.95); /* Slightly darker for contrast */
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(147, 51, 234, 0.4);
    z-index: 1999;
    overflow-y: auto;
    padding: 15px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(147, 51, 234, 0.2);
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(147, 51, 234, 0.25);
}

.queue-header h3 {
    margin: 0;
    color: #e0e0ff;
    font-size: 1.3rem;
    font-weight: 600;
    text-shadow: 0 0 5px rgba(147, 51, 234, 0.3);
}

#clear-queue-btn {
    background: linear-gradient(45deg, #ff5555, #ff7777); /* Matches clear button */
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s ease, background 0.3s ease;
}

#clear-queue-btn:hover {
    background: linear-gradient(45deg, #ff3333, #ff5555);
    transform: scale(1.05);
}

.queue-list {
    padding: 10px 0;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(50, 55, 130, 0.5);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.3s ease, transform 0.2s ease;
}

.queue-item:hover {
    background: rgba(50, 55, 130, 0.7);
    transform: translateX(5px);
}

.queue-item.dragging {
    opacity: 0.6;
    background: rgba(147, 51, 234, 0.6);
    transform: scale(0.98);
}

.queue-thumbnail {
    width: 45px;
    height: 45px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.queue-title {
    flex-grow: 1;
    color: #e0e0ff;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 0 4px rgba(147, 51, 234, 0.2);
}

.remove-queue-btn {
    background: none;
    border: none;
    color: #ff6666;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 5px;
    transition: color 0.3s ease, transform 0.2s ease;
}

.remove-queue-btn:hover {
    color: #ff8888;
    transform: scale(1.2);
}

.no-queue {
    color: #a0a0ff;
    text-align: center;
    padding: 25px 0;
    font-size: 1rem;
    opacity: 0.8;
}

/* Song Context Menu (Dropdown) */
.song-context-menu {
    position: fixed;
    background: rgba(20, 20, 40, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6);
    padding: 8px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    animation: fadeInScale 0.2s ease-out;
    min-width: 150px;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.menu-option {
    background: none;
    border: none;
    color: #e0e0ff;
    padding: 8px 12px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    margin: 2px 0;
    transition: background 0.2s ease;
}

.menu-option:hover {
    background: rgba(147, 51, 234, 0.3);
}

.download-btn {
    background-color: #1ed760;
    color: #000;
}

.download-btn:hover {
    background-color: #1fdf64;
}

/* Queue Buttons in Song Items */
.play-next-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(45deg, #9333ea, #a5b4fc); /* Gradient for vibrancy */
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: transform 0.2s ease, background 0.3s ease;
    opacity: 1; /* Always visible */
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.3);
    z-index: 10; /* Ensure button appears above other elements */
}

.queue-btn:hover, .play-next-btn:hover {
    background: linear-gradient(45deg, #a5b4fc, #9333ea); /* Reverse gradient on hover */
    transform: scale(1.05);
}

/* Queue Toggle Button in Music Player */
#queue-toggle-btn {
    background: none;
    border: none;
    color: #e0e0ff;
    font-size: 1.6rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s ease, transform 0.2s ease;
}

#queue-toggle-btn:hover {
    color: #a5b4fc;
    transform: scale(1.1);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #queue-panel {
        width: 100%;
        right: 0;
        bottom: 85px; /* Adjusted for mobile music player */
        max-height: 350px;
        border-radius: 12px 12px 0 0;
    }

    .queue-header {
        padding: 8px 12px;
    }

    .queue-item {
        padding: 8px;
        gap: 10px;
    }

    .queue-thumbnail {
        width: 35px;
        height: 35px;
    }

    .queue-title {
        font-size: 0.85rem;
    }

    .queue-btn, .play-next-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .queue-btn {
        right: 55px;
    }

    .play-next-btn {
        top: 10px;
        right: 10px;
    }
}

.queue-controls {
    display: flex;
    gap: 10px; /* Space between buttons */
}

#close-queue-btn {
    background: linear-gradient(45deg, #ff5555, #ff7777); /* Matches clear button */
    border: none;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s ease, background 0.3s ease;
}

#close-queue-btn:hover {
    background: linear-gradient(45deg, #ff3333, #ff5555);
    transform: scale(1.05);
}

/* Play count and last played indicators */
.play-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
}

.last-played {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 9px;
}

/* Current session indicator */
.current-session .thumbnail-container {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.7);
}

@media (max-width: 768px) {
    .play-count {
        font-size: 8px;
        padding: 1px 4px;
        top: 3px;
        right: 3px;
    }
    
    .last-played {
        font-size: 7px;
        padding: 1px 4px;
        bottom: 3px;
        left: 3px;
    }
}

/* Styling for popups to ensure mobile responsiveness */
#popup-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    font-family: Arial, sans-serif;
    max-width: 90vw; /* Limit width on small screens */
}

.popup {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 10px;
    animation: fadeOut 0.5s ease-out forwards;
    animation-delay: 2s;
    word-wrap: break-word; /* Ensure text wraps on small screens */
    max-width: 300px; /* Limit popup width */
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.loading {
    animation: pulse 1.5s infinite ease-in-out;
}

/* Skeleton Loader Styles */
.skeleton {
    background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.2s infinite linear;
}

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

.loading-placeholder {
    opacity: 0.7;
}

/* Popup Container */
#popup-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
    max-width: 350px;
    width: 90%;
}

/* Popup Message */
.popup-message {
    background: rgba(30, 30, 40, 0.95);
    color: white;
    padding: 18px 25px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    position: relative;
    overflow: hidden;
    border-left: 4px solid #4a6bff;
    animation: slideIn 0.3s forwards;
    will-change: transform, opacity;
}

/* Popup Content */
.popup-message > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.popup-message > div > div {
    flex-grow: 1;
    font-size: 15px;
    line-height: 1.5;
}

/* Close Button */
.popup-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.popup-close:hover {
    color: white;
}

/* Progress Bar */
.popup-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    width: 100%;
}

.popup-progress > div {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4a6bff, #8a5fff);
    transform-origin: left;
    transform: scaleX(1);
    transition: transform linear;
}

/* Animations */
@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

@keyframes progressBar {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Different message types */
.popup-message.success { border-left-color: #4CAF50; }
.popup-message.error { border-left-color: #f44336; }
.popup-message.warning { border-left-color: #ff9800; }
.popup-message.info { border-left-color: #2196F3; }

/* Progress bar colors */
.popup-message.success .popup-progress > div { background: linear-gradient(90deg, #4CAF50, #8BC34A); }
.popup-message.error .popup-progress > div { background: linear-gradient(90deg, #f44336, #ff5252); }
.popup-message.warning .popup-progress > div { background: linear-gradient(90deg, #ff9800, #ffc107); }
.popup-message.info .popup-progress > div { background: linear-gradient(90deg, #2196F3, #00BCD4); }

.popup-message {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.song-item.playing {
    background: rgba(0, 255, 0, 0.1);
    border-left: 3px solid #00ff00;
}

.song-item.current {
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.seeking {
    cursor: grabbing !important;
}

#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}