/* =========================================
   MDKG WIDGET SYSTEM (Scoped)
   ========================================= */

/* --- MUSIC PLAYER --- */
.mdkg-widget-player {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 9999;
    --w-bg: rgba(255, 255, 255, 0.65);
    --w-text: #111111;
    --w-sub: #666666;
    background: var(--w-bg);
    backdrop-filter: blur(32px) saturate(200%);
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px; /* [FIX] Disesuaikan agar lebih round dan serasi dengan widget kiri */
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.5s ease, background 0.8s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    color: var(--w-text);
    will-change: transform;
    transform: translateZ(0);
}

.mdkg-widget-player:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
    filter: brightness(1.05);
}

.mdkg-widget-player:active, .mdkg-widget-player.playing:active {
    transform: scale(0.98);
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.1);
}

/* --- [NEW] PLAYER COVER & TRACK INFO --- */
.mdkg-player-cover {
    width: 0; /* Default tertutup */
    height: 28px; /* Lebih kecil agar compact */
    border-radius: 50%; /* [UPDATE] Diubah menjadi lingkaran penuh */
    flex-shrink: 0;
    /* [FIX] Background dihapus, border ditangani langsung oleh image */
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin-right: 0;
    position: relative;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Mencegah gambar bocor saat transisi */
}

/* [NEW] Efek Pantulan Cahaya di Piringan Hitam */
.mdkg-player-cover::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 28px; height: 28px; /* [FIX] Ukuran absolut agar silau tidak gepeng */
    border-radius: 50%;
    /* Pantulan dibuat lebih transparan dan soft */
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 40%, transparent 60%, rgba(255,255,255,0.1) 100%);
    z-index: 2;
    pointer-events: none;
}

/* [NEW] Titik tengah (hole) piringan hitam dibuat lebih detail */
.mdkg-player-cover::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #e0e0e0;
    border: 1px solid #111;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
    box-sizing: border-box; /* [FIX] Memastikan titik tengah bulat sempurna */
}

/* [NEW] State Terbuka saat Play */
.mdkg-widget-player.playing .mdkg-player-cover {
    width: 28px;
    margin-right: 6px;
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: auto; /* [FIX] Aktifkan klik/hover di cover saat play */
    cursor: zoom-in; /* [NEW] Kursor khusus menandakan bisa di-zoom */
}

@keyframes mdkgSpinRecord {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mdkg-track-cover {
    min-width: 28px; /* [FIX] Paksa bentuk bulat konsisten di 28px */
    height: 28px;
    border: 2px solid #111; /* [FIX] Symmetrical sempurna */
    box-sizing: border-box;
    object-fit: cover;
    /* [NEW] Animasi putar yang di-pause secara default */
    animation: mdkgSpinRecord 4s linear infinite;
    animation-play-state: paused; 
    border-radius: 50%;
    z-index: 1;
    display: block; /* [FIX] Menghilangkan space kosong/miring bawaan elemen image */
    background-color: #111;
}

/* [NEW] Piringan berputar hanya saat lagu sedang play */
.mdkg-widget-player.playing .mdkg-track-cover {
    animation-play-state: running;
}

.mdkg-track-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    line-height: 1.2;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    margin-left: 0;
}

.mdkg-widget-player.playing .mdkg-track-info {
    max-width: 110px;
    opacity: 1;
}

.mdkg-track-title {
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--w-text);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    width: 100%;
}

.mdkg-track-artist {
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    color: var(--w-sub);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    width: 100%;
}

.mdkg-player-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mdkg-player-icon svg {
    width: 16px;
    height: 16px;
}

.mdkg-player-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mdkg-player-text {
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--w-text);
    letter-spacing: 0.5px;
    user-select: none;
    text-align: center;
    max-width: 60px; /* Cukup menampung kata PLAY/PAUSED */
    opacity: 1;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    overflow: hidden;
}

.mdkg-widget-player.playing .mdkg-player-text {
    max-width: 0;
    opacity: 0;
    margin: 0;
}

.mdkg-visualizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 12px;
    width: 14px;
}

.mdkg-bar {
    width: 3px;
    background-color: var(--w-text);
    height: 2px;
    transition: height 0.2s ease;
}

/* Animation State */
.mdkg-widget-player.playing .mdkg-bar {
    animation: mdkgEqualizer 0.5s infinite ease-in-out alternate;
}

.mdkg-widget-player.playing .mdkg-bar:nth-child(1) { animation-duration: 0.4s; }
.mdkg-widget-player.playing .mdkg-bar:nth-child(2) { animation-duration: 0.5s; }
.mdkg-widget-player.playing .mdkg-bar:nth-child(3) { animation-duration: 0.35s; }

@keyframes mdkgEqualizer {
    0% { height: 20%; }
    100% { height: 100%; }
}

/* Next Button */
.mdkg-next-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-left: 4px;
    opacity: 0.7;
    color: var(--w-text);
}
.mdkg-next-btn:hover {
    background: rgba(0,0,0,0.08);
    opacity: 1;
    transform: scale(1.1);
}
.mdkg-next-btn svg {
    width: 12px;
    height: 12px;
}

/* --- [NEW] MDKG WIDGET LIGHTBOX & TOOLTIP --- */
.mdkg-cover-tooltip {
    position: absolute;
    bottom: 100%;
    left: 14px;
    transform: translateY(-8px) scale(0.95);
    background: rgba(17, 17, 17, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 10;
}

.mdkg-cover-tooltip::after {
    content: ''; position: absolute; top: 100%; left: 14px;
    border: 4px solid transparent; border-top-color: rgba(17, 17, 17, 0.95);
}

/* Menampilkan Tooltip saat cover di-hover */
.mdkg-player-cover:hover ~ .mdkg-cover-tooltip {
    opacity: 1; visibility: visible;
    transform: translateY(-12px) scale(1);
}

/* Lightbox Styles */
#mdkg-widget-lightbox {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100000;
    display: none; align-items: center; justify-content: center; opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}
#mdkg-widget-lightbox.active { opacity: 1; }

.mdkg-lightbox-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    cursor: zoom-out;
}

.mdkg-lightbox-content {
    position: relative; z-index: 2; max-width: 90vw; max-height: 90vh;
    transform: scale(0.9); transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}
#mdkg-widget-lightbox.active .mdkg-lightbox-content { transform: scale(1); }

.mdkg-lightbox-content img {
    max-width: 100%; max-height: 90vh; border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); display: block; object-fit: contain;
}

.mdkg-lightbox-close {
    position: absolute;
    top: 32px;
    right: 40px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 10001;
}

.mdkg-lightbox-close svg {
    width: 20px;
    height: 20px;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}
.mdkg-lightbox-close:hover { background: #fff; color: #000; transform: scale(1.05); }
.mdkg-lightbox-close:hover svg { transform: rotate(90deg); }

/* --- LIVE STATUS WIDGET --- */
.mdkg-widget-status {
    position: fixed;
    bottom: 40px;
    left: 40px;
    z-index: 9990;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(32px) saturate(200%);
    -webkit-backdrop-filter: blur(32px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 20px 24px;
    border-radius: 24px;
    color: #111111;
    font-family: var(--font-primary, 'Inter', sans-serif);
    width: max-content;
    min-width: 260px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
    text-decoration: none;
}

.mdkg-widget-status.widget-hidden,
.mdkg-widget-player.widget-hidden {
    transform: translateY(200%) !important;
    opacity: 0;
    pointer-events: none;
}

.mdkg-widget-status:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
    filter: brightness(1.05);
}

.mdkg-widget-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    padding: 0;
    border: none;
    font-weight: 600;
}

.mdkg-widget-status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.mdkg-status-dot {
    width: 8px;
    height: 8px;
    background-color: #28cd41; /* Apple Green */
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(40, 205, 65, 0.7);
    animation: mdkgStatusPulse 2.5s infinite cubic-bezier(0.66, 0, 0, 1);
}

/* [FIX] Animasi Pulse untuk dot hijau dikembalikan */
@keyframes mdkgStatusPulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 205, 65, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 205, 65, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 205, 65, 0); }
}

.mdkg-status-text {
    font-size: 14px;
    color: #000000;
    font-weight: 500;
    position: relative;
    white-space: nowrap; /* Memastikan teks tidak turun ke bawah */
}

/* --- Animasi Kursor Ketik --- */
.mdkg-typing-cursor {
    font-weight: 400;
    color: #111;
    animation: mdkgBlink 0.8s step-end infinite;
}

@keyframes mdkgBlink {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}

.mdkg-book-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: #111111;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 16px;
    letter-spacing: 0.5px;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    border: 1px solid transparent;
    cursor: none !important;
}

.mdkg-book-btn:hover {
    background: #ffffff;
    color: #111111;
    border-color: #111111;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* Calendar Icon Pulse Animation */
@keyframes mdkgIconPulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
    50% { transform: scale(1.2); filter: drop-shadow(0 0 4px rgba(0,0,0,0.2)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
}

.mdkg-book-btn > svg:first-child {
    animation: mdkgIconPulse 2s infinite ease-in-out;
}

/* --- CUSTOM SNAP CURSOR --- */
.mdkg-snap-cursor {
    position: fixed;
    top: 0; left: 0;
    width: 10px; height: 10px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9991; /* Berada tepat di atas widget status */
    opacity: 0;
}

/* --- TABLET RESPONSIVE --- */
@media (max-width: 991px) {
    .mdkg-widget-player {
        bottom: 30px;
        right: 30px;
    }
    .mdkg-widget-status {
        bottom: 30px;
        left: 30px;
    }
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 767px) {
    .mdkg-widget-player {
        bottom: 20px;
        right: 20px;
        padding: 0 12px;
        height: 48px; /* [FIX] Tinggi sedikit dinaikkan agar lebih pas dan nyaman ditekan */
        box-sizing: border-box;
        gap: 6px;
        border-radius: 20px; /* [FIX] Dibuat lebih membulat di mobile menyamai Live Status */
        max-width: max-content;
        border: none; /* [FIX] Menghapus border transparan di mobile */
    }

    .mdkg-player-text,
    .mdkg-track-info,
    .mdkg-widget-player.playing .mdkg-track-info,
    .mdkg-player-cover,
    .mdkg-widget-player.playing .mdkg-player-cover {
        display: none !important;
    }

    .mdkg-visualizer {
        display: flex !important;
        margin: 0 4px;
    }

    .mdkg-player-icon svg {
        width: 20px; /* Diperkecil agar widget tidak terlalu lebar */
        height: 20px;
    }

    .mdkg-next-btn {
        width: 20px; /* Diperkecil agar proporsional */
        height: 20px;
        margin-left: 0;
    }
    
    .mdkg-cover-tooltip {
        display: none !important; /* Tooltip tak relevan di Mobile Touch */
    }

    .mdkg-lightbox-close {
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }
    .mdkg-lightbox-close svg {
        width: 18px;
        height: 18px;
    }

    /* Compact Live Status Widget */
    .mdkg-widget-status {
        position: fixed;
        bottom: 20px;
        left: 20px;
        transform: none;
        z-index: 990;
        width: auto;
        min-width: 0;
        max-width: calc(100vw - 120px); /* Ruang diperlebar agar teks muat penuh */
        height: 48px; /* [FIX] Tinggi disamakan presisi dengan Music Player */
        padding: 0 10px;
        box-sizing: border-box; /* [FIX] Memastikan padding tidak menambah tinggi asli kotak */
        border-radius: 20px;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }
    .mdkg-widget-header { display: none; } /* Hide clock on mobile */
    .mdkg-widget-status-row { margin-bottom: 0; margin-right: auto; }
    .mdkg-status-text { font-size: 11px; line-height: 1.2; white-space: nowrap; } /* Mencegah elipsis/kepotong */
    
    .mdkg-book-btn {
        width: 32px; height: 32px; padding: 0; border-radius: 12px; flex-shrink: 0;
        display: flex; align-items: center; justify-content: center; gap: 0;
        background: #111; color: #fff;
    }
    .mdkg-book-btn span {
        display: none; /* Sembunyikan teks di mobile */
    }
    .mdkg-snap-cursor { display: none !important; } /* Nonaktifkan kursor pada sentuhan layar HP */
}