/* Reset y estilos base */
audio {
    display: none;
    visibility: hidden;
}

/* Contenedor principal */
.premium-player {
    position: relative;
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    transition: all 0.3s ease;
}

.premium-player.playlist-mode {
    max-width: 700px;
}

.premium-player:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Forma de onda */
.waveform-container,
[id^="waveform-"] {
    width: 100%;
    height: 80px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* Lista de reproducción */
.playlist-container {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 20px;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.playlist-count {
    color: #666;
    font-weight: normal;
}

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

.playlist-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.playlist-item:last-child {
    border-bottom: none;
}

.playlist-item:hover {
    background: #f8f8f8;
}

.playlist-item.active {
    background: #000;
    color: #fff;
}

.playlist-item.active:hover {
    background: #222;
}

.playlist-item.playing .track-playing-icon {
    display: block !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.track-status {
    width: 20px;
    position: relative;
}

.track-number {
    min-width: 25px;
    font-size: 13px;
    opacity: 0.7;
}

.track-name {
    flex: 1;
    padding: 0 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.track-duration {
    font-size: 13px;
    opacity: 0.7;
    min-width: 45px;
    text-align: right;
}

/* Controles del reproductor */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: nowrap;
}

.main-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.secondary-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Botones */
.control-btn,
.play-btn {
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    outline: none;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.play-btn {
    background-color: #000 !important;
    color: #fff;
    width: 50px;
    height: 50px;
    min-width: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.play-btn:hover {
    background-color: #333 !important;
    transform: scale(1.05);
}

.play-btn:active {
    transform: scale(0.95);
    background-color: #000 !important;
}

/* Asegurar que los SVG dentro del botón sean blancos */
.play-btn svg {
    fill: #fff !important;
    color: #fff !important;
}

.control-btn {
    padding: 8px;
    color: #666;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
}

.control-btn.active {
    color: #000;
    background: rgba(0, 0, 0, 0.1);
}

/* Focus para accesibilidad */
.control-btn:focus,
.play-btn:focus,
button:focus {
    outline: 2px solid #00000000;
    outline-offset: 2px;
}

/* Información de pista */
.track-info {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0 10px;
    overflow: hidden;
}

.track-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-counter {
    font-size: 12px;
    color: #666;
}

/* Control de velocidad */
.speed-control {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.speed-control:hover {
    border-color: #999;
}

.speed-control:focus {
    border-color: #00000000;
}

/* Control de volumen */
.volume-container {
    position: relative;
    display: flex;
    align-items: center;
}

.volume-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.volume-btn:hover {
    color: #000;
}

.volume-btn svg {
    width: 24px;
    height: 24px;
    display: block;
}

.volume-slider-wrapper {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

.volume-container:hover .volume-slider-wrapper {
    opacity: 1;
    visibility: visible;
}

.volume-slider {
    -webkit-appearance: none;
    width: 100px;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #000;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Tiempo */
.time-info {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Controles extra */
.extra-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Mensaje de error */
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px 15px;
    border-radius: 6px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.error-message svg {
    width: 20px;
    height: 20px;
}

/* Estados de carga */
.loading {
    color: #666;
    font-style: italic;
}

/* Marca de agua */
.watermark {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 11px;
    color: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    font-family: Arial, sans-serif;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.premium-player:hover .watermark {
    opacity: 0.3;
}

/* Scrollbar personalizado */
.playlist-container::-webkit-scrollbar {
    width: 8px;
}

.playlist-container::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.playlist-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.playlist-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ====================== */
/* RESPONSIVE MÓVIL */
/* ====================== */

/* Fix específico para el botón de play en móvil */
@media (max-width: 768px) {
    .play-btn {
        background-color: #000 !important;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .play-btn:active,
    .play-btn:focus {
        background-color: #000 !important;
        outline: none;
    }
}

/* Fix para iOS Safari */
@supports (-webkit-touch-callout: none) {
    .play-btn {
        background-color: #000 !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    .play-btn:active {
        background-color: #000 !important;
    }
}

/* Eliminar cualquier estilo de hover en dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .play-btn:hover {
        transform: none;
        background-color: #000 !important;
    }
    
    .play-btn:active {
        transform: scale(0.95);
        background-color: #000 !important;
    }
}

@media (max-width: 768px) {
    .premium-player {
        padding: 15px;
        margin: 15px auto;
        border-radius: 10px;
    }
    
    /* Waveform en móvil - altura fija */
    .waveform-container,
    [id^="waveform-"] {
        height: 60px;
        margin-bottom: 15px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Evitar que el waveform se corte */
    [id^="waveform-"] > div {
        width: 100% !important;
        overflow: hidden !important;
    }
    
    /* Canvas del waveform */
    [id^="waveform-"] canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
    }
    
    /* Reorganizar controles */
    .player-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    /* Info de pista arriba */
    .track-info {
        order: -1;
        width: 100%;
        margin-bottom: 10px;
        padding: 0;
    }
    
    .track-title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 5px;
    }
    
    /* Controles principales */
    .main-controls {
        order: 0;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    /* Controles secundarios */
    .secondary-controls {
        order: 1;
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
        padding-top: 15px;
        border-top: 1px solid #e0e0e0;
    }
    
    /* Botón de play más grande */
    .play-btn {
        width: 60px;
        height: 60px;
        background-color: #000 !important;
    }
    
    .play-btn svg {
        width: 28px;
        height: 28px;
        fill: #fff !important;
    }
    
    /* Botones de control */
    .control-btn {
        width: 44px;
        height: 44px;
    }
    
    .control-btn svg {
        width: 24px;
        height: 24px;
    }
    
    /* Ocultar control de velocidad en móvil */
    .speed-control {
        display: none;
    }
    
    /* Tiempo */
    .time-info {
        font-size: 14px;
        font-weight: 500;
    }
    
    /* Control de volumen simplificado */
    .volume-container {
        position: static;
    }
    
    .volume-slider-wrapper {
        display: none !important;
    }
    
    .volume-btn {
        width: 36px;
        height: 36px;
    }
    
    .volume-btn svg {
        width: 24px;
        height: 24px;
    }
    
    /* Controles extra en móvil */
    .extra-controls {
        gap: 5px;
    }
    
    /* Lista de reproducción móvil */
    .playlist-container {
        max-height: 200px;
        margin-bottom: 15px;
    }
    
    .playlist-item {
        padding: 10px 12px;
    }
    
    .track-name {
        font-size: 14px;
        padding: 0 10px;
    }
    
    .track-duration {
        font-size: 12px;
    }
    
    /* Marca de agua */
    .watermark {
        font-size: 10px;
        bottom: 5px;
        right: 8px;
    }
}

/* Móviles muy pequeños */
@media (max-width: 480px) {
    .premium-player {
        padding: 12px;
        margin: 10px auto;
    }
    
    .waveform-container,
    [id^="waveform-"] {
        height: 50px;
    }
    
    /* Ajustes para controles */
    .main-controls {
        gap: 8px;
    }
    
    .play-btn {
        width: 50px;
        height: 50px;
    }
    
    .play-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .control-btn svg {
        width: 20px;
        height: 20px;
    }
    
    /* Ocultar botones menos importantes */
    .shuffle-btn,
    .repeat-btn,
    .download-btn {
        display: none;
    }
    
    /* Título más pequeño */
    .track-title {
        font-size: 16px;
    }
    
    /* Simplificar controles secundarios */
    .secondary-controls {
        justify-content: center;
        gap: 20px;
    }
    
    .time-info {
        font-size: 12px;
    }
}

/* Modo landscape móvil */
@media (max-width: 768px) and (orientation: landscape) {
    .premium-player {
        padding: 10px 15px;
    }
    
    .waveform-container,
    [id^="waveform-"] {
        height: 40px;
        margin-bottom: 10px;
    }
    
    .player-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .track-info {
        order: -1;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .main-controls {
        order: 0;
        margin-bottom: 0;
    }
    
    .secondary-controls {
        order: 1;
        flex: 1;
        border-top: none;
        padding-top: 0;
        justify-content: flex-end;
    }
    
    .play-btn {
        width: 45px;
        height: 45px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
}

/* Ajustes para iOS */
@supports (-webkit-touch-callout: none) {
    .waveform-container {
        -webkit-tap-highlight-color: transparent;
    }
    
    .control-btn,
    .play-btn {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Estados hover deshabilitados en móvil */
@media (hover: none) {
    .control-btn:hover {
        transform: none;
        background-color: initial;
    }
    
    .volume-container:hover .volume-slider-wrapper {
        opacity: 0;
        visibility: hidden;
    }
}

/* Animaciones suaves */
@media (prefers-reduced-motion: no-preference) {
    .track-title {
        transition: opacity 0.3s ease;
    }
}

/* Fix para evitar texto que se corta */
.track-title span {
    display: block;
    width: 100%;
}

/* Asegurar que los SVG se vean bien */
.premium-player svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Prevenir zoom en inputs en iOS */
@media (max-width: 768px) {
    input[type="range"],
    select {
        font-size: 16px;
    }
}