/**
 * Fiorra Premium Audio Player v2.0
 * ================================
 * 
 * Date: 2025-12-26
 * 
 * Features:
 * - Glassmorphism design
 * - Animated waveform visualization
 * - Persona-themed gradients
 * - Skip forward/backward 10s
 * - Playback speed control
 * - Download button
 * - Smooth animations
 * - Mobile-first responsive
 * 
 * Usage:
 * Add class "audio-player-v2" to player container
 */

/* ═══════════════════════════════════════════════════════════════
   BASE PLAYER CONTAINER
   ═══════════════════════════════════════════════════════════════ */

.audio-player-v2 {
    --player-bg: rgba(30, 30, 50, 0.95);
    --player-glass: rgba(255, 255, 255, 0.08);
    --player-border: rgba(255, 255, 255, 0.12);
    --player-accent: var(--persona-color, #8b5cf6);
    --player-accent-glow: rgba(139, 92, 246, 0.4);
    --player-text: #ffffff;
    --player-text-muted: rgba(255, 255, 255, 0.6);
    --player-progress-bg: rgba(255, 255, 255, 0.15);
    --player-waveform: rgba(255, 255, 255, 0.3);
    --player-waveform-active: var(--persona-color, #8b5cf6);
    
    position: relative;
    background: var(--player-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 20px;
    margin: 15px 0;
    border: 1px solid var(--player-border);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    overflow: hidden;
    transition: all 0.3s ease;
}

.audio-player-v2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent
    );
}

.audio-player-v2:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 0 30px var(--player-accent-glow);
}

/* Playing state glow */
.audio-player-v2.playing {
    border-color: var(--player-accent);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px var(--player-accent) inset,
        0 0 40px var(--player-accent-glow);
}

/* ═══════════════════════════════════════════════════════════════
   WAVEFORM VISUALIZATION
   ═══════════════════════════════════════════════════════════════ */

.player-waveform-v2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 50px;
    margin-bottom: 15px;
    cursor: pointer;
    position: relative;
    padding: 0 5px;
}

.waveform-bar-v2 {
    flex: 1;
    max-width: 4px;
    min-width: 2px;
    background: var(--player-waveform);
    border-radius: 2px;
    transition: all 0.15s ease;
    transform-origin: center;
}

.waveform-bar-v2.active {
    background: linear-gradient(180deg, 
        var(--player-accent) 0%, 
        rgba(139, 92, 246, 0.6) 100%
    );
    box-shadow: 0 0 8px var(--player-accent-glow);
}

/* Playing animation */
.audio-player-v2.playing .waveform-bar-v2.active {
    animation: waveformPulse 0.8s ease-in-out infinite;
}

.audio-player-v2.playing .waveform-bar-v2.active:nth-child(odd) {
    animation-delay: 0.1s;
}

.audio-player-v2.playing .waveform-bar-v2.active:nth-child(3n) {
    animation-delay: 0.2s;
}

.audio-player-v2.playing .waveform-bar-v2.active:nth-child(5n) {
    animation-delay: 0.15s;
}

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

/* ═══════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════ */

.player-progress-container-v2 {
    position: relative;
    height: 6px;
    background: var(--player-progress-bg);
    border-radius: 3px;
    margin-bottom: 12px;
    cursor: pointer;
    overflow: hidden;
}

.player-progress-bar-v2 {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, 
        var(--player-accent), 
        #a78bfa
    );
    border-radius: 3px;
    transition: width 0.1s linear;
}

.player-progress-bar-v2::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.player-progress-container-v2:hover .player-progress-bar-v2::after {
    transform: translateY(-50%) scale(1);
}

/* Buffered indicator */
.player-buffered-v2 {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   TIME DISPLAY
   ═══════════════════════════════════════════════════════════════ */

.player-time-v2 {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--player-text-muted);
    margin-bottom: 15px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    letter-spacing: 0.5px;
}

.player-time-current {
    color: var(--player-text);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════
   CONTROLS
   ═══════════════════════════════════════════════════════════════ */

.player-controls-v2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Base button style */
.player-btn-v2 {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--player-glass);
    border: 1px solid var(--player-border);
    border-radius: 50%;
    color: var(--player-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-btn-v2:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.player-btn-v2:active {
    transform: scale(0.95);
}

/* Skip buttons (small) */
.player-btn-skip-v2 {
    width: 40px;
    height: 40px;
}

.player-btn-skip-v2 svg {
    width: 18px;
    height: 18px;
}

.player-btn-skip-v2 .skip-text {
    position: absolute;
    font-size: 8px;
    font-weight: 700;
    color: var(--player-text);
    margin-top: 1px;
}

/* Play/Pause button (large) */
.player-btn-play-v2 {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, 
        var(--player-accent), 
        #a78bfa
    );
    border: none;
    box-shadow: 
        0 4px 20px var(--player-accent-glow),
        0 0 0 3px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.player-btn-play-v2::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent
    );
    transition: left 0.5s ease;
}

.player-btn-play-v2:hover::before {
    left: 100%;
}

.player-btn-play-v2:hover {
    transform: scale(1.08);
    box-shadow: 
        0 6px 30px var(--player-accent-glow),
        0 0 0 4px rgba(255, 255, 255, 0.15);
}

.player-btn-play-v2 svg {
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
}

/* Play/Pause icon toggle */
.player-btn-play-v2 .icon-play {
    display: block;
}

.player-btn-play-v2 .icon-pause {
    display: none;
}

.audio-player-v2.playing .player-btn-play-v2 .icon-play {
    display: none;
}

.audio-player-v2.playing .player-btn-play-v2 .icon-pause {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════
   SECONDARY CONTROLS (Speed, Download)
   ═══════════════════════════════════════════════════════════════ */

.player-secondary-v2 {
    display: flex;
    align-items: center;
    justify-content: center;  /* space-between yerine center */
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--player-border);
}

/* Speed control */
.player-speed-v2 {
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-speed-btn-v2 {
    padding: 6px 10px;
    background: var(--player-glass);
    border: 1px solid var(--player-border);
    border-radius: 8px;
    color: var(--player-text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-speed-btn-v2:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--player-text);
}

.player-speed-btn-v2.active {
    background: var(--player-accent);
    border-color: var(--player-accent);
    color: #fff;
}

/*
.player-download-v2 {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--player-glass);
    border: 1px solid var(--player-border);
    border-radius: 10px;
    color: var(--player-text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.player-download-v2:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--player-text);
    transform: translateY(-2px);
}

.player-download-v2 svg {
    width: 14px;
    height: 14px;
}
*/
/* ═══════════════════════════════════════════════════════════════
   LOADING STATE
   ═══════════════════════════════════════════════════════════════ */

.audio-player-v2.loading .player-btn-play-v2 {
    pointer-events: none;
}

.audio-player-v2.loading .player-btn-play-v2::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.audio-player-v2.loading .player-btn-play-v2 svg {
    opacity: 0;
}

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

/* ═══════════════════════════════════════════════════════════════
   PERSONA THEMES
   ═══════════════════════════════════════════════════════════════ */

/* Mira - Purple */
.audio-player-v2[data-persona="mira"] {
    --player-accent: #8b5cf6;
    --player-accent-glow: rgba(139, 92, 246, 0.4);
}

/* Luna - Blue */
.audio-player-v2[data-persona="luna"] {
    --player-accent: #3b82f6;
    --player-accent-glow: rgba(59, 130, 246, 0.4);
}

/* Canan - Pink */
.audio-player-v2[data-persona="canan"] {
    --player-accent: #ec4899;
    --player-accent-glow: rgba(236, 72, 153, 0.4);
}

/* Elif - Teal */
.audio-player-v2[data-persona="elif"] {
    --player-accent: #14b8a6;
    --player-accent-glow: rgba(20, 184, 166, 0.4);
}

/* Sage - Green */
.audio-player-v2[data-persona="sage"] {
    --player-accent: #22c55e;
    --player-accent-glow: rgba(34, 197, 94, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 400px) {
    .audio-player-v2 {
        padding: 15px;
        border-radius: 16px;
    }
    
    .player-waveform-v2 {
        height: 40px;
        margin-bottom: 12px;
    }
    
    .player-btn-play-v2 {
        width: 54px;
        height: 54px;
    }
    
    .player-btn-skip-v2 {
        width: 36px;
        height: 36px;
    }
    
.player-secondary-v2 {
    display: flex;
    align-items: center;
    justify-content: center;  /* space-between yerine center */
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--player-border);
}
    
    .player-speed-v2 {
        width: 100%;
        justify-content: center;
    }
    
    .player-download-v2 {
        width: 100%;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-color-scheme: dark) {
    .audio-player-v2 {
        --player-bg: rgba(20, 20, 35, 0.98);
    }
}

/* ═══════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */

.audio-player-v2 *:focus {
    outline: 2px solid var(--player-accent);
    outline-offset: 2px;
}

.audio-player-v2 *:focus:not(:focus-visible) {
    outline: none;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .audio-player-v2,
    .audio-player-v2 * {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
