/* === Player Container === */
#music-player-ui {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 400px !important;
    max-width: calc(100vw - 40px) !important;
    background: #282828 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 9999 !important;
    transform: translateY(100%) !important;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    will-change: transform !important;
}

#music-player-ui.show {
    transform: translateY(0) !important;
}

/* === Player Controls === */
.control-button {
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    padding: 8px !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    transform: scale(1.1) !important;
}

.control-button:active {
    transform: scale(0.95) !important;
}

/* === Volume Control === */
.player-volume-control {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 100px !important;
    max-width: 150px !important;
}

.player-volume-slider {
    -webkit-appearance: none !important;
    width: 100% !important;
    height: 4px !important;
    border-radius: 2px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    outline: none !important;
    transition: all 0.2s ease !important;
}

.player-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    background: #fff !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.player-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2) !important;
}

/* === Progress Bar === */
.player-progress-container {
    position: relative;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    overflow: hidden;
}

.player-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.player-progress-bar:hover {
    height: 6px;
    transition: height 0.15s ease-out;
}

.player-progress-value {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    height: 100% !important;
    background: #ff0000 !important;
    border-radius: 2px !important;
    transition: width 0.05s linear !important;
    will-change: width !important;
}

/* === Platform Specific Styles === */
.youtube-theme .player-progress-value {
    background: #ff0000 !important;
}

.spotify-theme .player-progress-value {
    background: #1DB954 !important;
}

.soundcloud-theme .player-progress-value {
    background: #ff7700 !important;
}

/* === Playlist Container === */
.playlist-container {
    max-height: 300px !important;
    overflow-y: auto !important;
    background: rgba(25, 25, 25, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.playlist-track {
    display: flex !important;
    align-items: center !important;
    padding: 10px 15px !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
}

.playlist-track:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

.playlist-track.active {
    background: rgba(255, 255, 255, 0.15) !important;
    border-left: 3px solid #ff0000 !important;
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* === Responsive Design === */
@media (max-width: 768px) {
    #music-player-ui {
        width: 90% !important;
        left: 5% !important;
        right: 5% !important;
    }

    .player-controls-bar {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
    }

    .player-volume-control {
        min-width: 80px !important;
    }
}

/* === Player Iframe Container === */
#player-iframe-container {
    position: relative !important;
    width: 100% !important;
    padding-top: 56.25% !important;
    background: #000 !important;
    border-radius: 12px 12px 0 0 !important;
}

.iframe-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* === Fix YouTube UI Issues === */
.ytp-pause-overlay,
.ytp-playlist-menu-button,
.ytp-playlist-container,
.ytp-related-videos-card {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Player info section */
.player-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    box-sizing: border-box;
}

#player-title {
    font-size: 16px;
    color: #fff;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

#player-source {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Player controls section */
.player-controls {
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.player-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

/* Progress bar container */
.player-progress-container {
    position: relative !important;
    width: 100% !important;
    padding: 10px 15px;
    box-sizing: border-box;
}

/* Volume control */
.player-volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    max-width: 150px;
}

.player-volume-slider {
    width: 100%;
    height: 4px;
}

/* Playlist container */
.playlist-container {
    max-height: 200px !important;
    overflow-y: auto !important;
    position: relative !important;
    padding: 10px 15px;
    box-sizing: border-box;
    background: rgba(25, 25, 25, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    z-index: 9999 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #music-player-ui {
        width: 90% !important;
        left: 5% !important;
        right: 5% !important;
    }
}

/* Thêm scrollbar styles cho playlist */
.playlist-container::-webkit-scrollbar {
    width: 6px;
}

.playlist-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.playlist-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Hiệu ứng hover cho các nút */
.player-controls button {
    transition: transform 0.2s ease;
}

.player-controls button:hover {
    transform: scale(1.1);
}

/* Thêm animation cho player khi hiển thị/ẩn */
#music-player-ui {
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
}

#music-player-ui.show {
    transform: translateY(0);
}

/* Chế độ thu gọn */
#music-player-ui.minimized {
    height: 80px;
    overflow: hidden;
}

#music-player-ui.minimized .player-info {
    padding: 8px 15px;
}

#player-iframe-container {
    max-height: 250px !important;
    position: relative !important;
    overflow: hidden !important;
    width: 100%;
    padding-top: 56.25%; /* Tỷ lệ 16:9 */
    min-height: 240px;
    background: #000;
    border-radius: 12px;
}

.iframe-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.iframe-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Điều chỉnh kích thước player tùy theo chế độ */
.single-track-mode #player-iframe-container {
    min-height: 300px;
}

.playlist-mode #player-iframe-container {
    min-height: 240px;
}

/* CSS cho thanh progress bar kiểu YouTube */
.player-progress-bar:hover {
    height: 6px;
}

/* Phần đã tải của video */
.player-progress-loaded {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
    width: 0;
    z-index: 1;
    transition: width 0.3s linear;
}

/* Hiển thị thời gian */
.player-time-display {
    display: flex;
    justify-content: flex-end;
    font-size: 12px;
    color: #aaa;
    margin-right: 5px;
}

/* Tooltip khi hover trên thanh tiến trình */
.progress-preview-time {
    position: absolute;
    top: -30px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 50;
}

.progress-preview-time::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.8);
}

/* Hiệu ứng fade out cho playlist container */
@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

.playlist-container.fading-out {
    animation: fadeOut 0.3s ease forwards;
}

/* Đảm bảo video YouTube không tràn ra ngoài */
#youtube-player {
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px 12px 0 0 !important;
    background-color: #000 !important;
}

.playlist-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 10px !important;
    padding-bottom: 5px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.playlist-source {
    font-size: 12px !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    background: rgba(255, 255, 255, 0.2) !important;
}

.youtube-source {
    background: rgba(255, 0, 0, 0.6) !important;
}

.track-thumbnail {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    margin-right: 10px !important;
    border-radius: 4px !important;
    object-fit: cover !important;
}

.track-info {
    flex: 1 !important;
    overflow: hidden !important;
    color: white !important;
}

.track-title {
    font-size: 13px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Ẩn các phần tử YouTube UI không mong muốn */
body > .ytp-pause-overlay,
body > .ytp-playlist-container,
body > .ytp-related-videos-card,
body > iframe[src*="youtube.com"]:not(#youtube-player) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ngăn các video YouTube hiển thị phần danh sách phát bên ngoài */
#youtube-player {
    background-color: #000 !important;
}

/* Xử lý lỗi chồng chéo UI */
html body > *:not(#music-player-ui):not(script):not(style) {
    z-index: auto !important;
}

/* Đảm bảo player UI luôn nằm trên cùng */
#music-player-ui.show {
    transform: translateY(0) !important;
    z-index: 9999 !important;
}

/* Ngăn chặn các phần tử YouTube xuất hiện bên ngoài */
html body > div[id^="ytp-"],
html body > div[class^="ytp-"],
html body > .ytp-pause-overlay,
html body > .ytp-playlist-container,
html body > .ytp-related-videos-card,
html body > iframe[src*="youtube.com"]:not(#youtube-player) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -9999 !important;
}

/* Reset lại các transform và opacity khi player hiển thị */
#music-player-ui.show #player-iframe-container,
#music-player-ui.show .playlist-container,
#music-player-ui.show .player-controls,
#music-player-ui.show .player-info {
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Đảm bảo kích thước và các thuộc tính hiển thị */
.iframe-wrapper {
    border-radius: 12px !important;
    overflow: hidden !important;
    background-color: #000 !important;
}

/* Khắc phục vấn đề với danh sách phát */
.playlist-container {
    position: relative !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    background: rgba(25, 25, 25, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* === Spotify Player Styles === */
#music-player-ui.spotify-theme {
    background: #121212 !important;
    color: white !important;
}

#music-player-ui.spotify-theme .player-progress-value {
    background: #1DB954 !important;
}

#music-player-ui.spotify-theme .player-controls button {
    color: white !important;
}

#music-player-ui.spotify-theme .player-controls button:hover {
    background: rgba(29, 185, 84, 0.2) !important;
}

#music-player-ui.spotify-theme .player-source {
    color: #1DB954 !important;
}

/* Khung iframe Spotify */
#music-player-ui.spotify-theme #player-iframe-container {
    padding-top: 0 !important; 
    height: 352px !important;
    max-height: 80vh !important;
    background: #000 !important;
}

/* Loại bỏ padding để iframe lấp đầy container */
#music-player-ui.spotify-theme .iframe-wrapper {
    position: relative !important;
    height: 100% !important;
}

/* Responsive cho Spotify Player */
@media (max-width: 768px) {
    #music-player-ui.spotify-theme #player-iframe-container {
        height: 300px !important;
    }
}

@media (max-width: 480px) {
    #music-player-ui.spotify-theme #player-iframe-container {
        height: 240px !important;
    }
}

/* Tối ưu hóa hiển thị Spotify iframe */
#spotify-player {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 12px 12px 0 0 !important;
}

/* Ẩn playlist container khi đang phát Spotify */
#music-player-ui.spotify-theme .player-playlist-container {
    display: none !important;
}

/* Ẩn thanh điều khiển khi chơi Spotify */
#music-player-ui.spotify-theme .player-controls-bar,
#music-player-ui.spotify-custom .player-controls-bar {
    display: none !important;
}

/* Đảm bảo iframe hiển thị đầy đủ */
#spotify-player {
    border-radius: 12px !important;
    width: 100% !important;
    height: 352px !important;
}

/* Tùy chỉnh container Spotify */
#music-player-ui.spotify-theme {
    background: transparent !important;
}

/* Thêm animation mượt mà cho thanh tiến trình khi tua nhanh */
@keyframes smoothProgress {
    from { background-position: 0 0; }
    to { background-position: 100px 0; }
}

.player-progress-value.seeking {
    background: linear-gradient(90deg, #ff0000 0%, #ff5e5e 50%, #ff0000 100%) !important;
    background-size: 100px 100% !important;
    animation: smoothProgress 2s linear infinite !important;
    transition: width 0.1s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
}

.spotify-theme .player-progress-value.seeking {
    background: linear-gradient(90deg, #1DB954 0%, #4eda7c 50%, #1DB954 100%) !important;
    background-size: 100px 100% !important;
}

.soundcloud-theme .player-progress-value.seeking {
    background: linear-gradient(90deg, #ff7700 0%, #ff9955 50%, #ff7700 100%) !important;
    background-size: 100px 100% !important;
} 
