/* ================================================================
   Shipo — Pestaña "Música" (agregador YouTube + Jamendo)
   Mantiene la paleta y el lenguaje visual existentes de Shipo.
   ================================================================ */

#music_page {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: #0d0f14;
    overflow: hidden;
}

.music_root {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #0d0f14;
    color: #c8d6e5;
    overflow: hidden;
}

/* ------------------------------ Cabecera ------------------------------ */

.music_header {
    flex-shrink: 0;
    padding: 12px 16px 6px;
    border-bottom: 1px solid #1e2330;
    background: #13161d;
}

.music_header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
}

.music_header h2 i {
    color: #4db8e8;
    margin-right: 6px;
}

.music_sub {
    font-size: 0.78rem;
    color: rgba(200, 214, 229, 0.55);
}

/* ------------------------------ Toolbar ------------------------------ */

.music_toolbar {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #13161d;
    border-bottom: 1px solid #1e2330;
}

.music_search {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
}

.music_search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(200, 214, 229, 0.45);
    font-size: 0.9rem;
    pointer-events: none;
}

.music_search input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px 9px 32px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #c8d6e5;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.music_search input::placeholder {
    color: rgba(200, 214, 229, 0.36);
}

.music_search input:focus {
    border-color: rgba(0, 100, 160, 0.65);
    box-shadow: 0 0 0 2px rgba(0, 100, 160, 0.2);
}

.music_search_btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: rgb(0, 96, 138);
    border: 1px solid rgb(0, 96, 138);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.15s;
    white-space: nowrap;
}

.music_search_btn:hover {
    background: rgb(0, 120, 170);
}

/* ------------------------------ Filtros ------------------------------ */

.music_filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.music_filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: #c8d6e5;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.music_filter:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}

.music_filter.active {
    background: rgb(0, 96, 138);
    border-color: rgb(0, 96, 138);
    color: #ffffff;
}

.music_filter_count {
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 1px 7px;
    color: rgba(200, 214, 229, 0.8);
}

.music_filter.active .music_filter_count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

/* ------------------------------ Meta / estado ------------------------------ */

.music_meta {
    flex-shrink: 0;
    padding: 6px 16px;
    font-size: 0.78rem;
    color: rgba(200, 214, 229, 0.55);
    background: #13161d;
    border-bottom: 1px solid #1e2330;
}

.music_meta:empty {
    display: none;
}

.music_status {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
    color: rgba(200, 214, 229, 0.65);
    overflow-y: auto;
}

.music_status:empty {
    display: none;
}

.music_status i {
    font-size: 2rem;
    color: rgba(200, 214, 229, 0.35);
}

.music_status p {
    margin: 0;
    font-size: 0.92rem;
    max-width: 460px;
}

.music_status .music_status_provider {
    font-size: 0.78rem;
    color: rgba(200, 214, 229, 0.45);
    max-width: 460px;
    margin-top: 4px;
}

.music_spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: #4db8e8;
    border-radius: 50%;
    animation: musicSpin 0.8s linear infinite;
}

@keyframes musicSpin {
    to { transform: rotate(360deg); }
}

.music_retry {
    padding: 8px 16px;
    background: rgb(0, 96, 138);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.music_retry:hover {
    background: rgb(0, 120, 170);
}

/* ------------------------------ Resultados ------------------------------ */

.music_grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
}

/* Con el reproductor visible, deja espacio para que la barra fija
   no tape los últimos resultados de la lista. */
body.shipo-music-open .music_grid {
    padding-bottom: 88px;
}

/* Colapsado: el header es más fino, se reserva menos espacio. */
body.shipo-music-open.shipo-music-collapsed .music_grid {
    padding-bottom: 40px;
}

.music_row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: #13161d;
    border: 1px solid #1e2330;
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.music_row:hover {
    border-color: rgba(77, 184, 232, 0.55);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.music_row_art {
    position: relative;
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: #0b0e13;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(200, 214, 229, 0.35);
}

.music_row_art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.music_row_info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.music_row_title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music_row_artist {
    font-size: 0.78rem;
    color: rgba(200, 214, 229, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music_row_meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.music_badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(200, 214, 229, 0.75);
}

.music_badge.youtube {
    background: rgba(255, 0, 0, 0.18);
    color: #ff8a80;
}

.music_badge.jamendo {
    background: rgba(0, 150, 90, 0.18);
    color: #48e6a0;
}

.music_row_dur {
    font-size: 0.72rem;
    color: rgba(200, 214, 229, 0.5);
}

.music_row_actions {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.music_row_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #c8d6e5;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, transform 0.1s;
}

.music_row_btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.music_row_btn:active {
    transform: scale(0.94);
}

.music_row_btn.play {
    background: rgb(0, 96, 138);
    color: #ffffff;
}

.music_row_btn.play:hover {
    background: rgb(0, 120, 170);
}

.music_row_btn.fav.active {
    color: #f9c74f;
    background: rgba(249, 199, 79, 0.16);
}

.music_row_btn.remove:hover {
    background: rgba(224, 73, 73, 0.22);
    color: #ff7b7b;
}

/* ================================================================
   Reproductor global persistente (fijo al viewport, vive fuera
   de #music_page para seguir disponible al navegar por Shipo)
   ================================================================ */

#shipo_music_player {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    background: #13161d;
    border-top: 1px solid #1e2330;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.5);
}

#shipo_music_player[hidden] {
    display: none;
}

.mp_head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 10px;
    border-bottom: 1px solid #1e2330;
    background: #0b0e13;
}

.mp_head_title {
    flex: 1;
    min-width: 0;
    font-size: 0.74rem;
    font-weight: 600;
    color: rgba(200, 214, 229, 0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp_head_btn {
    flex: none;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #c8d6e5;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mp_head_btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* Colapsado: solo queda el header (chevron para reexpandir). */
#shipo_music_player.shipo-music-collapsed .mp_bar,
#shipo_music_player.shipo-music-collapsed #shipo_music_yt,
#shipo_music_player.shipo-music-collapsed #shipo_music_queue {
    display: none;
}

.mp_bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    flex-wrap: wrap;
}

.mp_art {
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #0b0e13;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(200, 214, 229, 0.35);
    cursor: pointer;
    position: relative;
}

.mp_art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mp_art.youtube::after {
    content: "\f167"; /* fa-youtube */
    font-family: "Font Awesome 6 Brands";
    font-weight: 400;
    position: absolute;
    right: 3px;
    bottom: 3px;
    font-size: 0.72rem;
    color: #fff;
    background: rgba(255, 0, 0, 0.85);
    border-radius: 4px;
    padding: 1px 4px;
    line-height: 1.2;
}

.mp_info {
    flex: 1 1 120px;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.mp_title {
    font-size: 0.86rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp_artist {
    font-size: 0.74rem;
    color: rgba(200, 214, 229, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp_artist a {
    color: #4db8e8;
    text-decoration: none;
}

.mp_artist a:hover {
    text-decoration: underline;
}

.mp_progress {
    flex: 1 1 220px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mp_progress input[type="range"] {
    width: 100%;
    height: 4px;
    accent-color: #4db8e8;
    cursor: pointer;
}

.mp_times {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: rgba(200, 214, 229, 0.55);
}

.mp_controls {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mp_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #c8d6e5;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.mp_btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.mp_btn.play {
    width: 42px;
    height: 42px;
    background: rgb(0, 96, 138);
    color: #ffffff;
    font-size: 1rem;
}

.mp_btn.play:hover {
    background: rgb(0, 120, 170);
}

.mp_volume {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mp_volume input[type="range"] {
    width: 80px;
    accent-color: #4db8e8;
    cursor: pointer;
}

/* Panel de video de YouTube (flota sobre la barra) */
#shipo_music_yt {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 16px;
    width: 320px;
    height: 180px;
    background: #000;
    border: 1px solid #1e2330;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

#shipo_music_yt[hidden] {
    display: none;
}

#shipo_music_yt_target {
    width: 100%;
    height: 100%;
}

/* ------------------------------ Tema claro ------------------------------ */

html[data-theme="light"] #music_page,
html[data-theme="light"] .music_root {
    background: #f5f7fa;
    color: #1a2d42;
}

html[data-theme="light"] .music_header,
html[data-theme="light"] .music_toolbar,
html[data-theme="light"] .music_meta {
    background: #ffffff;
    border-bottom-color: #d0d8e4;
}

html[data-theme="light"] .music_header h2 {
    color: #1a2d42;
}

html[data-theme="light"] .music_header h2 i {
    color: #1565c0;
}

html[data-theme="light"] .music_sub {
    color: rgba(26, 45, 66, 0.55);
}

html[data-theme="light"] .music_search i {
    color: rgba(26, 45, 66, 0.45);
}

html[data-theme="light"] .music_search input {
    background: #ffffff;
    border-color: #d0d8e4;
    color: #1a2d42;
}

html[data-theme="light"] .music_search input::placeholder {
    color: rgba(26, 45, 66, 0.36);
}

html[data-theme="light"] .music_search input:focus {
    border-color: #1565c0;
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.2);
}

html[data-theme="light"] .music_search_btn {
    background: #1565c0;
    border-color: #1565c0;
}

html[data-theme="light"] .music_search_btn:hover {
    background: #0d47a1;
}

html[data-theme="light"] .music_filter {
    background: #ffffff;
    border-color: #d0d8e4;
    color: #1a2d42;
}

html[data-theme="light"] .music_filter:hover {
    background: #eef2f7;
    color: #0d1b2a;
}

html[data-theme="light"] .music_filter.active {
    background: #1565c0;
    border-color: #1565c0;
    color: #ffffff;
}

html[data-theme="light"] .music_filter_count {
    background: rgba(26, 45, 66, 0.08);
    color: rgba(26, 45, 66, 0.8);
}

html[data-theme="light"] .music_filter.active .music_filter_count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

html[data-theme="light"] .music_status {
    color: rgba(26, 45, 66, 0.65);
}

html[data-theme="light"] .music_status i {
    color: rgba(26, 45, 66, 0.35);
}

html[data-theme="light"] .music_status .music_status_provider {
    color: rgba(26, 45, 66, 0.45);
}

html[data-theme="light"] .music_spinner {
    border-color: rgba(26, 45, 66, 0.14);
    border-top-color: #1565c0;
}

html[data-theme="light"] .music_retry {
    background: #1565c0;
}

html[data-theme="light"] .music_retry:hover {
    background: #0d47a1;
}

html[data-theme="light"] .music_row {
    background: #ffffff;
    border-color: #d0d8e4;
}

html[data-theme="light"] .music_row:hover {
    border-color: #1565c0;
    box-shadow: 0 4px 14px rgba(26, 45, 66, 0.12);
}

html[data-theme="light"] .music_row_art {
    background: #e8ecf0;
    color: rgba(26, 45, 66, 0.35);
}

html[data-theme="light"] .music_row_title {
    color: #1a2d42;
}

html[data-theme="light"] .music_row_artist {
    color: rgba(26, 45, 66, 0.75);
}

html[data-theme="light"] .music_badge {
    background: rgba(26, 45, 66, 0.08);
    color: rgba(26, 45, 66, 0.75);
}

html[data-theme="light"] .music_row_dur {
    color: rgba(26, 45, 66, 0.5);
}

html[data-theme="light"] .music_row_btn {
    background: rgba(26, 45, 66, 0.08);
    color: #1a2d42;
}

html[data-theme="light"] .music_row_btn:hover {
    background: rgba(26, 45, 66, 0.14);
    color: #0d1b2a;
}

html[data-theme="light"] .music_row_btn.play {
    background: #1565c0;
    color: #ffffff;
}

html[data-theme="light"] .music_row_btn.play:hover {
    background: #0d47a1;
}

html[data-theme="light"] #shipo_music_player {
    background: #ffffff;
    border-top-color: #d0d8e4;
    box-shadow: 0 -6px 24px rgba(26, 45, 66, 0.12);
}

html[data-theme="light"] .mp_art {
    background: #e8ecf0;
    color: rgba(26, 45, 66, 0.35);
}

html[data-theme="light"] .mp_title {
    color: #1a2d42;
}

html[data-theme="light"] .mp_artist {
    color: rgba(26, 45, 66, 0.65);
}

html[data-theme="light"] .mp_artist a {
    color: #1565c0;
}

html[data-theme="light"] .mp_head {
    background: #eef2f6;
    border-bottom-color: #d0d8e4;
}

html[data-theme="light"] .mp_head_title {
    color: rgba(26, 45, 66, 0.7);
}

html[data-theme="light"] .mp_head_btn {
    color: #1a2d42;
}

html[data-theme="light"] .mp_head_btn:hover {
    background: rgba(26, 45, 66, 0.12);
    color: #0d1b2a;
}

html[data-theme="light"] .mp_times {
    color: rgba(26, 45, 66, 0.55);
}

html[data-theme="light"] .mp_btn {
    color: #1a2d42;
}

html[data-theme="light"] .mp_btn:hover {
    background: rgba(26, 45, 66, 0.12);
    color: #0d1b2a;
}

html[data-theme="light"] .mp_btn.play {
    background: #1565c0;
    color: #ffffff;
}

html[data-theme="light"] .mp_btn.play:hover {
    background: #0d47a1;
}

#shipo_music_yt_target iframe {
    display: block;
}

.mp_yt_close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.78rem;
    cursor: pointer;
    line-height: 1;
}

.mp_yt_close:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Panel de cola (flota sobre la barra) */
#shipo_music_queue {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 16px;
    width: 340px;
    max-height: 42vh;
    display: flex;
    flex-direction: column;
    background: #13161d;
    border: 1px solid #1e2330;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

#shipo_music_queue[hidden] {
    display: none;
}

.mp_queue_head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #1e2330;
    font-size: 0.86rem;
    font-weight: 600;
    color: #ffffff;
}

.mp_queue_head button {
    border: none;
    background: transparent;
    color: #4db8e8;
    font-size: 0.78rem;
    cursor: pointer;
}

.mp_queue_head button:hover {
    text-decoration: underline;
}

.mp_queue_list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mp_queue_item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
}

.mp_queue_item.current {
    background: rgba(0, 96, 138, 0.22);
}

.mp_queue_item .qtitle {
    flex: 1;
    min-width: 0;
    color: #c8d6e5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp_queue_item.current .qtitle {
    color: #ffffff;
    font-weight: 600;
}

.mp_queue_item .qartist {
    font-size: 0.7rem;
    color: rgba(200, 214, 229, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp_queue_item button {
    flex: none;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #c8d6e5;
    font-size: 0.75rem;
    cursor: pointer;
}

.mp_queue_item button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.mp_queue_item button.rm:hover {
    background: rgba(224, 73, 73, 0.22);
    color: #ff7b7b;
}

.mp_queue_empty {
    padding: 14px;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(200, 214, 229, 0.5);
}

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 863px) {
    .music_toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .music_search {
        flex: 1 1 auto;
        min-width: 0;
    }
    .music_grid {
        padding: 10px 10px 18px;
    }
}

@media (max-width: 640px) {
    #music_page {
        top: 36px;
    }
    /* Reproductor de música anclado al bottom del viewport.
       La nav inferior móvil vive dentro de #ct, que se oculta al abrir
       la pestaña de música, así que no debe reservarse espacio debajo. */
    #shipo_music_player {
        bottom: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .music_header h2 {
        font-size: 1rem;
    }
    .music_grid {
        gap: 6px;
        padding: 8px 8px 16px;
    }
    .music_row {
        gap: 8px;
        padding: 7px 8px;
    }
    .music_row_art {
        width: 48px;
        height: 48px;
    }
    .music_row_title {
        font-size: 0.85rem;
    }
    .music_row_actions {
        gap: 3px;
    }
    .music_row_btn {
        width: 32px;
        height: 32px;
    }
    /* En móvil el seek ocupa todo el ancho */
    .mp_progress {
        order: 5;
        flex-basis: 100%;
    }
    body.shipo-music-open .music_grid {
        padding-bottom: 170px;
    }
    body.shipo-music-open.shipo-music-collapsed .music_grid {
        padding-bottom: 44px;
    }
    .mp_volume input[type="range"] {
        width: 56px;
    }
    #shipo_music_yt {
        right: 8px;
        width: calc(100% - 16px);
        height: 180px;
    }
    #shipo_music_queue {
        right: 8px;
        width: calc(100% - 16px);
    }
}
