/* assets/css/estilo.css */

/* --- RESET Y BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0d0d1a;
    color: #e8e8e8;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
}

/* --- OVERLAY DE CARGA --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0d0d1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.8s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid #1a1a3e;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-overlay p {
    margin-top: 20px;
    color: #888;
    font-size: 14px;
    letter-spacing: 2px;
}

/* --- CONTENEDOR PRINCIPAL --- */
#app {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 900px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(ellipse at 50% 30%, #1a1a3e, #0d0d1a);
}

/* --- BOTÓN DE HISTORIAL --- */
.btn-historial {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

.btn-historial:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.badge-historial {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e94560;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- REPRODUCTOR --- */
.reproductor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding-top: 20px;
}

/* --- PORTADA --- */
.portada-container {
    position: relative;
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1/1;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    background: #1a1a2e;
}

#portada {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.4s ease;
}

.badge-version {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- FLECHAS DE NAVEGACIÓN --- */
.flecha {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    z-index: 5;
}

.flecha:hover {
    background: rgba(233, 69, 96, 0.6);
    border-color: rgba(233, 69, 96, 0.75);
    color: #fff;
}

.flecha:active {
    background: rgba(233, 69, 96, 0.85);
    border-color: rgba(233, 69, 96, 0.9);
}

.flecha svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.flecha-arriba {
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
}

.flecha-abajo {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
}

.flecha-izquierda {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
}

.flecha-derecha {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
}

.flecha.oculta {
    opacity: 0;
    pointer-events: none;
}

/* --- INFORMACIÓN DE CANCIÓN --- */
.info-cancion {
    text-align: center;
    width: 100%;
    padding: 0 10px;
}

.titulo-like {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

#titulo {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0;
    color: #fff;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.btn-like {
    background: transparent;
    border: none;
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.45);
    transition: transform 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.btn-like svg {
    width: 26px;
    height: 26px;
    fill: transparent;
    stroke: currentColor;
    stroke-width: 1.5;
    transition: fill 0.2s ease, stroke 0.2s ease, transform 0.2s ease;
}

.btn-like:hover {
    color: rgba(255, 255, 255, 0.85);
    transform: scale(1.08);
}

.btn-like.activo,
.btn-like.activo:hover {
    color: #e94560;
}

.btn-like.activo svg {
    fill: #e94560;
    stroke: #e94560;
}

.btn-like:active {
    transform: scale(0.92);
}

.meta-cancion {
    font-size: 13px;
    color: #888;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.separador {
    color: #444;
}

/* --- LETRA (DESPLAZABLE) --- */
.letra-container {
    width: 100%;
    max-height: 140px;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.letra-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(13, 13, 26, 0.9), transparent);
    pointer-events: none;
}

.letra-scroll {
    max-height: 110px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-right: 6px;
}

.letra-scroll::-webkit-scrollbar {
    width: 3px;
}

.letra-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.letra-scroll::-webkit-scrollbar-thumb {
    background: rgba(233, 69, 96, 0.4);
    border-radius: 10px;
}

#letra-texto {
    font-size: 16px;
    line-height: 1.75;
    color: #ccc;
    white-space: pre-wrap;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-style: normal;
    transition: color 0.3s;
}

#letra-texto .verso-actual,
#letra-texto .linea-letra.verso-actual {
    color: #e94560;
    font-weight: 600;
    font-style: normal;
}

/* --- CONTROLES DE REPRODUCCIÓN --- */
.controles {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.btn-play-pause {
    background: #e94560;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-play-pause:hover {
    transform: scale(1.05);
    background: #d63851;
}

.btn-play-pause:active {
    transform: scale(0.92);
}

.btn-play-pause svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.progreso-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progreso-container span {
    font-size: 12px;
    color: #666;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
}

#barra-progreso {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
    transition: height 0.2s;
}

#barra-progreso::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
}

#barra-progreso::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
}

.btn-volumen {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.3s;
}

.btn-volumen:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

/* --- MODAL DE HISTORIAL --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.abierto {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.cerrar-modal {
    background: none;
    border: none;
    color: #666;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 1;
}

.cerrar-modal:hover {
    color: #fff;
}

.lista-historial {
    padding: 16px 20px 20px;
    overflow-y: auto;
    flex: 1;
}

.lista-historial .mensaje-vacio {
    color: #666;
    text-align: center;
    padding: 30px 0;
    font-size: 14px;
}

.item-historial {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.item-historial:hover {
    background: rgba(255,255,255,0.04);
}

.item-historial img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

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

.item-historial .titulo {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-historial .meta {
    font-size: 11px;
    color: #666;
}

.item-historial .escuchada {
    font-size: 11px;
    color: #e94560;
}

.like-historial {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.like-historial svg {
    width: 16px;
    height: 16px;
    fill: #e94560;
    stroke: #e94560;
}

.like-historial:not(.activo) {
    visibility: hidden;
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    #app {
        padding: 12px;
        max-height: 100vh;
    }
    
    .portada-container {
        max-width: 300px;
    }
    
    .flecha {
        width: 36px;
        height: 36px;
    }
    
    .flecha svg {
        width: 16px;
        height: 16px;
    }
    
    .flecha-arriba { top: -6px; }
    .flecha-abajo { bottom: -6px; }
    .flecha-izquierda { left: -6px; }
    .flecha-derecha { right: -6px; }
    
    #titulo {
        font-size: 18px;
    }
    
    .letra-container {
        max-height: 110px;
        padding: 10px 14px;
    }
    
    .letra-scroll {
        max-height: 85px;
    }
    
    #letra-texto {
        font-size: 14px;
        line-height: 1.65;
    }
    
    .btn-play-pause {
        width: 42px;
        height: 42px;
    }
    
    .btn-play-pause svg {
        width: 20px;
        height: 20px;
    }
}

/* --- ICONOS PLAY/PAUSA --- */
.btn-play-pause #icon-pause,
.btn-play-pause #icon-pause2 {
    display: none;
}

.btn-play-pause.reproduciendo #icon-play {
    display: none;
}

.btn-play-pause.reproduciendo #icon-pause,
.btn-play-pause.reproduciendo #icon-pause2 {
    display: block;
}

.btn-volumen.muted {
    color: #e94560;
}

/* --- TOASTS Y MENSAJES FLOTANTES --- */
.mensaje-limite,
.toast-error {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.mensaje-limite {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeInUp 0.3s ease;
}

.toast-error {
    background: rgba(233, 69, 96, 0.9);
}

.mensaje-limite.desvaneciendo,
.toast-error.desvaneciendo {
    opacity: 0;
    transition: opacity 0.5s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%);
    }
}

/* --- ESTADO DE ERROR EN CARGA --- */
.loading-error-titulo {
    color: #e94560;
    font-size: 18px;
}

.loading-error-texto {
    color: #666;
    font-size: 14px;
}

.btn-reload {
    margin-top: 16px;
    background: #e94560;
    color: #fff;
    border: none;
    padding: 10px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.lista-historial .mensaje-vacio.subtle {
    font-size: 12px;
    color: #444;
}

.lista-historial .mensaje-vacio.error {
    color: #e94560;
}

@media (max-height: 700px) {
    .portada-container {
        max-width: 220px;
    }
    
    .info-cancion {
        gap: 2px;
    }
    
    #titulo {
        font-size: 17px;
    }
    
    .meta-cancion {
        font-size: 11px;
    }
    
    .letra-container {
        max-height: 80px;
        padding: 8px 12px;
    }
    
    .letra-scroll {
        max-height: 60px;
    }
    
    #letra-texto {
        font-size: 13px;
        line-height: 1.55;
    }
    
    .controles {
        gap: 8px;
    }
}