/* Custom styles for ListenHUB */
.tree-item {
    transition: all 0.2s ease;
}

.tree-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.audio-file {
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-file:hover {
    color: #3b82f6;
}

.audio-file.active {
    color: #3b82f6;
    font-weight: bold;
}

.player-control {
    transition: all 0.2s ease;
}

.player-control:hover {
    transform: scale(1.1);
}

.time-skip-btn {
    transition: all 0.2s ease;
}

.time-skip-btn:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.speed-btn {
    transition: all 0.2s ease;
}

.speed-btn.active {
    background-color: #3b82f6;
    color: white;
}

.repeat-btn.active {
    color: #3b82f6;
}

.shuffle-btn.active {
    color: #3b82f6;
}

.progress-bar {
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 var(--progress), #e5e7eb var(--progress), #e5e7eb 100%);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: var(--progress);
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(59, 130, 246, 0.8) 0%,
        rgba(139, 92, 246, 0.8) 50%,
        rgba(59, 130, 246, 0.8) 100%
    );
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-bar.playing::after {
    opacity: 1;
    animation: progressShimmer 2s linear infinite;
}

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

.modal {
    backdrop-filter: blur(10px);
}

.folder-icon {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.folder-icon:hover {
    transform: rotate(90deg);
}

.folder-icon.expanded {
    transform: rotate(90deg);
}

.volume-slider {
    background: #e5e7eb;
    position: relative;
}

.volume-slider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--volume);
    background: linear-gradient(90deg, #3b82f6 0%, #6366f1 100%);
    border-radius: inherit;
    transition: all 0.3s ease;
}

/* Help button positioning */
.help-button-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

/* Copyright section styling */
.copyright-section {
    transition: all 0.3s ease;
}

.copyright-section a {
    transition: all 0.2s ease;
}

.copyright-section a:hover {
    transform: translateY(-2px);
}

/* Logo animation */
.sidebar svg {
    transition: transform 0.3s ease;
}

.sidebar svg:hover {
    transform: scale(1.1);
}

/* Logo sound wave animation */
@keyframes soundWave {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.sidebar svg path {
    animation: soundWave 2s ease-in-out infinite;
}

.sidebar svg path:nth-child(3) {
    animation-delay: 0.2s;
}

.sidebar svg path:nth-child(4) {
    animation-delay: 0.4s;
}

.sidebar svg path:nth-child(5) {
    animation-delay: 0.6s;
}

.sidebar svg path:nth-child(6) {
    animation-delay: 0.8s;
}

/* Responsive design for vertical layout */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100% !important;
        max-height: 50vh;
        min-height: 300px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    /* Reduce logo size in mobile vertical mode */
    .sidebar .w-36 {
        width: 4rem !important;
        height: 4rem !important;
    }
    
    /* Ensure folder tree gets enough space */
    .sidebar .flex-1 {
        min-height: 180px;
    }
    
    .player-container {
        flex: 1;
    }
    
    .help-button-container {
        position: fixed;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    /* Hide copyright section in mobile */
    .copyright-section {
        display: none;
    }
    
    /* Adjust player size for mobile */
    .player-card {
        max-width: 100% !important;
        margin: 1rem;
        padding: 1.5rem !important;
    }
    
    .album-art {
        width: 200px !important;
        height: 200px !important;
    }
    
    /* Adjust button sizes */
    .time-skip-btn {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .speed-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .main-container {
        flex-direction: row;
    }
    
    .sidebar {
        width: 30% !important;
        max-height: 100vh;
        border-right: 1px solid #e5e7eb;
        border-bottom: none;
    }
    
    .album-art {
        width: 150px !important;
        height: 150px !important;
    }
}

/* Tablet and small desktop */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100% !important;
        max-height: 45vh;
        min-height: 350px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    /* Reduce logo size in tablet vertical mode */
    .sidebar .w-36 {
        width: 5rem !important;
        height: 5rem !important;
    }
    
    /* Ensure folder tree gets enough space */
    .sidebar .flex-1 {
        min-height: 220px;
    }
    
    /* Hide copyright section in tablet vertical mode */
    .copyright-section {
        display: none;
    }
}

/* Folder tree container improvements */
#folderTree {
    overflow-y: auto;
    flex: 1;
    min-height: 150px;
}

/* Better folder tree spacing in vertical modes */
@media (max-width: 1024px) {
    #folderTree {
        min-height: 200px;
    }
    
    /* Improve scrollbar for vertical layouts */
    .sidebar::-webkit-scrollbar {
        width: 8px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: #f8fafc;
        border-radius: 4px;
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: #94a3b8;
        border-radius: 4px;
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }
}

/* Custom scrollbar for tree view */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smooth transitions */
* {
    box-sizing: border-box;
}

.main-container {
    transition: all 0.3s ease;
}

.sidebar {
    transition: all 0.3s ease;
}

.player-container {
    transition: all 0.3s ease;
}

/* Focus styles for accessibility */
button:focus,
input:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Improved modal styles */
.modal {
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

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

.modal > div {
    animation: scaleIn 0.2s ease;
}

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

/* Improved progress bar */
.progress-bar {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.progress-bar:hover {
    transform: scaleY(1.2);
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    border-radius: inherit;
}

/* Volume slider improvements */
.volume-slider {
    appearance: none;
    background: #e5e7eb;
    cursor: pointer;
    position: relative;
    border-radius: 9999px;
    height: 8px;
}

.volume-slider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--volume);
    background: linear-gradient(90deg, #3b82f6 0%, #6366f1 100%);
    border-radius: inherit;
    transition: all 0.3s ease;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.volume-slider::-moz-range-track {
    background: #e5e7eb;
    height: 8px;
    border-radius: 9999px;
    border: none;
}

.volume-slider::-moz-range-progress {
    background: linear-gradient(90deg, #3b82f6 0%, #6366f1 100%);
    height: 8px;
    border-radius: 9999px;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* File tree improvements */
.folder-contents {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.folder-contents.hidden {
    max-height: 0;
}

.folder-contents:not(.hidden) {
    max-height: 1000px;
}

/* Improved button states */
.player-control:active {
    transform: scale(0.95);
}

.time-skip-btn:active,
.speed-btn:active {
    transform: scale(0.95);
}

/* ===== NEW EFFECTS ===== */

/* Album Art Visualizer Effect */
.album-art {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.album-art.playing {
    animation: albumPulse 2s ease-in-out infinite;
    box-shadow: 
        0 0 20px rgba(59, 130, 246, 0.3),
        0 0 40px rgba(59, 130, 246, 0.1),
        inset 0 0 20px rgba(59, 130, 246, 0.1);
}

.album-art.playing::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(59, 130, 246, 0.1),
        transparent,
        rgba(139, 92, 246, 0.1),
        transparent
    );
    animation: visualizerSweep 3s linear infinite;
}

.album-art.playing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        circle at center,
        transparent 60%,
        rgba(59, 130, 246, 0.2) 70%,
        transparent 80%
    );
    animation: visualizerPulse 1.5s ease-in-out infinite alternate;
}

@keyframes albumPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

@keyframes visualizerSweep {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes visualizerPulse {
    0% {
        opacity: 0.3;
    }
    100% {
        opacity: 0.8;
    }
}

/* Enhanced Play/Pause Button Glow */
#playPauseBtn {
    position: relative;
    transition: all 0.3s ease;
}

#playPauseBtn.playing {
    color: #3b82f6;
    animation: playGlow 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}

#playPauseBtn.playing::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(59, 130, 246, 0.2) 0%,
        rgba(59, 130, 246, 0.1) 50%,
        transparent 70%
    );
    animation: glowPulse 2s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes playGlow {
    0%, 100% {
        text-shadow: 
            0 0 5px rgba(59, 130, 246, 0.5),
            0 0 10px rgba(59, 130, 246, 0.3),
            0 0 15px rgba(59, 130, 246, 0.2);
    }
    50% {
        text-shadow: 
            0 0 10px rgba(59, 130, 246, 0.8),
            0 0 20px rgba(59, 130, 246, 0.5),
            0 0 30px rgba(59, 130, 246, 0.3);
    }
}

@keyframes glowPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

/* Enhanced Progress Bar with Pulse Effect */
.progress-bar.playing {
    animation: progressGlow 2s ease-in-out infinite;
}

.progress-bar.playing::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    bottom: -2px;
    background: linear-gradient(
        90deg,
        rgba(59, 130, 246, 0.3) 0%,
        rgba(59, 130, 246, 0.6) var(--progress),
        transparent var(--progress)
    );
    border-radius: inherit;
    filter: blur(2px);
}

@keyframes progressGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
    }
}

/* Ripple Effect for Buttons */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Enhanced Control Buttons */
.player-control {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-control:hover {
    transform: scale(1.1) translateY(-2px);
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
}

.player-control:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
}

/* Floating Animation for Speed Buttons */
.speed-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.speed-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.speed-btn.active {
    animation: activeFloat 2s ease-in-out infinite;
    box-shadow: 0 5px 20px rgba(59, 130, 246, 0.4);
}

@keyframes activeFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

/* Time Skip Buttons Wave Effect */
.time-skip-btn {
    transition: all 0.3s ease;
    position: relative;
}

.time-skip-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.time-skip-btn:active {
    animation: skipPulse 0.3s ease;
}

@keyframes skipPulse {
    0% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
    100% {
        transform: scale(1.05);
    }
}

/* Background Gradient Animation */
.player-container {
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    position: relative;
}

.player-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 255, 255, 0.8) 100%
    );
    pointer-events: none;
}

.player-container.playing {
    animation: gradientShift 8s ease infinite, playingPulse 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes playingPulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.05);
    }
}

/* Volume Slider Enhanced */
.volume-slider {
    position: relative;
}

.volume-slider.active {
    animation: volumePulse 0.5s ease;
}

@keyframes volumePulse {
    0%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(1.1);
    }
}

.volume-slider::-webkit-slider-thumb {
    position: relative;
    z-index: 2;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.2),
        0 0 0 8px rgba(59, 130, 246, 0.1);
}

/* Repeat and Shuffle Button Effects */
.repeat-btn.active,
.shuffle-btn.active {
    animation: activeButton 2s ease-in-out infinite;
    color: #3b82f6 !important;
}

@keyframes activeButton {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.3));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
    }
}

/* File Item Hover Effect */
.audio-file {
    transition: all 0.3s ease;
    position: relative;
}

.audio-file:hover {
    transform: translateX(8px);
    color: #3b82f6 !important;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
}

.audio-file.active {
    animation: activeTrack 1s ease-in-out infinite;
    position: relative;
}

.audio-file.active::before {
    content: '♪';
    position: absolute;
    left: -20px;
    animation: musicNote 1.5s ease-in-out infinite;
}

@keyframes activeTrack {
    0%, 100% {
        background: rgba(59, 130, 246, 0.1);
    }
    50% {
        background: rgba(59, 130, 246, 0.2);
    }
}

@keyframes musicNote {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-3px) rotate(5deg);
        opacity: 1;
    }
}

/* Loading States */
.loading-audio {
    position: relative;
}

.loading-audio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #3b82f6;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Particle Effect for Album Art */
.album-art.playing {
    position: relative;
}

.album-art.playing .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(59, 130, 246, 0.6);
    border-radius: 50%;
    animation: particle 3s ease-in-out infinite;
}

.album-art.playing .particle:nth-child(1) {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
}

.album-art.playing .particle:nth-child(2) {
    top: 30%;
    right: 20%;
    animation-delay: 0.5s;
}

.album-art.playing .particle:nth-child(3) {
    bottom: 20%;
    left: 30%;
    animation-delay: 1s;
}

.album-art.playing .particle:nth-child(4) {
    bottom: 30%;
    right: 30%;
    animation-delay: 1.5s;
}

@keyframes particle {
    0%, 100% {
        opacity: 0;
        transform: scale(0.5) translateY(0);
    }
    50% {
        opacity: 1;
        transform: scale(1) translateY(-10px);
    }
}

/* Enhanced Modal Animations */
.modal {
    animation: modalFadeIn 0.3s ease;
}

.modal > div {
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Player card improvements with glassmorphism effect */
.player-card {
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.player-card:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Enhanced sidebar with glassmorphism */
.sidebar {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

/* Floating help button */
.help-button-container button {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.help-button-container button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Responsive adjustments for effects */
@media (max-width: 768px) {
    .album-art.playing {
        animation-duration: 3s;
    }
    
    .player-control:hover {
        transform: scale(1.05) translateY(-1px);
    }
    
    .speed-btn:hover {
        transform: translateY(-2px);
    }
    
    /* Reduce particle effects on mobile */
    .album-art.playing .particle {
        display: none;
    }
    
    /* Reduce glassmorphism on mobile for performance */
    .player-card,
    .sidebar {
        backdrop-filter: blur(5px);
    }
}
