/* style.css - Diseño Científico / Hemi-Sync */

:root {
    --bg-dark: #0a0b10;
    --bg-panel: #14161f;
    --accent: #00d4ff; /* Cyan Hemi-Sync */
    --accent-dim: #007acc;
    --text-main: #e0e0e0;
    --text-dim: #888;
    --border: #2a2d3a;
    --wave-alpha: #4caf50;
    --wave-theta: #9c27b0;
    --wave-delta: #3f51b5;
    --wave-beta: #ff9800;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    /* Margen de seguridad para TVs (Overscan) */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* SIDEBAR - FILTERS */
.sidebar {
    width: 320px;
    min-width: 280px; /* Evitar que se colapse en pantallas grandes escaladas */
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    transition: left 0.3s ease;
    z-index: 200;
}

.brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
}

select, input[type="text"] {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px;
    border-radius: 4px;
    outline: none;
}

select:focus, input:focus {
    border-color: var(--accent);
}

.stats {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-dim);
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* MAIN CONTENT */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%; /* Ensure full width on mobile */
}

.header-info {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(20, 22, 31, 0.8);
    backdrop-filter: blur(5px);
}

.track-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.track-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.track-item:hover {
    background: rgba(0, 212, 255, 0.05);
}

.track-item.active {
    background: rgba(0, 212, 255, 0.1);
    border-left: 3px solid var(--accent);
}

.track-icon {
    width: 30px;
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-right: 15px;
    flex-shrink: 0; /* Prevent shrinking */
}

.track-info {
    flex: 1;
    min-width: 0; /* Enable text truncation in flex items */
}

.track-title {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    gap: 15px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.tag {
    padding: 2px 6px;
    border-radius: 3px;
    background: #333;
    color: #fff;
    font-size: 0.7rem;
    white-space: nowrap;
}

.tag.alpha { background: var(--wave-alpha); }
.tag.theta { background: var(--wave-theta); }
.tag.delta { background: var(--wave-delta); }
.tag.beta { background: var(--wave-beta); }

/* PLAYER BAR */
.player-bar {
    height: 90px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 30px;
    gap: 20px;
    z-index: 100;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.btn-control {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.btn-control:hover { color: var(--accent); }
.btn-play { font-size: 2rem; }

.now-playing {
    width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-title { font-weight: bold; font-size: 0.9rem; margin-bottom: 3px; }
.now-playing-artist { font-size: 0.75rem; color: var(--text-dim); }

.progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.time { font-size: 0.75rem; color: var(--text-dim); width: 45px; text-align: center; }

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    background: var(--border);
    height: 4px;
    border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

/* Favoritos */
.btn-fav {
    color: #666;
    transition: all 0.2s ease;
}
.btn-fav.active {
    color: #e74c3c; /* Rojo corazón */
    transform: scale(1.1);
}
.track-fav-icon {
    margin-right: 8px;
    cursor: pointer;
    color: #444;
}
.track-fav-icon.active {
    color: #e74c3c;
}

.btn-toggle {
    width: 100%;
    padding: 10px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}
.btn-toggle:hover {
    background: #333;
}
.btn-toggle.active {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

/* Scrollbar para la lista */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10,11,16,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 999;
}

.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Volume Control */
.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 15px;
}

#volume-bar {
    width: 80px;
    accent-color: var(--accent); /* Para navegadores modernos */
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    #menu-toggle {
        display: block !important; /* Mostrar botón hamburguesa */
        background: rgba(255,255,255,0.1);
        border-radius: 4px;
        padding: 5px 10px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -100%; /* Ocultar moviendo fuera */
        width: 85%; /* Ancho relativo seguro */
        max-width: 320px;
        min-width: 250px; /* Evitar que sea muy estrecho */
        background-color: var(--bg-panel); /* Asegurar fondo opaco */
        transform: none; /* Quitar transform */
        box-shadow: 5px 0 20px rgba(0,0,0,0.8); /* Sombra fuerte */
        border-right: 1px solid var(--accent); /* Borde visible */
        z-index: 9999; 
        transition: left 0.3s ease; /* Transición de posición */
        display: flex; /* Asegurar flex para contenido interno */
    }

    .sidebar.open {
        left: 0; /* Mostrar pegado a la izquierda */
        transform: none;
    }

    /* Header adjustments */
    .header-info {
        padding: 15px;
        flex-wrap: wrap; /* Permitir que baje si no cabe */
    }

    .header-info h2 {
        font-size: 1.2rem;
    }

    .player-bar {
        height: auto;
        padding: 15px;
        flex-direction: column;
        gap: 15px;
        background: var(--bg-panel);
        border-top: 1px solid var(--border);
        position: fixed; /* Fijar abajo */
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100; /* Por encima de la lista */
    }

    /* Espacio extra al final de la lista para que el player no tape la última canción */
    .track-list {
        padding-bottom: 160px; 
    }

    .progress-container {
        width: 100%;
        order: 1; 
        margin-bottom: 5px;
    }
    
    .now-playing {
        width: 100%;
        text-align: center;
        order: 2; 
        margin-bottom: 5px;
    }
    
    .player-controls {
        order: 3; 
        width: 100%;
        display: flex; /* Asegurar flex */
        justify-content: center; /* Centrar controles principales */
        align-items: center;
        gap: 15px;
        padding-bottom: 5px; /* Margen para tocar */
    }

    .volume-container {
        order: 4;
        width: 100%;
        justify-content: center;
        margin-right: 0;
        padding-bottom: 15px; /* Espacio extra abajo */
    }

    .btn-control {
        font-size: 1.5rem; /* Botones más grandes */
        padding: 10px; /* Área táctil mayor */
        color: var(--text-main); /* Color brillante */
    }

    .btn-play {
        font-size: 2.5rem; /* Play muy grande */
        color: var(--accent);
    }
}

    /* Ajustar panel de descripción para que no ocupe tanto */
    #description-panel {
        margin: 10px;
        padding: 10px;
        font-size: 0.9rem;
    }
    
    /* Overlay para cuando el menú está abierto */
    #sidebar-overlay.active {
        display: block !important;
        backdrop-filter: blur(2px);
    }
}