:root {
    --primary-color: #fa4c0d;
    --bg-color: #111;
    --surface-color: #181818;
    --text-dim: #bbb;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    /* Ảnh nền + lớp phủ tối nhẹ để chữ vẫn rõ */
    background:
        linear-gradient(rgba(0,0,0,.2), rgba(0,0,0,.32)),
        url('../pic/backgroundmusic.webp') center center / cover no-repeat fixed,
        var(--bg-color);
    color: #fff;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

.player {
    max-width: 500px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 35px 15px 15px 15px;
    /* Kính mờ trong suốt để thấy ảnh nền xuyên qua */
    background: rgba(18, 18, 18, 0.32);
    backdrop-filter: blur(12px) saturate(1.15);
    -webkit-backdrop-filter: blur(12px) saturate(1.15);
    position: relative;
    overflow: hidden;
}

/* LOGO */
.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    flex-shrink: 0;
    height: 45px;
}
.logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* MEDIA INFO */
.media-info {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-shrink: 0;
    align-items: stretch;
}
.media-cover {
    position: relative;
    width: 120px;
    min-width: 120px;
    height: 120px;
    background: #000;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    overflow: hidden;
    flex-shrink: 0;
}
.media-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.media-cover:has(img[style*="display:none"]) {
    background: linear-gradient(135deg, #252525 0%, #181818 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.media-cover:has(img[style*="display:none"])::after {
    content: "🎵";
    font-size: 40px;
    opacity: 0.4;
}
.media-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 12px 16px;
    min-height: 120px;
}
.detail-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.detail-artist {
    font-size: 14px;
    color: var(--primary-color);
    font-weight: 600;
}
.detail-album {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
}

/* VISUALIZER LAYER - Nền + Controls chồng lên */
.visualizer-layer {
    position: relative;
    width: 100%;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 15px;
    flex-shrink: 0;
    background: #000;
    border: 1px solid #333;
}

/* Layer 1: Canvas visualizer */
.visualizer-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
}

/* Layer 2: Controls chồng lên canvas */
.player-controls {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* Hàng nút điều khiển */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Các nút điều khiển - dạng icon nổi */
.ctrl-btn {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
}
.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: scale(1.05);
}
.ctrl-btn:active {
    transform: scale(0.92);
}
.ctrl-btn svg {
    display: block;
}

/* Nút play to hơn */
.ctrl-play {
    width: 52px;
    height: 52px;
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(250, 76, 13, 0.4);
}
.ctrl-play:hover {
    background: #e55b2a;
    transform: scale(1.05);
}

/* Badge "1" cho repeat-one */
.ctrl-btn {
    position: relative;
}
.repeat-badge {
    display: none;
    position: absolute;
    top: 1px;
    right: 4px;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--primary-color);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    z-index: 2;
}
.repeat-badge.show {
    display: block;
}

/* Volume slider */
.volume-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
}
.vol-icon {
    color: rgba(255,255,255,0.8);
    flex-shrink: 0;
}
.vol-percent {
    font-size: 9px;
    color: rgba(255,255,255,0.5);
    min-width: 28px;
    text-align: right;
}
.volume-slider {
    width: 50px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
    height: 14px;
    margin: 0;
    padding: 0;
    --track-fill: 80%;
}
.volume-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color) var(--track-fill), rgba(255,255,255,0.2) var(--track-fill));
    border-radius: 2px;
    cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.15s ease;
    margin-top: -4px;
    position: relative;
}
.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
.volume-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    border: none;
    cursor: pointer;
}
.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.volume-slider::-ms-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border-color: transparent;
    color: transparent;
    cursor: pointer;
}
.volume-slider::-ms-fill-lower {
    background: var(--primary-color);
    border-radius: 2px;
}
.volume-slider::-ms-fill-upper {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}
.volume-slider::-ms-thumb {
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.volume-slider:focus {
    outline: none;
}

/* Responsive: thu nhỏ volume trên mobile */
@media (max-width: 480px) {
    .volume-slider {
        width: 36px;
    }
    .volume-wrap {
        gap: 4px;
        margin-left: 4px;
    }
    .vol-percent {
        min-width: 22px;
        font-size: 8px;
    }
    .vol-icon {
        width: 12px;
        height: 12px;
    }
}

/* Active state cho shuffle & repeat */
.ctrl-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(250, 76, 13, 0.3);
}

/* Progress row */
.progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 90%;
    max-width: 400px;
}
.time {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
    min-width: 40px;
    text-align: center;
    font-weight: 500;
}
.progress {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.1s linear;
}

/* SEARCH */
input#search {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 15px;
    border-radius: 25px;
    border: 1px solid #333;
    background: #222;
    color: #fff;
    margin-bottom: 15px;
    outline: none;
    flex-shrink: 0;
}
input#search:focus { border-color: var(--primary-color); }

/* PLAYLIST */
#playlist {
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) #222;
}
#playlist::-webkit-scrollbar { width: 4px; }
#playlist::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 10px; }

.song {
    padding: 12px;
    border-bottom: 1px solid #252525;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}
.song-thumb {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}
.song-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.song-info strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}
.song-info small {
    color: var(--text-dim);
    font-size: 12px;
}
.song:hover { background: rgba(255,255,255,0.05); }
.song.active {
    background: rgba(250, 76, 13, 0.15);
    border-left: 4px solid var(--primary-color);
}

/* FOOTER */
.player-footer {
    flex-shrink: 0;
    padding: 10px;
    text-align: center;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.player-footer strong {
    color: var(--primary-color);
    font-weight: 700;
}
