/* --- 1. KHUNG CHÍNH (GIỮ HIỆU ỨNG KÍNH & ĐỔ BÓNG) --- */
.lynk-main-ui {
    background: rgba(20, 20, 20, 0.08) !important; 
    backdrop-filter: blur(2px)!important;
    -webkit-backdrop-filter: blur(2px)!important;
    border-radius: 999px !important;
    border: 1px solid rgba(247, 231, 206, 0.1)!important;
    z-index: 9999;
    box-shadow: 0 4px 15px 0 rgba(0, 0, 0, 0.1)!important;
    max-width: 950px;
    display: flex !important;
    align-items: center;
    gap: 25px;
    width: 100% !important;
    flex-direction: row !important;
    opacity: 0; 
    animation: fadeInPlayer 0.5s ease forwards;
}

.lynk-center-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 10px;
}

.lynk-controls-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.lynk-header { 
    display: flex; 
    align-items: center; 
    gap: 12px;
    margin-bottom: 0 !important;
    flex-shrink: 0;
    padding-left: 0 !important;
}

/* --- 2. VOLUME & MUTE (GIỮ NGUYÊN) --- */
.lynk-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 170px; 
}

#lynk-mute {
    background: transparent !important;
    border: none !important;
    width: 28px;
    height: 28px;
    cursor: pointer;
    color: #F7E7CE !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#lynk-mute:hover {
    color: #00F2AD !important;
}

#lynk-volume-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 110px !important;
    height: 4px;
    background: linear-gradient(to right, #00F2AD 0%, #00F2AD var(--volume-before-width, 80%), rgba(247, 231, 206, 0.2) var(--volume-before-width, 80%)) !important;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

#lynk-volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #00F2AD;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 5px rgba(0, 242, 173, 0.5);
}

/* --- 3. ICONS (GIỮ NGUYÊN) --- */
.pc-svg { 
    width: 20px !important;   
    height: 20px !important; 
    display: block !important;
    fill: currentColor !important;
}

.lynk-volume-wrapper .pc-svg {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 16px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- 4. ĐĨA THAN (XOÁ THUMBNAIL NHƯNG GIỮ ĐĨA QUAY) --- */
.lynk-thumb-container {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.lynk-record-bg {
    position: absolute;
    width: 100% !important;
    height: 100% !important;
    z-index: 1;
    border-radius: 50% !important; /* Bo tròn đĩa than */
    animation: lynkRotation 10s linear infinite;
    animation-play-state: paused; /* Chỉ quay khi nhạc phát */
    transition: box-shadow 0.3s ease, filter 0.3s ease;
}

/* Chỉ xóa hiển thị của ảnh thumbnail nhỏ */
.lynk-disk-thumb {
    display: none !important;
}

/* --- HIỆU ỨNG BÓNG XANH KHI NHẠC ĐANG PHÁT (VỪA PHẢI) --- */
.music-is-playing .lynk-record-bg {
    animation-play-state: running !important;
    /* Bóng xanh toả ra xung quanh đĩa than - vừa phải */
    box-shadow: 
        0 0 10px rgba(0, 242, 173, 0.5),
        0 0 20px rgba(0, 242, 173, 0.3),
        0 0 30px rgba(0, 242, 173, 0.2) !important;
    filter: drop-shadow(0 0 8px rgba(0, 242, 173, 0.4));
}

/* Thêm hiệu ứng pulse cho bóng xanh (nhẹ nhàng) */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 
            0 0 10px rgba(0, 242, 173, 0.5),
            0 0 20px rgba(0, 242, 173, 0.3),
            0 0 30px rgba(0, 242, 173, 0.2);
    }
    50% {
        box-shadow: 
            0 0 15px rgba(0, 242, 173, 0.6),
            0 0 25px rgba(0, 242, 173, 0.4),
            0 0 35px rgba(0, 242, 173, 0.25);
    }
}

.music-is-playing .lynk-record-bg {
    animation: 
        lynkRotation 10s linear infinite,
        glowPulse 2s ease-in-out infinite;
}

/* --- 5. META & BUTTONS (PHỤC HỒI HIỆU ỨNG ACTIVE) --- */
.lynk-meta {
    display: flex;
    flex-direction: column;
    min-width: 280px;
    max-width: 550px;
}

.lynk-song-title { 
    font-weight: bold; 
    font-size: 15px; 
    color: #F7E7CE; 
    margin: 0;
}

.lynk-song-artist { 
    font-size: 11px; 
    color: #F7E7CE; 
    opacity: 0.6; 
}

.lynk-buttons-group {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.lynk-icon-btn {
    background: transparent !important;
    border: none !important;
    width: 28px !important;
    height: 28px !important;
    padding: 0;
    cursor: pointer;
    color: #F7E7CE !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.lynk-icon-btn:hover {
    color: #00F2AD !important;
    transform: scale(1.1);
}

/* Nút không active - Reset về trạng thái mặc định */
.lynk-icon-btn:not(.active) {
    color: #F7E7CE !important;
    transform: scale(1) !important;
    filter: none !important;
}

/* Nút active - Sáng lên khi được bật */
.lynk-icon-btn.active {
    color: #00F2AD !important;
    transform: scale(1.15) !important;
    filter: drop-shadow(0 0 5px rgba(0, 242, 173, 0.9)) !important;
}

.lynk-play-trigger {
    background: #00F2AD !important;
    width: 34px !important;  
    height: 34px !important; 
    border-radius: 50%;
    border: none !important;
    cursor: pointer;
    color: #000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.2s ease;
}

.lynk-play-trigger:hover {
    transform: scale(1.1);
}

/* --- 6. PROGRESS BAR (GIỮ NGUYÊN) --- */
.lynk-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* ===== SEEK BAR – FIX SAFARI ===== */
#lynk-seekbar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: transparent;
    cursor: pointer;
}

/* TRACK */
#lynk-seekbar::-webkit-slider-runnable-track {
    height: 5px;
    background: linear-gradient(
        to right,
        #00F2AD 0%,
        #00F2AD var(--seek-before-width, 0%),
        rgba(247, 231, 206, 0.25) var(--seek-before-width, 0%)
    );
    border-radius: 5px;
}

/* THUMB */
#lynk-seekbar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #00F2AD;
    border-radius: 50%;
    margin-top: -4.5px; /* CĂN GIỮA TRACK */
    box-shadow: 0 0 6px rgba(0, 242, 173, 0.6);
}

/* Firefox fallback */
#lynk-seekbar::-moz-range-track {
    height: 5px;
    background: rgba(247, 231, 206, 0.25);
}
#lynk-seekbar::-moz-range-progress {
    height: 5px;
    background: #00F2AD;
}
#lynk-seekbar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #00F2AD;
    border-radius: 50%;
}

.lynk-timer {
    font-size: 12px;
    color: #F7E7CE;
    font-family: monospace;
}

/* --- 7. ANIMATIONS (GIỮ NGUYÊN) --- */
@keyframes lynkRotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeInPlayer {
    to { opacity: 1; }
}

/* ============================================
   COLLAPSED STATE - DESKTOP + MOBILE
   ============================================ */
.lynk-main-ui.collapsed .lynk-center-content {
    opacity: 0 !important;
    max-width: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translateX(20px);
    pointer-events: none;
    overflow: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.lynk-main-ui.collapsed {
    width: 90px !important;
    height: 90px !important;
    max-width: 90px !important;
    max-height: 90px !important;
    min-width: 90px !important;
    min-height: 90px !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 50% !important;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                gap 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.lynk-main-ui.collapsed .lynk-header {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    align-self: stretch !important;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                align-self 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.lynk-main-ui.collapsed .lynk-thumb-container {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

.lynk-main-ui.collapsed .lynk-thumb-container .lynk-record-bg {
    width: 100% !important;
    height: 100% !important;
}

.lynk-main-ui.collapsed .lynk-volume-wrapper {
    display: none !important;
}

.lynk-thumb-container {
    cursor: pointer;
}

/* ============================================
   MOBILE RESPONSIVE - PLAYER LAYOUT
   ============================================ */
@media (max-width: 768px), (max-width: 1024px) and (orientation: portrait) {
    /* Wrapper - break out nhưng chừa 10px mỗi bên */
    .lynk-player-wrapper {
        margin-left: calc(-50vw + 50% + 10px) !important;
        margin-right: calc(-50vw + 50% + 10px) !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Khung chính - hòa làm một với đĩa than: chiều cao = đường kính đĩa than (90px), bo tròn đầu */
    .lynk-main-ui {
        max-width: 100% !important;
        width: 100% !important;
        height: 90px !important; /* Chiều cao = đường kính đĩa than */
        min-height: 90px !important;
        max-height: 90px !important;
        border-radius: 100px !important; /* Bo tròn các đầu như lúc đầu */
        padding: 0 10px 0 0 !important; /* Padding phải nhỏ lại */
        gap: 10px !important; /* Gap nhỏ lại */
        flex-direction: row !important;
        align-items: center !important;
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    gap 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Cột trái - Đĩa than: kích thước cố định 90px */
    .lynk-header {
        flex-shrink: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        width: 90px !important; /* Bằng đường kính đĩa than */
        height: 90px !important; /* Bằng đường kính đĩa than */
        min-width: 90px !important;
        min-height: 90px !important;
        max-width: 90px !important;
        max-height: 90px !important;
        padding: 0 !important;
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .lynk-thumb-container {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 !important;
        max-width: 100% !important;
        max-height: 100% !important;
        min-width: 90px !important;
        min-height: 90px !important;
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Đảm bảo đĩa than có width = height của container */
    .lynk-thumb-container .lynk-record-bg {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
    }
    
    /* Cột phải - Content: chiều cao cố định 90px, nội dung nhỏ lại */
    .lynk-center-content {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important; /* Gap nhỏ lại */
        min-width: 0 !important;
        height: 90px !important; /* Chiều cao = đường kính đĩa than */
        max-height: 90px !important;
        min-height: 90px !important;
        justify-content: center !important;
        transition: opacity 0.3s ease, transform 0.3s ease, max-width 0.3s ease, margin 0.3s ease, height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }
    
    /* Khi player collapsed - ẩn cột phải với animation mượt */
    .lynk-main-ui.collapsed .lynk-center-content {
        opacity: 0 !important;
        max-width: 0 !important;
        width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: translateX(20px);
        pointer-events: none;
        overflow: hidden;
        transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Khi player collapsed - khung chỉ còn đĩa than tròn (thu về mượt, khít với đĩa than) */
    .lynk-main-ui.collapsed {
        width: 90px !important; /* Bằng đúng kích thước đĩa than (90px từ min-width) */
        height: 90px !important; /* Bằng đúng kích thước đĩa than */
        max-width: 90px !important;
        max-height: 90px !important;
        min-width: 90px !important;
        min-height: 90px !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important; /* Không có padding, khít với đĩa than */
        gap: 0 !important;
        border-radius: 50% !important; /* Tròn như đĩa than */
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    gap 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Khi player collapsed - đĩa than chiếm toàn bộ container (không padding) */
    .lynk-main-ui.collapsed .lynk-header {
        width: 100% !important;
        height: 100% !important;
        min-width: 100% !important;
        min-height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        align-self: stretch !important; /* Chiếm toàn bộ container */
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    min-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    margin 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    align-self 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Đảm bảo đĩa than chiếm toàn bộ container khi collapsed - giữ nguyên kích thước 90px */
    .lynk-main-ui.collapsed .lynk-thumb-container {
        width: 100% !important;
        height: 100% !important;
        min-width: 100% !important;
        min-height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
    
    /* Đĩa than record bg - chiếm toàn bộ container */
    .lynk-main-ui.collapsed .lynk-thumb-container .lynk-record-bg {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Đĩa than có thể click trên mobile */
    .lynk-thumb-container {
        cursor: pointer;
    }
    
    /* Controls Row - Xếp dọc: tiêu đề trên, nút dưới */
    .lynk-controls-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Meta - Chỉ tiêu đề, bỏ tên ca sĩ */
    .lynk-meta {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        order: 1 !important;
        overflow: hidden !important;
    }
    
    .lynk-song-title {
        font-size: 12px !important;
        line-height: 1.2 !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .lynk-song-artist {
        display: none !important; /* Ẩn tên ca sĩ */
    }
    
    /* Buttons Group - 5 nút (dưới tiêu đề) */
    .lynk-buttons-group {
        width: 100% !important;
        justify-content: center !important;
        gap: 5px !important;
        order: 2 !important;
        flex-shrink: 0 !important;
    }
    
    .lynk-icon-btn {
        width: 28px !important;
        height: 28px !important;
    }
    
    .lynk-play-trigger {
        width: 32px !important;
        height: 32px !important;
    }
    
    .lynk-icon-btn .pc-svg,
    .lynk-play-trigger .pc-svg {
        width: 14px !important;
        height: 14px !important;
    }
    
    /* Progress Container - Dưới buttons */
    .lynk-progress-container {
        order: 3 !important;
        width: 100% !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
    }
    
    .lynk-timer {
        font-size: 9px !important;
        min-width: 30px !important;
        flex-shrink: 0 !important;
    }
    
    #lynk-seekbar {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    /* Ẩn Volume trên mobile */
    .lynk-volume-wrapper {
        display: none !important;
    }
}

/* Small Mobile - Điều chỉnh thêm cho màn hình nhỏ */
@media (max-width: 480px) {
    .lynk-main-ui {
        height: 90px !important;
        min-height: 90px !important;
        max-height: 90px !important;
        padding: 0 8px 0 0 !important;
        gap: 8px !important;
        border-radius: 100px !important;
        max-width: 100% !important;
        width: auto !important;
    }
    
    .lynk-header {
        width: 90px !important;
        height: 90px !important;
        min-width: 90px !important;
        min-height: 90px !important;
        max-width: 90px !important;
        max-height: 90px !important;
    }
    
    .lynk-thumb-container {
        min-width: 90px !important;
        min-height: 90px !important;
    }
    
    .lynk-center-content {
        height: 90px !important;
        max-height: 90px !important;
        min-height: 90px !important;
        gap: 6px !important;
    }
    
    .lynk-controls-row {
        gap: 6px !important;
    }
    
    .lynk-song-title {
        font-size: 11px !important;
    }
    
    .lynk-song-artist {
        font-size: 9px !important;
    }
    
    .lynk-buttons-group {
        gap: 4px !important;
    }
    
    .lynk-icon-btn {
        width: 28px !important;
        height: 28px !important;
    }
    
    .lynk-play-trigger {
        width: 32px !important;
        height: 32px !important;
    }
    
    .lynk-icon-btn .pc-svg,
    .lynk-play-trigger .pc-svg {
        width: 14px !important;
        height: 14px !important;
    }
    
    .lynk-progress-container {
        gap: 4px !important;
        min-width: 60px !important;
    }
    
    .lynk-timer {
        font-size: 8px !important;
        min-width: 28px !important;
    }
}
