/* ============================================================
   Radio Castelar - Estilos del Reproductor y Vúmetros
   @version 1.1.4 - FIX: Vúmetro responsive en móviles Android
   ============================================================ */
:root {
    --color-bg:           #0a0a0a;
    --color-bg-elevated:  #1c1c1c;
    --color-border:       #2a2a2a;
    --color-fg:           #f5f5f5;
    --color-fg-muted:     #999;
    --color-fg-dim:       #666;
    --color-primary:      #ff5e1f;
    --color-primary-hov:  #ff7a3d;
    --color-primary-glow: rgba(255, 94, 31, 0.4);
    --color-live:         #ff3030;
    --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: rgba(10, 10, 10, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--color-border);
    transform: translateY(100%);
    transition: transform var(--t-base);
}

.player.visible { transform: translateY(0); }

.player__inner {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 1.5rem;
    align-items: center;
    max-width: 1280px;
    margin-inline: auto;
    padding: 0.75rem 1.5rem;
}

/* Botón principal Play/Pause */
.player__play-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    transition: all var(--t-base);
    box-shadow: 0 0 20px var(--color-primary-glow);
    border: none;
    cursor: pointer;
}

.player__play-btn:hover {
    transform: scale(1.08);
    background: var(--color-primary-hov);
    box-shadow: 0 0 30px var(--color-primary-glow);
}

.player__play-btn:active { transform: scale(1); }

.player__play-btn .icon-play,
.player__play-btn .icon-pause {
    position: relative;
    z-index: 1;
}

.player__play-btn.playing .icon-play { display: none; }
.player__play-btn.playing .icon-pause { display: block; }

.player__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    opacity: 0;
    pointer-events: none;
}

.player__play-btn.playing .player__pulse {
    animation: playerPulse 1.5s infinite;
}

@keyframes playerPulse {
    0%   { transform: scale(1);   opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Botón Toggle Vúmetro */
.player__vu-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    color: var(--color-fg-muted);
    transition: all var(--t-fast);
    background: transparent;
    border: none;
    cursor: pointer;
}

.player__vu-btn:hover { color: var(--color-primary); }
.player__vu-btn.active { color: var(--color-primary); background: rgba(255, 94, 31, 0.1); }

/* Información */
.player__info {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.player__live-tag {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    background: rgba(255, 48, 48, 0.15);
    border: 1px solid var(--color-live);
    border-radius: 4px;
    color: var(--color-live);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    flex-shrink: 0;
}

.player__track {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.player__track strong {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player__track span {
    font-size: 0.8rem;
    color: var(--color-fg-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controles */
.player__controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.player__volume {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player__vol-btn {
    color: var(--color-fg-muted);
    transition: color var(--t-fast);
    display: grid;
    place-items: center;
    background: transparent;
    border: none;
    cursor: pointer;
}

.player__vol-btn:hover { color: var(--color-fg); }
.player__vol-btn.muted { color: var(--color-live); }

#volumeSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    outline: none;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--t-fast);
}

#volumeSlider::-webkit-slider-thumb:hover { transform: scale(1.3); }

#volumeSlider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.player__listeners {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--color-fg-muted);
}

.player__listeners svg { color: var(--color-primary); }

/* Barra de progreso */
.player__progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--color-primary), #ffd700);
    transition: width 0.3s linear;
}

.player.playing .player__progress {
    animation: progressIndeterminate 4s linear infinite;
}

@keyframes progressIndeterminate {
    0%   { width: 0;     opacity: 1; }
    50%  { width: 100%;  opacity: 1; }
    100% { width: 100%;  opacity: 0; }
}

/* ============================================================
   VÚMETROS PROFESIONALES (Rack Flotante)
   FIX: Responsive para móviles Android
   ============================================================ */
.vu-rack {
    position: absolute;
    bottom: 100%;
    left: 20px;
    margin-bottom: 15px;
    width: 320px;
    max-width: calc(100vw - 40px); /* ← FIX: No exceder el viewport */
    background: linear-gradient(145deg, #1c1c1c, #0a0a0a);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    display: none;
    z-index: 95;
    box-sizing: border-box; /* ← FIX: Incluir padding en el ancho */
}

.vu-rack.show { display: block; }

.vu-rack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #222;
    padding-bottom: 8px;
}

.vu-rack-title {
    font-family: monospace;
    font-size: 0.7em;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.vu-rack-mode {
    font-family: monospace;
    font-size: 0.7em;
    color: var(--color-primary);
    text-transform: uppercase;
    cursor: pointer;
}

.vu-display-area {
    height: 140px;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #111;
    cursor: pointer;
    box-sizing: border-box;
}

.vu-mode {
    width: 100%;
    height: 100%;
    display: none;
    box-sizing: border-box;
}

.vu-mode.active { display: flex; }

/* 1. Analógico (Con imagen de fondo) */
.vu-analog {
    background: url('/assets/img/vu/vu-meter-waves1.webp') no-repeat center center;
    background-size: 100% 100%;
    position: relative;
    z-index: 1;
}

.analog-needle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.needle {
    position: absolute;
    bottom: 18%;
    width: 2px;
    height: 50%;
    background: #ff3030;
    transform-origin: bottom center;
    box-shadow: 0 0 3px rgba(255, 0, 0, 0.4);
    transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 3;
}

.needle::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: -2px;
    width: 6px;
    height: 6px;
    background: #222;
    border-radius: 50%;
}

.needle.left { left: 25%; transform: rotate(-45deg); }
.needle.right { left: 75%; transform: rotate(-45deg); }

/* 2. Espectro (Con imagen de fondo) */
.vu-spectrum {
    position: relative;
    background: url('/assets/img/vu/vu-meter-spectrum1.webp') no-repeat center center;
    background-size: 100% 100%;
    overflow: hidden;
    z-index: 1;
}

.spectrum-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0.7));
    z-index: 2;
    pointer-events: none;
}

.spectrum-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(to right, rgba(255,255,255,0.04) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 5% 20%;
    z-index: 3;
    pointer-events: none;
}

.spectrum-bars {
    position: absolute;
    bottom: 15px;
    left: 5%;
    width: 90%;
    height: 75%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2px;
    z-index: 4;
}

.s-bar {
    width: 100%;
    background: linear-gradient(to top, #00ff00 0%, #00ff00 60%, #ffff00 80%, #ff0000 100%);
    border-radius: 1px;
    height: 2%;
    transition: height 0.05s linear;
    box-shadow: 0 0 6px rgba(0,255,0,0.8);
    mix-blend-mode: screen;
}

/* 3. Spectrum Pro */
.vu-spectrum_pro {
    position: relative;
    background: #050505;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 5px;
}

.pro-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(to right, rgba(255,94,31,0.03) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255,94,31,0.05) 1px, transparent 1px);
    background-size: 6.25% 20%;
    z-index: 1;
    pointer-events: none;
}

.pro-container {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 2px;
    align-items: flex-end;
    z-index: 2;
}

.pro-col {
    flex: 1;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.pro-bar {
    width: 100%;
    background: linear-gradient(to top, #00ff00 0%, #00ff00 50%, #ffff00 75%, #ff0000 100%);
    border-radius: 1px;
    height: 2%;
    transition: height 0.03s linear;
    box-shadow: 0 0 4px rgba(0,255,0,0.6);
}

.pro-peak {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #fff;
    box-shadow: 0 0 3px #fff;
    bottom: 2%;
    opacity: 0.8;
    transition: bottom 0.1s ease-out;
}

/* 4. Osciloscopio */
.vu-oscilloscope {
    position: relative;
    background: #050505;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.osc-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(to right, rgba(255,94,31,0.1) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(255,94,31,0.1) 1px, transparent 1px);
    background-size: 10% 20%;
    z-index: 1;
    pointer-events: none;
}

.osc-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 2px #ff5e1f);
    z-index: 2;
}

/* ============================================================
   VÚMETRO INLINE (Sección Transmisión Actual)
   ============================================================ */
.now-playing__visualizer .vu-rack {
    position: relative;
    bottom: auto;
    left: auto;
    margin-bottom: 0;
    width: 100%;
    max-width: 100%; /* ← FIX: No exceder el contenedor padre */
    height: 50%;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.now-playing__visualizer .vu-rack-header {
    margin-bottom: 8px;
    padding: 0 4px 6px 4px;
}

.now-playing__visualizer .vu-display-area {
    flex-grow: 1;
    height: auto;
    min-height: 100px;
    border-radius: 12px;
}

/* ============================================================
   RESPONSIVE - FIX COMPLETO PARA MÓVILES ANDROID
   ============================================================ */
@media (max-width: 1024px) {
    .now-playing__visualizer { display: none; }
}

@media (max-width: 768px) {
    .player__inner {
        grid-template-columns: auto auto 1fr auto;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
    
    .player__live-tag { display: none; }
    .player__volume { display: none; }
    #volumeSlider { display: none; }
    .player__play-btn { width: 48px; height: 48px; }
    .player__listeners { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
    
    /* FIX CRÍTICO: Vúmetro responsive en móviles */
    .vu-rack {
        left: 10px;
        right: 10px;
        width: auto;
        max-width: calc(100vw - 20px); /* ← FIX: Máximo ancho del viewport menos márgenes */
    }
}

@media (max-width: 480px) {
    .player__listeners span { display: none; }
    
    /* FIX ADICIONAL: Para móviles muy pequeños (320px-360px) */
    .vu-rack {
        left: 5px;
        right: 5px;
        max-width: calc(100vw - 10px);
        padding: 10px; /* ← Reducir padding interno */
    }
    
    .vu-display-area {
        height: 120px; /* ← Reducir altura en móviles pequeños */
    }
    
    .vu-rack-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
}

/* FIX ADICIONAL: Para móviles extremadamente pequeños (menos de 360px) */
@media (max-width: 360px) {
    .vu-rack {
        left: 5px;
        right: 5px;
        max-width: calc(100vw - 10px);
        padding: 8px;
    }
    
    .vu-display-area {
        height: 100px;
    }
    
    .vu-rack-title,
    .vu-rack-mode {
        font-size: 0.6em;
    }
}