﻿/* Main Watch Page Styles */
body {
    background-color: #0f0f0f;
    /* YouTube Dark Mode */
}

/* Hide category sidebar by default on watch page — slide-in drawer only */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 220px;
    height: calc(100vh - 56px);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar.mobile-open {
    transform: translateX(0);
}

/* Dark overlay when sidebar is open on watch page */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* Container Adjustment for Ads */
.player-container {
    width: 100%;
    /* Mobile Default */
    max-width: 1600px;
    /* Allow wider content */
    margin: 0 auto;
    /* Removed top margin */
    padding: 75px 20px 20px 20px;
    /* Header 65px + 10px gap = 75px top padding */
    box-sizing: border-box;
}

/* Desktop: Reserve 170px on each side for Banner Ads */
@media (min-width: 1400px) {
    .player-container {
        padding-left: 170px;
        padding-right: 170px;
    }
}

.video-wrapper {
    box-shadow: none;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    /* Force logical cinema aspect ratio boundaries */
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16/9;
    max-height: 85vh;
    /* Prevent overflowing viewport height */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    /* Center wrapper */
    transition: all 0.3s ease;
}

.video-wrapper.ratio-9-16 {
    aspect-ratio: 9/16;
    max-width: 360px;
    /* Smaller width for comfort */
    max-height: 70vh;
    /* Prevent taking up too much screen */
}

/* Force Plyr to fit within the wrapper */
.plyr {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Ensure video inside uses contain to avoid cropping */
.plyr__video-wrapper {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

.plyr__video-wrapper video {
    object-fit: contain;
    width: 100%;
    height: 100%;
}



.movie-info-section {
    margin-top: 20px;
    background-color: #272727;
    padding: 20px;
    border-radius: 12px;
}

.movie-title {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.movie-desc {
    color: #ccc;
    line-height: 1.6;
}

.back-btn {
    display: inline-block;
    margin-bottom: 20px;
    color: #fff;
    text-decoration: none;
    font-weight: 500;
}

.back-btn:hover {
    color: var(--primary-color);
}

/* Plyr Customization - YouTube Style UI */
.plyr--video .plyr__control svg {
    fill: #fff !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.plyr__control--overlaid svg {
    fill: #fff !important;
    filter: none;
}

.video-primary-info {
    padding: 20px 0 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.video-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    color: #f1f1f1;
    margin: 0 0 10px 0;
}

.video-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.video-meta-left {
    color: #aaa;
    font-size: 14px;
}

.video-actions-right {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #f1f1f1;
    padding: 0 16px;
    height: 36px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Description Box */
.desc-container {
    margin-top: 12px;
    background: #272727;
    /* YouTube dark surface */
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    color: #f1f1f1;
    cursor: pointer;
}

.desc-container:hover {
    background: #3f3f3f;
}

.desc-meta {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 14px;
}

.desc-content {
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Show only 2 lines by default */
    -webkit-box-orient: vertical;
}

.desc-content.expanded {
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

.show-more-btn {
    font-weight: bold;
    margin-top: 4px;
    cursor: pointer;
    color: #fff;
}

/* Recommendation Section */
.rec-section {
    margin-top: 24px;
}

.rec-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

a.rec-item {
    display: flex;
    flex-direction: row;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.rec-img-wrapper {
    position: relative;
    width: 168px;
    /* Fixed width for thumbnail */
    min-width: 168px;
    /* Prevent shrinking */
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.rec-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.rec-item:hover .rec-img-wrapper img {
    transform: scale(1.05);
}

.rec-info-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rec-info-meta {
    font-size: 12px;
    color: #aaa;
}

/* Responsive */
@media (min-width: 1024px) {
    .watch-layout {
        display: flex;
        gap: 24px;
    }

    .main-column {
        flex: 1;
        min-width: 0;
        /* Fix flex overflow */
        padding-top: 20px;
    }

    .sidebar-column {
        width: 350px;
        flex-shrink: 0;
        /* Align with main column */
        padding-top: 20px;
        /* Match video player height: scrollable sidebar */
        max-height: calc(100vh - 76px);
        overflow-y: auto;
        position: sticky;
        top: 76px;
    }
}

/* Skin Ad Zones */
.promo-skin-zone {
    display: none;
    /* Hide on mobile */
    position: fixed;
    top: 100px;
    width: 130px;
    height: 600px;
    z-index: 99;
}

.left-skin {
    left: 15px;
}

.right-skin {
    right: 15px;
}

@media (min-width: 1400px) {
    .promo-skin-zone {
        display: block;
    }
}

/* ========== YOUTUBE-STYLE THEME ========== */
:root {
    --plyr-color-main: #ff0000;
    --plyr-range-fill-background: #ff0000;
    --plyr-video-control-color: #fff;
    --plyr-video-control-color-hover: #fff;
    --plyr-video-controls-background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    --plyr-range-track-height: 3px;
    --plyr-range-thumb-height: 13px;
    --plyr-range-thumb-background: #ff0000;
}

/* Force icon colors to white */
.plyr--video .plyr__control svg {
    fill: #fff !important;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.plyr__control--overlaid svg {
    fill: #fff !important;
    filter: none;
}

/* YouTube-like gradient overlay for controls */
.plyr--video .plyr__controls {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)) !important;
    padding: 30px 12px 10px;
}

/* Progress bar - thin like YouTube, expands on hover */
.plyr--video .plyr__progress__container {
    margin-bottom: 2px;
}

.plyr--video .plyr__progress input[type="range"] {
    height: 3px;
    transition: height 0.15s ease;
}

.plyr--video .plyr__controls:hover .plyr__progress input[type="range"] {
    height: 5px;
}

/* Red thumb on progress bar */
.plyr__progress input[type="range"]::-webkit-slider-thumb {
    background: #ff0000;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.plyr--video .plyr__controls:hover .plyr__progress input[type="range"]::-webkit-slider-thumb {
    opacity: 1;
}

/* Buffer track */
.plyr--video .plyr__progress__buffer {
    color: rgba(255, 255, 255, 0.35);
}

/* Control buttons styling */
.plyr--video .plyr__control {
    padding: 8px;
    transition: opacity 0.15s ease;
}

.plyr--video .plyr__control:hover {
    background: transparent !important;
    opacity: 0.8;
}

/* Time display like YouTube */
.plyr__time {
    font-size: 13px !important;
    font-weight: 400;
    color: #ddd !important;
}

/* Settings menu YouTube-like */
.plyr__menu__container {
    background: rgba(28, 28, 28, 0.95) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.5) !important;
}

.plyr__menu__container .plyr__control {
    color: #eee !important;
    font-size: 13px;
}

.plyr__menu__container .plyr__control--back {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.plyr__menu__container .plyr__control[role="menuitemradio"][aria-checked="true"]::before {
    background-color: #ff0000 !important;
}

/* Constrain menu height for small viewports */
.plyr__menu__container [role="menu"] {
    max-height: 280px;
    overflow-y: auto;
}

/* Large play button - YouTube style: PINNED to center */
.plyr__control--overlaid {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: rgba(0, 0, 0, 0.6) !important;
    border: none !important;
    border-radius: 50% !important;
    padding: 18px !important;
    opacity: 1 !important;
    transition: background 0.2s ease, opacity 0.2s ease !important;
}

.plyr__control--overlaid:hover {
    background: rgba(255, 0, 0, 0.85) !important;
    transform: translate(-50%, -50%) scale(1.08) !important;
}

.plyr__control--overlaid svg {
    width: 28px;
    height: 28px;
}

/* Hide Plyr's native play-large completely globally.
   We use a custom center button instead. */
.plyr__control--overlaid {
    display: none !important;
}

/* Custom Center Play/Pause Button (replaces play-large) */
.mobile-center-btn {
    display: none;
    /* Hidden by default, shown via JS on mobile or on hover on desktop */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    cursor: pointer;
    z-index: 50;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

/* Show on desktop when hovering over the player or when paused */
@media (min-width: 769px) {

    /* Show on hover - Plyr moves the button inside .plyr at runtime */
    .plyr:hover .mobile-center-btn {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* When video is paused, keep visible even without hover */
    .plyr.plyr--paused .mobile-center-btn {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
}

.mobile-center-btn svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.mobile-center-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

.mobile-center-btn:active {
    background: rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%) scale(0.9);
}

/* Show the button when controls are visible (Mobile JS logic) */
.mobile-center-btn.visible {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Hide pause icon by default, show play */
.mobile-center-btn .icon-pause {
    display: none;
}

.mobile-center-btn .icon-play {
    display: block;
}

/* When playing, swap icons */
.mobile-center-btn.is-playing .icon-pause {
    display: block;
}

.mobile-center-btn.is-playing .icon-play {
    display: none;
}

/* Tooltip styling */
.plyr__tooltip {
    background: rgba(28, 28, 28, 0.9) !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    padding: 4px 8px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
}

/* Volume slider - keep it clean, no oversized thumb */
.plyr--video .plyr__volume input[type="range"] {
    height: 3px;
}

.plyr--video .plyr__volume input[type="range"]::-webkit-slider-thumb {
    background: #fff;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Fullscreen button pulse */
.plyr__control[data-plyr="fullscreen"] {
    transition: transform 0.15s ease;
}

.plyr__control[data-plyr="fullscreen"]:hover {
    transform: scale(1.1);
}

/* ========== MOBILE RESPONSIVE (YouTube-like) ========== */
@media (max-width: 768px) {

    /* Volume hiding is done via JS (body.is-mobile-device) instead of media query.
       This prevents volume from being hidden on desktop when iframe is narrow (e.g. 9:16 videos). */

    /* Show rewind/forward on mobile with extra spacing */
    .plyr__controls [data-plyr="rewind"] {
        order: 3;
        margin-left: 4px;
    }

    .plyr__controls [data-plyr="fast-forward"] {
        order: 4;
        margin-right: 4px;
    }

    /* Controls: 2 h�ng - thanh tua ri�ng, n�t b?m ri�ng */
    .plyr--video .plyr__controls {
        padding: 10px 8px 6px;
        gap: 0;
        flex-wrap: wrap;
    }

    /* Thanh tua chi?m full chi?u ngang - ri�ng 1 h�ng tr�n c�ng */
    .plyr__progress__container {
        flex: 0 0 100% !important;
        width: 100% !important;
        order: -1;
        min-width: 0;
        margin-bottom: 4px;
    }

    /* Thanh tua to d�y d? b?m tr�n mobile */
    .plyr--video .plyr__progress input[type="range"] {
        height: 8px !important;
    }

    /* N�t k�o (thumb) to hon cho d? ch?m */
    .plyr__progress input[type="range"]::-webkit-slider-thumb {
        width: 16px !important;
        height: 16px !important;
        opacity: 1 !important;
    }

    /* ?n thanh buffer tr?ng */
    .plyr--video .plyr__progress__buffer {
        display: none !important;
    }

    /* CRITICAL: Touch targets must be at least 44px (Apple/Google rule) */
    .plyr--video .plyr__control {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Keep icons readable but wrap in bigger touch area */
    .plyr--video .plyr__control svg {
        width: 20px;
        height: 20px;
    }

    .plyr__time {
        font-size: 13px !important;
    }

    /* Layout: Play + Time tr�i | Settings + Fullscreen ph?i */
    .plyr__controls [data-plyr="play"] {
        order: 1;
    }

    .plyr__controls .plyr__time {
        order: 2;
    }

    /* �?y settings + fullscreen sang ph?i */
    .plyr__controls .plyr__menu {
        order: 10;
        margin-left: auto !important;
    }

    .plyr__controls [data-plyr="fullscreen"] {
        order: 11;
    }

    /* Ensure settings menu is NOT clipped */
    .plyr__menu__container {
        bottom: 100% !important;
        top: auto !important;
    }

    /* Mobile-responsive center play/pause button */
    .mobile-center-btn {
        width: 48px !important;
        height: 48px !important;
        background: rgba(0, 0, 0, 0.35) !important;
    }

    .mobile-center-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* Hide volume slider on mobile (hardware volume instead) */
    .plyr__volume {
        display: none !important;
    }
}

/* Also hide volume slider on mobile devices detected by JS class */
body.is-mobile-device .plyr__volume {
    display: none !important;
}

/* ========== CUSTOM MUTE BUTTON (for mobile, since Plyr removes native mute on touch devices) ========== */
.custom-mute-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.custom-mute-btn svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.custom-mute-btn .icon-volume-off {
    display: none;
}

.custom-mute-btn.is-muted .icon-volume-on {
    display: none;
}

.custom-mute-btn.is-muted .icon-volume-off {
    display: block;
}

/* Double-tap seek visual feedback */
.seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.seek-indicator.left {
    left: 15%;
}

.seek-indicator.right {
    right: 15%;
}

.seek-indicator.show {
    opacity: 1;
    animation: seekPulse 0.6s ease forwards;
}

@keyframes seekPulse {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }

    30% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) scale(1);
    }
}

/* ========== UNMUTE OVERLAY BUTTON ========== */
.unmute-overlay {
    display: none;
    position: absolute;
    bottom: 60px;
    left: 12px;
    transform: none;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    z-index: 55;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    animation: unmutePulse 2s ease-in-out infinite;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.unmute-overlay.visible {
    display: flex;
    align-items: center;
    gap: 5px;
}

.unmute-overlay:active {
    transform: scale(0.95);
}

.unmute-overlay svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

@keyframes unmutePulse {

    0%,
    100% {
        opacity: 0.85;
    }

    50% {
        opacity: 1;
    }
}

/* ========== MOBILE CENTER BUTTON ========== */
.mobile-center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    padding: 16px;
    cursor: pointer;
    z-index: 50;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: background 0.2s ease, transform 0.1s ease;
}

.mobile-center-btn:active {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(0.95);
}

.mobile-center-btn svg {
    display: block;
}