* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overscroll-behavior: none;
    overscroll-behavior-y: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #1a1a1a 0%, #121212 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    background: #121212;
    min-height: 100vh;
    position: relative;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
}

/* Sistema de Vistas */
.view {
    width: 100%;
    min-height: 100vh;
}

/* Playlist view siempre visible debajo */
#playlistView {
    position: relative;
    pointer-events: all;
}

/* Song view se desliza sobre la playlist */
#songView {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    z-index: 10;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    overscroll-behavior: none;
    touch-action: none;
}

#songView.active {
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

/* ===== VISTA DE PLAYLIST ===== */

/* Header */
.header {
    padding: 40px 20px 30px;
    text-align: left;
    background: linear-gradient(180deg, #2a2a2a 0%, #121212 100%);
}

.playlist-icon {
    margin-bottom: 20px;
}

.playlist-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.playlist-subtitle {
    font-size: 14px;
    color: #b3b3b3;
    font-weight: 400;
    margin-bottom: 4px;
}

.playlist-subtitle-secondary {
    font-size: 14px;
    color: #b3b3b3;
    font-weight: 400;
}

/* Lista de canciones */
.songs-list {
    padding: 0 0 20px 0;
}

.song-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.song-item:hover {
    background-color: #282828;
}

.song-item:active {
    background-color: #333333;
}

/* Cover de canción */
.song-cover {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: #D97842;
    margin-right: 16px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.song-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.song-cover img.loaded {
    opacity: 1;
}

.song-cover-letter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: white;
    z-index: 1;
    pointer-events: none;
}

.song-cover img[src]:not([src=""]) {
    background: white;
}

.song-cover:has(img[src]:not([src=""])) .song-cover-letter {
    display: none;
}

/* Info de canción */
.song-info {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
}

.song-title {
    font-size: 16px;
    font-weight: 400;
    color: #ffffff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 14px;
    color: #b3b3b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Duración */
.song-duration {
    font-size: 14px;
    color: #b3b3b3;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Botón de play */
.play-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
    opacity: 0.8;
}

.play-button:hover {
    opacity: 1;
    transform: scale(1.1);
}

.play-button:active {
    transform: scale(0.95);
}

.play-button svg {
    width: 24px;
    height: 24px;
}

/* Song item activa */
.song-item.playing {
    background-color: #282828;
}

.song-item.playing .song-title {
    color: #ff6b00;
}

.song-item.playing .play-button svg path {
    fill: #ff6b00;
}

/* ===== MINI PLAYER FLOTANTE ===== */
.mini-player {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    background: linear-gradient(to bottom, #282828 0%, #181818 100%);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: transform 0.3s ease;
}

.mini-player.visible {
    transform: translateX(-50%) translateY(0);
}

/* Ocultar mini-player cuando song view está activo */
#songView.active ~ .mini-player {
    transform: translateX(-50%) translateY(100%);
}

.mini-player-progress-bar {
    width: 100%;
    height: 4px;
    background: #404040;
    cursor: pointer;
    position: relative;
}

.mini-player-progress {
    height: 100%;
    background: #ff6b00;
    width: 0%;
    transition: width 0.1s linear;
    position: relative;
}

.mini-player-progress-bar.dragging .mini-player-progress {
    transition: none;
}

.mini-player-progress::after {
    content: '';
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
}

.mini-player-progress-bar:hover .mini-player-progress::after,
.mini-player-progress-bar.dragging .mini-player-progress::after {
    opacity: 1;
}

.mini-player-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
}

.mini-player-cover {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    margin-right: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.mini-player-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.mini-player-title-wrapper {
    display: flex;
    width: fit-content;
    animation: none;
}

.mini-player-title-wrapper.marquee {
    animation: marquee 10s linear infinite;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.mini-player-title {
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
    margin-bottom: 2px;
    white-space: nowrap;
    padding-right: 20px;
}

.mini-player-artist {
    font-size: 12px;
    color: #b3b3b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-player-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.mini-player-play:hover {
    transform: scale(1.1);
}

.mini-player-play:active {
    transform: scale(0.95);
}

/* ===== VISTA DE CANCIÓN INDIVIDUAL ===== */

#songView {
    background: linear-gradient(180deg, #4a6b5a 0%, #2a3a30 30%, #1a1a1a 60%, #121212 100%);
    padding-bottom: 80px;
    overscroll-behavior: none;
    overscroll-behavior-y: none;
}

#songView.active ~ .mini-player {
    display: block;
}

/* Header de vista de canción */
.song-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    position: sticky;
    top: 0;
    background: rgba(74, 107, 90, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.back-button,
.menu-button {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-button:hover,
.menu-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.song-view-title {
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
    text-align: center;
    line-height: 1.3;
}

/* Portada grande */
.song-view-cover-container {
    padding: 40px 40px 20px;
    display: flex;
    justify-content: center;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.song-view-cover {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Info de canción en vista detalle */
.song-view-info {
    padding: 24px 24px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.song-view-main-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.song-view-name-wrapper {
    display: flex;
    width: fit-content;
    animation: none;
    margin-bottom: 8px;
}

.song-view-name-wrapper.marquee {
    animation: marquee 10s linear infinite;
}

.song-view-name {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    padding-right: 20px;
}

.song-view-artist {
    font-size: 14px;
    color: #b3b3b3;
}

.like-button {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Barra de progreso */
.song-view-progress {
    padding: 24px 24px 0;
}

.progress-bar-full {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 2px;
    width: 0%;
    position: relative;
    transition: width 0.1s linear;
}

.progress-bar-full.dragging .progress-bar-fill {
    transition: none;
}

.progress-handle {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-bar-full:hover .progress-handle {
    opacity: 1;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #b3b3b3;
}

/* Controles de reproducción */
.song-view-controls {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.control-button {
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.7;
    position: relative;
}

.control-button:hover {
    opacity: 1;
    transform: scale(1.1);
}

.control-button:active {
    transform: scale(0.95);
}

.play-pause-main {
    opacity: 1;
}

.play-pause-main:hover {
    transform: scale(1.08);
}

/* Estados activos de shuffle y repeat */
.shuffle-button.active,
.repeat-button.active {
    opacity: 1;
    color: #ff6b00;
}

.shuffle-button.active svg path,
.repeat-button.active svg path {
    fill: #ff6b00;
}

.repeat-button.repeat-one::after {
    content: '1';
    position: absolute;
    font-size: 10px;
    font-weight: 700;
    color: #ff6b00;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Botones inferiores */
.song-view-bottom {
    padding: 32px 24px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    opacity: 0.7;
}

.icon-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

/* ===== VISTA DE QUEUE ===== */
.queue-view {
    position: fixed;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 70vh;
    background: #181818;
    border-radius: 12px 12px 0 0;
    z-index: 200;
    transition: top 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.queue-view.visible {
    top: 30vh;
}

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #282828;
}

.queue-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.queue-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.queue-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.queue-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.queue-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    transition: background-color 0.2s;
}

.queue-item:hover {
    background-color: #282828;
}

.queue-item.current {
    background-color: #282828;
}

.queue-item.current .queue-item-title {
    color: #ff6b00;
}

.queue-item-cover {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
}

.queue-item-info {
    flex: 1;
    min-width: 0;
}

.queue-item-title {
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.queue-item-artist {
    font-size: 12px;
    color: #b3b3b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive para desktop */
@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
    }

    .container {
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}
