/* Custom Audio Player Styles */

/* CSS Variables for theming */
:root {
    /* Dark mode colors (default) */
    --player-bg: #2a2a2a;
    --player-border: rgba(255, 255, 255, 0.1);
    --player-text: #ffffff;
    --player-text-secondary: #b0b0b0;
    --player-accent: #e56d64;
    --player-accent-hover: #e64631;
    --waveform-bg: #1a1a1a;
    --waveform-bg-hover: linear-gradient(to bottom, #1e1e1e 0%, #191919 100%);
    --waveform-border: rgba(255, 255, 255, 0.05);
}

/* Light mode theme - controlled by global theme toggle */
body.light-mode .waveform-audio-player-container,
html.light-mode .waveform-audio-player-container,
.waveform-audio-player-container.light-mode {
    --player-bg: #f8f9fa;
    --player-border: rgba(0, 0, 0, 0.15);
    --player-text: #1C2321;
    --player-text-secondary: #6c757d;
    --player-accent: #e56d64;
    --player-accent-hover: #d85c53;
    --waveform-bg: #e9ecef;
    --waveform-bg-hover: linear-gradient(to bottom, #dee2e6 0%, #e9ecef 100%);
    --waveform-border: rgba(0, 0, 0, 0.1);
}

/* Fallback: detect system preference */
@media (prefers-color-scheme: light) {
    .waveform-audio-player-container {
        --player-bg: #f8f9fa;
        --player-border: rgba(0, 0, 0, 0.15);
        --player-text: #1C2321;
        --player-text-secondary: #6c757d;
        --player-accent: #e56d64;
        --player-accent-hover: #d85c53;
        --waveform-bg: #e9ecef;
        --waveform-bg-hover: linear-gradient(to bottom, #dee2e6 0%, #e9ecef 100%);
        --waveform-border: rgba(0, 0, 0, 0.1);
    }
}

/* Override system preference when body has explicit class */
body.dark-mode .waveform-audio-player-container {
    --player-bg: #2a2a2a;
    --player-border: rgba(255, 255, 255, 0.1);
    --player-text: #ffffff;
    --player-text-secondary: #b0b0b0;
    --player-accent: #e56d64;
    --player-accent-hover: #e64631;
    --waveform-bg: #1a1a1a;
    --waveform-bg-hover: linear-gradient(to bottom, #1e1e1e 0%, #191919 100%);
    --waveform-border: rgba(255, 255, 255, 0.05);
}

.waveform-audio-player-container {
    margin: 20px 0;
}

/* Player View Variations */
.audio-player {
    display: flex;
    background: var(--player-bg, #2a2a2a);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--player-border, rgba(255, 255, 255, 0.1));
    position: relative;
}

/* Standard View - Elegant proportions */
.audio-player.view-standard {
    height: 240px;
    padding: 20px;
    gap: 24px;
    align-items: center;
}

/* Compact View - original horizontal layout */
.audio-player.view-compact,
.audio-player.single-track {
    height: 120px;
    padding: 20px;
    gap: 20px;
    align-items: center;
}

/* Album Art - Base styling */
.audio-player .album-art {
    flex-shrink: 0;
    flex-grow: 0;           /* Prevent growing */
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Standard view: Fixed square dimensions */
.audio-player.view-standard .album-art {
    width: 200px !important;
    height: 200px !important;
    min-width: 200px;       /* Force exact size */
    max-width: 200px;       /* Force exact size */
}

/* Compact view: Original smaller size */
.audio-player.view-compact .album-art,
.audio-player.single-track .album-art {
    width: 120px;
    height: 120px;
}

/* Image styling */
.audio-player .album-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Player Content */
.audio-player .player-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

/* Standard view: Clean spacing */
.audio-player.view-standard .player-content {
    gap: 16px;
}

/* Compact view: Original spacing */
.audio-player.view-compact .player-content,
.audio-player.single-track .player-content {
    gap: 16px;
}

/* Waveform Container - Responsive height */
.audio-player .waveform-container {
    border-radius: 8px;
    overflow: hidden;
    background: var(--waveform-bg);
    border: 1px solid var(--waveform-border);
    position: relative;
    flex: 1;
    min-height: 48px;
}

/* Standard view: Taller waveform (takes remaining vertical space) */
.audio-player.view-standard .waveform-container {
    min-height: 160px;
    cursor: pointer;
}

/* Remove any internal margins/padding from waveform */
.audio-player .waveform-container > div {
    width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure canvas fills container completely */
.audio-player .waveform-container canvas {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Compact view: Fixed height */
.audio-player.view-compact .waveform-container,
.audio-player.single-track .waveform-container {
    height: 48px;
    flex: none;
}

/* SoundCloud-style hover overlay */
.audio-player.view-standard .waveform-container .hover-overlay {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: rgba(255, 255, 255, 0.5);
    mix-blend-mode: overlay;
    opacity: 0;
    transition: opacity 0.1s ease;  /* Faster opacity transition */
    pointer-events: none;
    z-index: 10;
    will-change: width;             /* Optimize for width changes */
}

.audio-player.view-standard .waveform-container:hover .hover-overlay {
    opacity: 1;
}

.audio-player .waveform-container > div {
    width: 100%;
    height: 100%;
}

/* SoundCloud-style waveform enhancements */
.audio-player.view-standard .waveform-container {
    background: var(--waveform-bg);
    border: 1px solid var(--waveform-border);
    cursor: pointer;
}

/* Waveform hover effects */
.audio-player .waveform-container:hover {
    background: var(--waveform-bg-hover);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced waveform styling for SoundCloud-like appearance */
.audio-player.view-standard wave {
    transition: all 0.2s ease;
}

/* Waveform bar hover effects - will be enhanced by WaveSurfer interaction */
.audio-player.view-standard .waveform-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(229, 109, 100, 0.05) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.audio-player.view-standard .waveform-container:hover::after {
    opacity: 1;
}

/* Fluid animation support */
.audio-player.view-standard .waveform-container * {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Progress indication enhancements */
.audio-player.view-standard .waveform-container {
    position: relative;
}

.audio-player.view-standard .waveform-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 1;
    pointer-events: none;
}

/* Loading state */
.audio-player .waveform-container.loading::before {
    content: 'Loading waveform...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #b0b0b0;
    font-size: 14px;
    z-index: 1;
}

/* Controls Row */
.audio-player .controls {
    display: flex;
    align-items: center;
    flex: 0.4 !important;
    gap: 20px;
    flex-wrap: wrap;
}

.audio-player .controls-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
    width: 118px;
}

.audio-player .track-info{ 
    width: 118px;
}

/* Play Button */
.audio-player .play-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--player-accent);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-player .play-btn:hover {
    background: var(--player-accent-hover);
    transform: scale(1.05);
}

.audio-player .play-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Track Info */
.audio-player .track-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-player .track-title {
    color: var(--player-text);
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    cursor: help;
}


.audio-player .track-subtitle {
    color: var(--player-text-secondary);
    font-size: 13px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    cursor: help;
}



/* Volume Control */
.audio-player .volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.audio-player .volume-icon {
    width: 20px;
    height: 20px;
    fill: var(--player-text-secondary);
}

.audio-player .volume-slider {
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: #4a4a4a;
    outline: none;
    appearance: none;
    cursor: pointer;
}

.audio-player .volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--player-accent);
    cursor: pointer;
    border: 2px solid var(--player-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.audio-player .volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--player-accent);
    cursor: pointer;
    border: 2px solid var(--player-bg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Time Display */
.audio-player .time-display {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
    color: var(--player-text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.audio-player .time-separator {
    opacity: 0.6;
}

/* Mobile Responsive Design */
@media (max-width: 640px) {
    .audio-player.single-track,
    .audio-player.view-standard {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
        align-items: stretch;
        height: auto;
    }
    
    .audio-player .album-art {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        align-self: center;
    }
    
    .audio-player .controls {
        gap: 12px;
        justify-content: space-between;
    }
    
    .audio-player.view-standard .waveform-container {
        min-height: 80px;
        height: 80px;
    }
    
    .audio-player .track-info {
        order: -1;
        text-align: center;
        margin-bottom: 8px;
    }
    
    .audio-player .time-display {
        order: 1;
    }
    
}

@media (max-width: 480px) {
    .audio-player.single-track {
        padding: 12px;
    }
    
    .audio-player .album-art {
        width: 80px;
        height: 80px;
    }
    
    .audio-player .controls {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }
    
    .audio-player .controls > * {
        order: 0 !important;
    }
    
    .audio-player .track-info {
        width: 100%;
        text-align: center;
        margin-bottom: 0;
    }
    
    .audio-player .time-display {
        justify-content: flex-start;
    }
}