/* ============ PLAYER OVERLAY ============ */
#vwOverlay {
    display: none; position: fixed; z-index: 2147483647; 
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh; height: 100dvh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    touch-action: none;
}
#vwOverlayInner {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
#vwVideoContainer {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
#vwVideoContainer video {
    width: 100%; height: 100%; max-width: 100%; max-height: 100%;
    object-fit: contain; background: #000;
    outline: none; box-shadow: 0 0 50px rgba(0,0,0,0.5); 
}
#vwVideoContainer video::-webkit-media-controls { display: none !important; opacity: 0 !important; }

/* Sidebar (Right) */
.vw-sidebar {
    position: absolute; right: 10px; bottom: 80px; 
    display: flex; flex-direction: column; gap: 20px; 
    z-index: 100; align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
}
#vwOverlay .vw-action-btn {
    background: transparent; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    padding: 0; -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s;
}
.vw-action-btn:active { transform: scale(0.9); }

/* Icons & Text */
.vw-action-icon {
    width: 50px; height: 50px; background: none; border: none;
    display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.9));
}
.vw-action-icon svg { width: 35px; height: 35px; fill: #fff; }

.vw-action-btn span {
    color: #ffffff !important; font-family: sans-serif;
    font-size: 18px; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,1);
    background: none; border: none; padding: 0; margin-top: -2px;
}
.vw-liked .vw-action-icon svg { fill: #ff2c55; }
.vw-liked span { color: #ff2c55 !important; }

/* Controls */
#vwCloseBtn {
    position: absolute; top: 10px; right: 20px;
    background: rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%; width: 50px; height: 50px;
    cursor: pointer; z-index: 2147483647;
    display: flex; align-items: center; justify-content: center;
    padding: 0; transition: background 0.2s;
}
#vwCloseBtn:active { background: rgba(255,255,255,0.3); }
#vwCloseBtn svg { width: 24px; height: 24px; fill: #fff; }

#vwCenterPlay {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 80px; height: 80px;
    background: rgba(0,0,0,0.4); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; opacity: 0; transition: opacity 0.2s; z-index: 10;
}
#vwCenterPlay svg { width: 40px; height: 40px; fill: #fff; margin-left: 5px; }

/* Toast */
#vwToast {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85); color: white;
    padding: 15px 25px; border-radius: 8px; font-size: 18px; font-family: sans-serif;
    pointer-events: none; z-index: 200; opacity: 0; transition: opacity 0.3s;
    text-align: center; min-width: 200px;
}
#vwToast.show { opacity: 1; }

/* Desktop Arrows */
.vw-nav-arrow {
    position: fixed; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1); border: none; border-radius: 50%;
    width: 60px; height: 60px; cursor: pointer; z-index: 20;
    display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.vw-nav-arrow:hover { background: rgba(255, 255, 255, 0.3); }
.vw-nav-arrow svg { width: 30px; height: 30px; fill: #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
#vwPrevArrow { left: 20px; }
#vwNextArrow { right: 20px; }
@media (max-width: 1024px) { .vw-nav-arrow { display: none; } }

/* iOS Scaling */
.vw-ios-scale .vw-sidebar { bottom: 120px; gap: 40px; right: 35px; }
.vw-ios-scale .vw-action-icon { width: auto; height: auto; margin-bottom: 5px; }
.vw-ios-scale .vw-action-icon svg { width: 80px; height: 80px; }
.vw-ios-scale .vw-action-btn span { font-size: 36px !important; padding: 0; } 
.vw-ios-scale #vwCloseBtn { width: 80px; height: 80px; top: 60px; right: 30px; border-width: 3px; }
.vw-ios-scale #vwCloseBtn svg { width: 40px; height: 40px; }
.vw-ios-scale #vwCenterPlay { width: 140px; height: 140px; }
.vw-ios-scale #vwCenterPlay svg { width: 70px; height: 70px; }
.vw-ios-scale #vwToast { font-size: 28px; padding: 25px 40px; min-width: 300px; }
    
/* ===================== SEEK BAR ===================== */
.vp-seek-bar {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 80px); 
    left: 10%;
    right: 10%;
    height: 10px;
    background: rgba(255,255,255,0.25);
    border-radius: 999px;
    overflow: hidden;
    z-index: 99999;
    touch-action: none;
}
.vp-seek-buffer {
    position: absolute; left:0; top:0; height:100%; width:0%;
    background: rgba(255,255,255,0.35);
}
.vp-seek-progress {
    position: absolute; left:0; top:0; height:100%; width:0%;
    background: #fff;
}
.vp-seek-handle {
    position: absolute; top:50%; width:18px; height:18px;
    background:#fff; border-radius:50%;
    transform: translate(-50%, -50%);
}

/* ===================== AUTO HIDE ===================== */
#vwOverlay.hide-controls #vpSeekBar,
#vwOverlay.hide-controls #vpTimeText,
#vwOverlay.hide-controls #vwCloseBtn,
#vwOverlay.hide-controls #vwPrevArrow,
#vwOverlay.hide-controls #vwNextArrow {
    opacity: 0;
    pointer-events: none;
}

#vwOverlay.hide-controls #vpTimeText {
    opacity: 0;
    pointer-events: none;
}
/* มือถือ: ขยายเวลา 2 เท่า */
@media (max-width:1023px) {
    #vpTimeText {
        font-size: 36px !important;    /* 18px x 2 */
        bottom: calc(env(safe-area-inset-bottom) + 20px) !important;       /* ขยับขึ้นเล็กน้อยให้ไม่ทับ seek bar */
        right: 10% !important;         /* ตำแหน่งเดียวกับ seek bar */
    }
}
    
/* ===================== DESKTOP ===================== */
@media (min-width: 1024px) {

    .vp-seek-bar {
        bottom: 30px;
        left: 15%;
        right: 15%;
        height: 10px;
    }

    #vpTimeText {
        bottom: 60px;
        right: 15%;
        font-size: 18px;
    }
}
/* ===================== ANDROID ===================== */

html.android .vp-seek-bar {
    bottom: 70px !important;       /* ← เลื่อน bar ขึ้นจากขอบล่าง */
    left: 10%;
    right: 10%;
    height: 14px;
}

html.android #vpTimeText {
    bottom: 50px !important;       /* ← เวลาอยู่ใต้ bar แบบชัดเจน */
    right: 10%;
    font-size:16px !important;
}
/* ===================== iOS ===================== */
@supports (-webkit-touch-callout: none) {

    .vp-seek-bar {
        bottom: calc(env(safe-area-inset-bottom) + 90px); 
        left: 10%;
        right: 10%;
        height: 16px;  /* ใหญ่ขึ้นเล็กน้อย */
    }

    #vpTimeText {
        bottom: calc(env(safe-area-inset-bottom) + 20px);
        right: 10%;
        font-size: 36px; /* ใหญ่กว่า Android 2 เท่า */
    }
}