/* CSS Document */

/* Importar fuente (ej. Roboto) */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at top right, #1e1e3f, #0d0d1e);
    /* Fondo con gradiente */
    color: #e0e0e0;
    overflow-x: hidden;
    min-height: 100vh;
}

.player-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 450px;
    margin: 0 auto;
    background-color: transparent; /* Fondo transparente para ver los gradientes traseros */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
    padding-bottom: 110px;
    /* Espacio para el reproductor inferior fijo con la barra */
    overflow: hidden;
    /* Asegura que el pseudo-elemento no se salga */
}

/* Fondos dinámicos en capas superpuestas para crossfade fluido */
.bg-gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    transition: opacity 1.5s ease-in-out;
    background: radial-gradient(circle at top right, #1e1e3f, #0d0d1e);
}

#bg-overlay-1 {
    opacity: 1;
}

#bg-overlay-2 {
    opacity: 0;
}

/* Fondo central sutil con altavoz.jpg */
.player-app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background-image: url('altavoz.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.15;
    /* Sutil y transparente */
    z-index: 1; /* Elevado a 1 para estar sobre el gradiente pero bajo el contenido */
    pointer-events: none;
    filter: grayscale(30%);
}

.player-app>* {
    position: relative;
    z-index: 2; /* Incrementado a 2 para flotar sobre el fondo y la textura */
}

/* --- ENCABEZADO Y VINILO (Estilos existentes) --- */
.app-header {
    display: flex;
    align-items: center;
    padding: 20px 15px;
    background-color: rgba(26, 26, 46, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
    flex-shrink: 0; /* Evita que flexbox colapse la cabecera en pantallas de baja altura */
}

.main-album-title {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #e0e0e0;
    margin: 30px auto 15px;
    letter-spacing: 1px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.back-button {
    color: #e0e0e0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.back-button:hover {
    color: #007bff;
}

/* El visualizador superior ha sido eliminado, ahora se integra en la lista */
.vinyl-display {
    position: relative;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
}

.vinyl-image,
.vinyl-image-temp {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    filter: brightness(0.8);
    animation: rotate-vinyl 20s linear infinite;
    animation-play-state: paused;
}

/* El disco gira cuando el contenedor tiene la clase .playing */
.vinyl-display.playing .vinyl-image {
    animation-play-state: running;
}

@keyframes rotate-vinyl {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.vinyl-center {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: #fce8d6;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* --- LISTA DE PISTAS --- */
.tracklist-section {
    flex-grow: 1;
    padding: 0 15px 20px;
}

.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.track-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: rgba(42, 42, 74, 0.4);
    /* Fondo semi-transparente */
    backdrop-filter: blur(5px);
    /* Glassmorphism */
    -webkit-backdrop-filter: blur(5px);
    margin-bottom: 12px;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    /* Importante para el pseudo-elemento */
}

.track-main-content {
    display: flex;
    align-items: center;
    width: 100%;
}

.track-vinyl-container {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease, margin-top 0.5s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.track-item.active .track-vinyl-container {
    max-height: 220px; /* Restaurado para el vinilo (200px) + márgenes */
    opacity: 1;
    margin-top: 15px;
    padding-bottom: 5px;
}

.visualizer-card {
    height: 72px;
    padding: 0;
    overflow: hidden;
    cursor: default;
    pointer-events: none;
    background: rgba(42, 42, 74, 0.4) !important; /* Fondo cristalino translúcido */
    border: 1px solid rgba(0, 123, 255, 0.2) !important; /* Borde neón sutil */
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.1) !important;
}

.visualizer-card::before {
    display: none !important; /* Ocultar fondo difuminado */
}

.visualizer-card .visualizer-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    margin: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Fondo difuminado con la carátula */
.track-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--track-cover);
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.4);
    opacity: 0.6;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.track-item:not(.visualizer-card):hover::before {
    opacity: 0.8;
}

.track-item:not(.visualizer-card):hover {
    background-color: #2a2a4a;
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

.track-item:not(.visualizer-card):active {
    transform: scale(0.98);
}

.track-item.active {
    background-color: #252550;
    /* Fondo azul oscuro para la pista activa */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.track-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    /* Bordes más suaves */
    margin-right: 15px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.track-cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.3s ease;
}

.track-item:hover .track-icon {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.4);
}

/* Efecto para pista activa */
.track-item.active .track-icon {
    border-radius: 50%;
    /* Convertir en círculo tipo vinilo */
    animation: pulse-active 2s infinite ease-in-out;
    border: 2px solid #007bff;
}

.track-item.active .track-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: #1a1a2e;
    border-radius: 50%;
    box-shadow: inset 0 0 2px rgba(255, 255, 255, 0.5);
}

@keyframes pulse-active {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

.track-details-list {
    flex-grow: 1;
}

.track-details-list h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    color: #e0e0e0;
}

.track-details-list p {
    margin: 0;
    font-size: 13px;
    color: #8c8c99;
}

.track-arrow {
    font-size: 24px;
    color: #8c8c99;
    margin-left: 15px;
}


/* --- REPRODUCTOR INFERIOR FIJO Y BARRA DE PROGRESO --- */

.bottom-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    background: rgba(42, 42, 74, 0.7);
    /* Fondo cristal para el reproductor */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    z-index: 20;
    display: flex;
    flex-direction: column;
}

/* 1. Barra de Progreso */
.progress-bar-container {
    padding: 10px 15px 0;
    /* Espacio superior para la barra */
    cursor: pointer;
}

.progress-bar {
    position: relative;
    height: 4px;
    width: 100%;
    background-color: #3a3a5a;
    /* Color de la barra vacía */
    border-radius: 2px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    /* Controlado por JS */
    background-color: #007bff;
    /* Color de relleno */
    border-radius: 2px;
}

.progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    /* Controlado por JS */
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    display: block;
    /* Siempre visible para mejor UX */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.progress-bar-container:hover .progress-handle {
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

/* 2. Contenido del Reproductor */
.player-content {
    display: flex;
    align-items: center;
    padding: 10px 15px 15px;
}

.current-track-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
    margin-right: 15px;
}

.bottom-player .track-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bottom-player .track-details {
    overflow: hidden;
}

.bottom-player .track-title {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-player .track-duration-current {
    margin: 0;
    font-size: 12px;
    color: #8c8c99;
}

.player-buttons {
    display: flex;
    align-items: center;
}

.player-button {
    font-size: 30px;
    color: #e0e0e0;
    cursor: pointer;
    margin: 0 8px;
    transition: all 0.2s ease;
}

.player-button:hover {
    color: #007bff;
    text-shadow: 0 0 10px rgba(0, 123, 255, 0.8);
    transform: scale(1.2);
}

.player-button:active {
    transform: scale(0.9);
}

.player-button.play-pause {
    font-size: 45px;
    color: #007bff;
    text-shadow: 0 0 15px rgba(0, 123, 255, 0.5);
}

.player-button.play-pause:hover {
    text-shadow: 0 0 20px rgba(0, 123, 255, 1);
}

#audio-player {
    display: none;
}

/* --- TARJETA DE INTRODUCCIÓN DEL ÁLBUM --- */
.album-intro-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.album-square-cover {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 320px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.intro-album-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.intro-album-image:hover {
    transform: scale(1.05);
}

.album-intro-text {
    width: 100%;
    text-align: justify;
}

.album-intro-text p {
    font-size: 14px;
    line-height: 1.6;
    color: #c0c0d0;
    margin: 0;
    font-weight: 300;
}

/* --- TARJETA DE DETALLE DEL TEMA ACTIVO --- */
.active-song-detail-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px 15px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
}

.active-song-detail-cover {
    width: 55px;
    height: 55px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.active-song-detail-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.active-song-detail-text h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.active-song-detail-text p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
    color: #a0a0b0;
    font-weight: 300;
}

/* --- CRÉDITOS DEL ÁLBUM --- */
.album-credits-card {
    background: rgba(13, 13, 30, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    padding: 15px 20px;
    margin-top: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.album-credits-card h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #007bff;
}

.album-credits-card p {
    font-size: 12px;
    line-height: 1.6;
    color: #8c8ca0;
    margin: 0;
    font-weight: 300;
}

/* --- LAYOUT RESPONSIVE (MÓVIL Y ESCRITORIO SPLIT-SCREEN) --- */

.app-layout-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex-shrink: 0;
}

.left-panel, .right-panel {
    width: 100%;
}

.desktop-player-section {
    display: none; /* Oculto por defecto en móvil */
}

/* Escritorio (Pantallas medianas y grandes >= 850px) */
@media (min-width: 850px) {
    .player-app {
        max-width: 100vw !important;
        width: 100%;
        margin: 0 auto;
        border-radius: 0;
        border: none;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding-bottom: 0 !important;
        box-shadow: none;
        min-height: 100vh;
    }

    .app-layout-container {
        flex-direction: row;
        align-items: stretch;
        height: 100vh;
        overflow: hidden;
    }
    
    .left-panel {
        width: 38%;
        padding: 20px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
        overflow-y: hidden;
        box-sizing: border-box;
    }

    /* La tarjeta de detalle crece para llenar el espacio restante del panel izquierdo */
    .left-panel #active-song-detail {
        flex: 1;
        margin-top: 12px;
        margin-bottom: 0;
        padding: 14px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        background: rgba(255, 255, 255, 0.02) !important;
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 12px;
        box-sizing: border-box;
        width: 100%;
        gap: 10px;
    }

    .left-panel #active-song-detail .active-song-detail-cover {
        width: 100%;
        max-width: 140px;
        height: auto;
        aspect-ratio: 1;
        object-fit: cover;
        border-radius: 10px;
        flex-shrink: 0;
    }

    .left-panel #active-song-detail .active-song-detail-text {
        flex: 1;
        overflow-y: auto;
    }

    .left-panel #active-song-detail .active-song-detail-text h4 {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .left-panel #active-song-detail .active-song-detail-text p {
        font-size: 10.5px;
        line-height: 1.5;
        color: #909099;
    }
    
    .right-panel {
        width: 62%; /* Más espacio para las dos columnas */
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }
    
    .right-panel .tracklist-section {
        flex: 1;
        overflow-y: auto;
        padding: 25px;
    }

    /* Playlist en 2 columnas (filas de grid) */
    .right-panel .track-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin: 0;
        padding: 0;
    }
    
    .desktop-player-section {
        display: flex;
        width: 100%;
        justify-content: center;
        margin-top: 15px;
        box-sizing: border-box;
    }
    
    /* Impedir la expansión de la pista activa en el listado derecho */
    .track-item.active .track-vinyl-container {
        max-height: 0 !important;
        opacity: 0 !important;
        margin-top: 0 !important;
        padding-bottom: 0 !important;
        border: none !important;
    }
    
    /* Vinilo en panel izquierdo */
    #desktop-vinyl-container .vinyl-display {
        width: 170px;
        height: 170px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 123, 255, 0.2);
    }
    
    #desktop-vinyl-container .vinyl-image {
        width: 170px;
        height: 170px;
    }
    
    #desktop-vinyl-container .vinyl-center {
        width: 38px;
        height: 38px;
    }
    
    /* Estilos para controles de música empotrados a la izquierda */
    #desktop-controls-container #bottom-player-controls {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none !important;
        border-top: none !important;
        padding: 0 !important;
        margin-top: 5px;
        width: 100% !important;
    }
    
    #desktop-controls-container .player-content {
        flex-direction: column !important;
        gap: 6px !important;
        align-items: center !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    #desktop-controls-container .current-track-info {
        text-align: center !important;
        justify-content: center !important;
        width: 100% !important;
    }
    
    #desktop-controls-container .current-track-info .track-icon {
        display: none !important; /* Quitar miniatura redundante */
    }
    
    #desktop-controls-container .player-buttons {
        justify-content: center !important;
        width: 100% !important;
        gap: 15px !important;
    }
    
    #desktop-controls-container .progress-bar-container {
        padding: 0 !important;
        margin-bottom: 5px !important;
        width: 100%;
    }
    
    /* Visualizador en panel izquierdo */
    #desktop-visualizer-container .visualizer-card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        margin: 0;
        padding: 0;
        width: 100%;
    }
    
    #desktop-visualizer-container .visualizer-canvas {
        height: 70px;
    }
    
    /* Adaptar carátula e intro para que todo quepa a la izquierda sin scroll */
    .left-panel .album-square-cover {
        max-width: 90px;
        margin-bottom: 5px;
    }
    
    .left-panel .album-intro-card {
        padding: 10px;
        margin-bottom: 5px;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        box-sizing: border-box;
    }

    .left-panel .album-intro-text p {
        font-size: 11px;
        line-height: 1.4;
    }
    
    /* Barra de scroll personalizada solo en el listado derecho */
    .right-panel .tracklist-section::-webkit-scrollbar {
        width: 6px;
    }
    .right-panel .tracklist-section::-webkit-scrollbar-track {
        background: transparent;
    }
    .right-panel .tracklist-section::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
    }
    .right-panel .tracklist-section::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    /* Estilos de la tarjeta de detalle cuando está fuera del panel izquierdo (móvil) */
    #active-song-detail {
        display: none; /* En escritorio solo se muestra dentro del panel izquierdo via .left-panel rules */
    }

    .left-panel #active-song-detail {
        display: flex !important;
    }

    /* Ocultar la cabecera (título y botón atrás) en versión de escritorio */
    .app-header {
        display: none !important;
    }
}