/**
 * RoKaPlayer - Estilos del Reproductor
 * Version: 1.0.0 - CORREGIDO
 */

/* ===== VARIABLES CSS ===== */
:root {
    --primary-color: #fdbb2d;
    --primary-rgb: 253, 187, 45;
    --player-bg: #282828;
    --player-bg-rgb: 40, 40, 40;
    --player-bg-opacity: 0.95;
    --overlay-color: #1a2a6c;
    --overlay-rgb: 26, 42, 108;
    --overlay-opacity: 0.85;
    --active-green: #2ecc40;
    --inactive-red: #c0392b;
    --border-radius: 16px;
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.roka-player-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
    position: relative;
    font-family: var(--font-main);
    color: #d1d5db;
    background: linear-gradient(135deg, #181c2b 0%, #23243a 100%);
    border-radius: 16px;
    overflow: hidden;
    padding-bottom: 3.5cm;
}

/* ===== TARJETAS DE EMISORAS ===== */
.radio-grid-wrapper {
    margin: 20px 0 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.radio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.radio-card {
    display: grid;
    grid-template-columns: 80px 1fr;
    grid-template-rows: auto auto auto auto auto;
    gap: 8px;
    padding: 16px;
    background: rgba(26, 42, 108, 0.85);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    z-index: 1;
}

.radio-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.22);
}

/* ===== EL LOGO DE LA EMISORA SIGUE SIENDO EL LOGO ===== */
.radio-image {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.15);
    justify-self: center;
    align-self: center;
}

.radio-button-group {
    grid-column: 1 / span 2;
    grid-row: 2;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: -10px;
}

.website-btn {
    background: var(--website-btn-color, #0073aa) !important;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-decoration: none;
}

.website-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.custom-play-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, filter 0.2s;
    background: var(--inactive-red);
    color: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    outline: none;
}

.custom-play-btn:not(.active):hover {
    filter: brightness(1.08);
    background: #e74c3c;
}

.custom-play-btn.active {
    background: var(--active-green);
    animation: flicker 0.7s infinite alternate;
    box-shadow: 0 0 10px 4px rgba(46, 204, 64, 0.7);
}

@keyframes flicker {
    0% { filter: brightness(1.15); }
    25% { filter: brightness(1.5); }
    50% { filter: brightness(1.1); }
    75% { filter: brightness(1.5) saturate(1.3); }
    100% { filter: brightness(1.2); }
}

.radio-info {
    grid-column: 1 / span 2;
    grid-row: 3;
    text-align: center;
}

.radio-info h3 {
    font-size: 1.2rem;
    margin: 0;
    color: #FFDF00;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.radio-details {
    grid-column: 1 / span 2;
    grid-row: 4;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 6px 0;
}

.radio-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.radio-detail i {
    color: var(--primary-color);
    width: 16px;
}

/* ===== MEJORAR VISUALIZACIÓN DE CARÁTULAS ===== */
.now-playing-cover {
    grid-column: 1;
    grid-row: 5;
    width: 100%;
    max-width: 100px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    justify-self: center;
    align-self: start;
    transition: opacity 0.5s ease;
    background: rgba(0,0,0,0.2);
}

.now-playing-cover.loading {
    opacity: 0.3;
}

.now-playing-cover:not(.loading) {
    opacity: 1;
}

.now-playing-preview {
    grid-column: 2;
    grid-row: 5;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(1px);
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
    overflow: hidden;
}

.now-playing-preview .song-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.now-playing-preview .song-artist {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== SHORTCODES INTERMEDIOS ===== */
.shortcode-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 32px;
    margin: 24px auto;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.shortcode-item {
    flex: 1 1 48%;
    min-width: 280px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

/* ============================================
   BARRA DEL REPRODUCTOR - CORREGIDA
   ============================================ */
.barra-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100%;
    height: 3cm;
    background-color: #282828;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 10000;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}



/* Logo en el reproductor */
.radio-info {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 10px;
    z-index: 10;
}

.radio-logo {
    height: 2.5cm;
    width: auto;
    max-width: 80px;
    border-radius: 5px;
    object-fit: contain;
}

.radio-name {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
    white-space: nowrap;
}

/* Metadatos - Carátula y texto */
.metadata {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    margin: 0 15px;
    z-index: 10;
}

.player-cover {
    width: 2.5cm;
    height: 2.5cm;
    overflow: hidden;
    border-radius: 4px;
    margin-right: 10px;
    background-color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

.player-cover.loading::before {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #eee;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.song-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.song-title {
    font-size: 0.95rem;
    margin: 0 0 2px 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 0.75rem;
    margin: 0;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controles a la derecha */
.player-controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    z-index: 10;
}

.controls.player-controller {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-button {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    position: relative;
}

.player-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.player-button-play {
    background: var(--primary-color);
    color: #333;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
}

.player-button-play:hover {
    background: #ffdd44;
    transform: scale(1.08);
}

.player-button-play.playing {
    background: var(--active-green);
    color: #fff;
    animation: pulse-green 0.7s infinite alternate;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 10px rgba(46, 204, 64, 0.3); }
    100% { box-shadow: 0 0 25px rgba(46, 204, 64, 0.7); }
}

.volume-button {
    font-size: 1.1rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    position: absolute;
    z-index: 5;
    background: #f0f0f0;
    border-radius: 8px;
    height: 8px;
    width: 100px;
    cursor: pointer;
    bottom: 125%;
    right: 0;
    display: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #d4a000;
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #d4a000;
}

/* ============================================
   VISUALIZADOR - CORREGIDO (detrás de todo)
   ============================================ */
.visualizer-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0; /* DETRAS de todo */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.visualizer-container.active {
    opacity: 0.5;
}

#audio-visualizer {
    display: block;
    width: 100%;
    height: 100%;
}

/* Fondo dinámico (detrás de todo) */
.dynamic-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0.25;
    z-index: -1;
    filter: blur(8px) brightness(0.7);
}

/* ===== ELEMENTOS DEL REPRODUCTOR - ENCIMA DEL VISUALIZADOR ===== */
.radio-info,
.metadata,
.player-controls-right {
    position: relative;
    z-index: 5; /* Encima del visualizador */
}

.song-details,
.controls {
    position: relative;
    z-index: 5;
}

/* Personalización de shortcodes intermedios */
.shortcode-item {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 16px !important;
    padding: 20px !important;
    transition: all 0.3s ease;
}

.shortcode-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

/* Títulos dentro de los shortcodes */
.shortcode-item h2,
.shortcode-item h3,
.shortcode-item h4 {
    color: #FFDF00 !important;
    margin-bottom: 10px !important;
}

/* Texto dentro de los shortcodes */
.shortcode-item p,
.shortcode-item span,
.shortcode-item div {
    color: #d1d5db !important;
}

/* ===== MENSAJES ===== */
.offline-message, .online-message {
    position: fixed;
    bottom: 90px;
    left: 20px;
    padding: 12px 24px;
    border-radius: 32px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10001;
    font-weight: 600;
    font-size: 0.9rem;
}

.offline-message { 
    background: #ff6b6b; 
    color: white; 
}

.online-message { 
    background: #4CAF50; 
    color: white; 
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .radio-grid {
        grid-template-columns: 1fr;
    }
    
    .radio-card {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto auto;
    }
    
    .radio-image {
        grid-column: 1;
        grid-row: 1;
        width: 80px;
        height: 80px;
    }
    
    .radio-button-group {
        grid-column: 1;
        grid-row: 2;
    }
    
    .radio-info {
        grid-column: 1;
        grid-row: 3;
    }
    
    .radio-details {
        grid-column: 1;
        grid-row: 4;
    }
    
    .now-playing-cover {
        grid-column: 1;
        grid-row: 5;
        justify-self: center;
        max-width: 80px;
        height: 80px;
    }
    
    .now-playing-preview {
        grid-column: 1;
        grid-row: 6;
        text-align: center;
    }
    
    .shortcode-row {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .shortcode-item {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    .barra-player {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .radio-info {
        display: none !important;
    }
    
    .metadata {
        flex: 1;
        min-width: 0;
        margin: 0 8px;
    }
    
    .player-cover {
        width: 45px;
        height: 45px;
    }
    
    .song-title {
        font-size: 0.8rem;
    }
    
    .song-artist {
        font-size: 0.65rem;
    }
    
    .player-button {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .player-button-play {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .volume-slider {
        width: 70px;
        height: 6px;
        bottom: 115%;
        right: -5px;
    }
}

@media (max-width: 480px) {
    .radio-card {
        padding: 12px;
    }
    
    .radio-info h3 {
        font-size: 1rem;
    }
    
    .radio-detail {
        font-size: 0.75rem;
    }
    
    .player-cover {
        width: 35px;
        height: 35px;
    }
    
    .song-title {
        font-size: 0.7rem;
    }
    
    .song-artist {
        font-size: 0.6rem;
    }
}

@media (min-width: 769px) {
    .radio-info {
        display: flex !important;
    }
}