/* ===================================
   COLUMNA ARTISTA - Panel Lateral Derecho
   =================================== */

/* Contenedor principal con 3 columnas */
#viewHome.artist-panel-open {
    /* Cuando el panel está abierto */
}

/* Columna del Artista - Oculta por defecto */
#artistColumn {
    width: 0;
    min-width: 0;
    flex-shrink: 0;
    opacity: 0;
    overflow: hidden;
    visibility: hidden;
    contain: layout paint;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0s 0.4s;
    background: linear-gradient(180deg,
        rgba(15, 15, 25, 0.98) 0%,
        rgba(10, 10, 18, 0.99) 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
}

/* Columna visible */
#artistColumn.visible {
    width: 320px;
    min-width: 320px;
    opacity: 1;
    visibility: visible;
    contain: none;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0s 0s;
}

/* La columna central se reduce cuando el panel del artista está abierto */
#viewHome.artist-panel-open #contentColumn {
    min-width: 0;
    flex: 1 1 0;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Todas las secciones internas deben poder reducirse */
#viewHome.artist-panel-open #contentColumn section,
#viewHome.artist-panel-open #contentColumn > div,
#viewHome.artist-panel-open #contentColumn .favorites-carousel-header,
#viewHome.artist-panel-open #contentColumn #categoriesCarousels,
#viewHome.artist-panel-open #contentColumn #genresGrid {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Carruseles se ajustan al espacio disponible */
#viewHome.artist-panel-open .carousel-wrapper {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}

#viewHome.artist-panel-open .carousel-track {
    width: auto;
    max-width: none;
}

/* El grid de covers se ajusta automáticamente */
#viewHome.artist-panel-open #categoryCoversGrid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

/* Explorar géneros se ajusta */
#viewHome.artist-panel-open #exploreGenres {
    min-width: 0;
    overflow: hidden;
}

/* El grid de géneros ya usa auto-fill, solo asegurar min-width consistente */
#viewHome.artist-panel-open .genres-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Categorías dinámicas (category_carousels) se ajustan */
#viewHome.artist-panel-open .category-section {
    min-width: 0;
    overflow: hidden;
}

#viewHome.artist-panel-open .category-carousel-wrapper {
    min-width: 0;
    max-width: 100%;
}

#viewHome.artist-panel-open .category-track {
    min-width: 0;
}

#viewHome.artist-panel-open .category-header {
    min-width: 0;
    overflow: hidden;
}

/* Favoritos se ajustan */
#viewHome.artist-panel-open #favoritesCarouselSection {
    min-width: 0;
    overflow: hidden;
}

#viewHome.artist-panel-open .favorites-track {
    min-width: 0;
}

/* Header con cover del artista */
.artist-header {
    position: relative;
    padding: 0;
}

/* Desktop: clipea el cover cuando colapsa al hacer scroll */
@media (min-width: 601px) {
    .artist-header {
        overflow: hidden;
    }
}

.artist-cover-container {
    position: relative;
    width: 100%;
    margin: 0 0 16px;
}

.artist-cover {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.05);
}

.artist-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.artist-cover .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
        rgba(99, 102, 241, 0.2),
        rgba(139, 92, 246, 0.1));
}

.artist-cover .no-image svg {
    width: 60px;
    height: 60px;
    color: rgba(255, 255, 255, 0.3);
}

/* Nombre del artista */
.artist-name {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    color: white;
    margin-bottom: 4px;
    line-height: 1.2;
    padding: 0 16px;
}

/* Canción actual */
.current-song-title {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2rem;
}

.current-song-title .playing-icon {
    display: inline-flex;
    gap: 2px;
    align-items: flex-end;
    height: 12px;
}

.current-song-title .playing-icon span {
    width: 3px;
    background: #8b5cf6;
    border-radius: 1px;
    animation: soundwave 0.5s ease-in-out infinite alternate;
}

.current-song-title .playing-icon span:nth-child(1) { height: 40%; animation-delay: 0s; }
.current-song-title .playing-icon span:nth-child(2) { height: 70%; animation-delay: 0.1s; }
.current-song-title .playing-icon span:nth-child(3) { height: 50%; animation-delay: 0.2s; }
.current-song-title .playing-icon span:nth-child(4) { height: 80%; animation-delay: 0.3s; }

@keyframes soundwave {
    0% { transform: scaleY(0.5); }
    100% { transform: scaleY(1); }
}

/* Sección de contenido scrolleable */
.artist-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 80px; /* 80px para la barra inferior */
}

.artist-content::-webkit-scrollbar {
    width: 4px;
}

.artist-content::-webkit-scrollbar-track {
    background: transparent;
}

.artist-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* Secciones */
.artist-section {
    margin-bottom: 20px;
}

.artist-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.artist-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Detalles compactos en línea */
.song-details-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.song-detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
}

.song-detail-tag .icon {
    font-size: 12px;
}

.song-detail-tag .value {
    font-weight: 500;
    color: white;
}

/* Biografía - colapsada por defecto */
.artist-bio {
    font-size: 0.8rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.artist-bio .bio-text {
    display: none;
}

.artist-bio.expanded .bio-text {
    display: block;
    margin-bottom: 6px;
}

.artist-bio.loading .bio-text {
    display: block;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

.bio-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 0.7rem;
}

.bio-expand-btn:hover {
    color: white;
}

.bio-expand-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.bio-expand-btn.expanded svg {
    transform: rotate(180deg);
}

/* Detalles - colapsados por defecto */
.song-details-compact {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
}

.song-details-compact.expanded {
    display: flex;
}

.details-section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 0.7rem;
}

.details-section-header:hover {
    color: white;
}

.details-section-header svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.details-section-header.expanded svg {
    transform: rotate(180deg);
}

/* Lista de canciones del artista */
.artist-songs-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.artist-song-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}

.artist-song-item:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

.artist-song-item.playing {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
}

.artist-song-cover {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.artist-song-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.artist-song-cover .no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artist-song-cover .no-cover svg {
    width: 18px;
    height: 18px;
    color: rgba(255, 255, 255, 0.2);
}

.artist-song-info {
    flex: 1;
    min-width: 0;
}

.artist-song-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist-song-album {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist-song-duration {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

/* Play icon on hover */
.artist-song-item .play-icon {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #8b5cf6;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.artist-song-item:hover .play-icon {
    display: flex;
}

.artist-song-item:hover .artist-song-duration {
    display: none;
}

/* Botón volver (flecha) - oculto en desktop, visible en móvil */
.back-artist-panel {
    display: none; /* Oculto por defecto en desktop */
    position: absolute;
    top: 16px;
    left: 16px;
    height: 44px;
    padding: 0 16px 0 12px;
    border-radius: 22px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border: none;
    color: white;
    cursor: pointer;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    z-index: 10;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.back-artist-panel svg {
    width: 22px;
    height: 22px;
}

.back-artist-panel:hover {
    background: linear-gradient(135deg, #fbbf24, #f87171);
    transform: translateX(-2px);
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.9), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.back-artist-panel:active {
    transform: scale(0.95);
}

/* Botón cerrar panel (X) */
.close-artist-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.close-artist-panel:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Empty state */
.artist-songs-empty {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
}

/* ===================================
   MINI REPRODUCTOR EN PANEL ARTISTA
   =================================== */
.artist-mini-player {
    display: none; /* Oculto en desktop */
    padding: 12px 16px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Barra de progreso */
.amp-progress-container {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 12px;
}

.amp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.amp-progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: left 0.1s linear;
}

.amp-progress-container:active .amp-progress-thumb {
    transform: translate(-50%, -50%) scale(1.2);
}

/* Controles */
.amp-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.amp-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.amp-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.amp-btn svg {
    width: 22px;
    height: 22px;
}

.amp-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.amp-btn-play {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.amp-btn-play svg {
    width: 28px;
    height: 28px;
}

.amp-btn-play:active {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

.amp-icon-play,
.amp-icon-pause {
    display: block;
}

.amp-icon-play.hidden,
.amp-icon-pause.hidden {
    display: none;
}

/* ===================================
   RESPONSIVE
   =================================== */

/* Tablet */
@media (max-width: 1024px) {
    #artistColumn.visible {
        width: 280px;
        min-width: 280px;
    }
}

/* Mobile - Panel overlay (≤600px) */
@media (max-width: 600px) {
    #artistColumn {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        /* No definir width aquí - heredar width:0 de app-critical.css
           para evitar extender el documento más allá del viewport */
        height: 100dvh;
        z-index: 9998;
        transform: translateX(100vw);
        opacity: 0;
        overflow: hidden;
        border-left: none;
        background: linear-gradient(180deg,
            rgb(15, 15, 25) 0%,
            rgb(10, 10, 18) 100%);
        visibility: hidden;
        contain: layout paint;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0s 0.4s;
    }

    /* Visible: panel ocupa toda la pantalla */
    #artistColumn.visible {
        transform: translateX(0);
        width: 100vw;
        min-width: 100vw;
        opacity: 1;
        visibility: visible;
        contain: none;
        overflow-y: auto;
        overflow-x: hidden;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0s 0s;
    }

    /* Header: parte del flujo de scroll (no fijo) */
    #artistColumn .artist-header {
        padding-top: 56px;
        position: relative;
        background: linear-gradient(180deg,
            rgba(15, 15, 25, 1) 0%,
            rgba(10, 10, 18, 1) 100%);
        z-index: 2;
    }

    /* Contenido: sin scroll propio, fluye con el panel */
    #artistColumn .artist-content {
        position: relative;
        background: rgb(10, 10, 18);
        overflow-y: visible;
        flex: 0 0 auto;
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    /* Cover ocupa todo el ancho en móvil */
    #artistColumn .artist-cover-container {
        max-width: 100%;
        width: 100%;
        margin: 0 0 16px;
    }

    #artistColumn .artist-cover {
        width: 100%;
        aspect-ratio: 5 / 3;
        border-radius: 0;
    }

    /* Botón cerrar - esquina superior derecha (absolute dentro de artist-header) */
    #artistColumn .close-artist-panel {
        position: absolute;
        top: 60px;
        right: 16px;
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.7);
        border: 2px solid rgba(255, 255, 255, 0.3);
        z-index: 10;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    }

    #artistColumn .close-artist-panel svg {
        width: 20px;
        height: 20px;
    }

    /* Botón volver - parte inferior izquierda de la carátula (absolute dentro de artist-header) */
    #artistColumn .back-artist-panel {
        display: flex;
        position: absolute;
        top: calc(56px + 60vw - 52px);
        left: 16px;
        z-index: 10;
    }

    /* Mini reproductor STICKY - queda fijo debajo del header (56px) cuando el cover desaparece */
    #artistColumn .artist-mini-player {
        display: block;
        position: sticky;
        top: 56px;
        z-index: 5;
        background: rgb(10, 10, 18);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    /* Ocultar biografía y detalles en móvil */
    #artistColumn .artist-bio,
    #artistColumn .song-details-compact,
    #artistColumn .artist-section:has(.artist-bio),
    #artistColumn .artist-section:has(.song-details-compact) {
        display: none;
    }

    /* Artista clickeable en lista de canciones */
    .song-artist {
        background: linear-gradient(90deg, #f97316, #ec4899, #8b5cf6);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-weight: 600;
        padding: 2px 6px;
        border-radius: 4px;
        border: 1px solid rgba(249, 115, 22, 0.4);
        margin-left: -6px;
    }

    .song-artist:active {
        background: linear-gradient(90deg, #fb923c, #f472b6, #a78bfa);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        border-color: rgba(249, 115, 22, 0.7);
    }
}
