/*!
 * TVP Player – Public CSS v2.0.0
 * KEY FIX: All variables scoped to .tvp-player-container (not :root)
 *          Full CSS reset inside .tvp-player-container to survive any theme
 * @package TVP_Player
 */

/* ══════════════════════════════════════════════════════════════════════════════
   1. Scoped CSS variables (theme tokens – never pollute :root)
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-player-container {
    --tvp-accent:      #f00;
    --tvp-accent-h:    #c00;
    --tvp-bg:          #0f0f0f;
    --tvp-surface:     #1a1a1a;
    --tvp-surface2:    #242424;
    --tvp-border:      #303030;
    --tvp-text:        #fff;
    --tvp-muted:       #aaa;
    --tvp-radius:      6px;
    --tvp-trans:       .2s ease;
    --tvp-shadow:      0 4px 24px rgba(0,0,0,.55);
}

/* Theme variants */
.tvp-player-container.tvp-theme-light {
    --tvp-bg:#f5f5f5; --tvp-surface:#fff; --tvp-surface2:#eee;
    --tvp-border:#ddd; --tvp-text:#111; --tvp-muted:#555;
}
.tvp-player-container.tvp-theme-red  { --tvp-accent:#e11; --tvp-accent-h:#900; }
.tvp-player-container.tvp-theme-blue { --tvp-accent:#1a73e8; --tvp-accent-h:#1558b0; }

/* ══════════════════════════════════════════════════════════════════════════════
   2. CSS Reset – neutralise theme interference INSIDE the player wrapper
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-player-container,
.tvp-player-container *,
.tvp-player-container *::before,
.tvp-player-container *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.tvp-player-container {
    /* Block-level, full width, no collapse */
    display: block;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    background: #000;
    border-radius: var(--tvp-radius);
    box-shadow: var(--tvp-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: var(--tvp-text);
    /* Isolate stacking context so overlays work regardless of theme z-index */
    isolation: isolate;
}

/* ══════════════════════════════════════════════════════════════════════════════
   3. Video.js player – scoped overrides
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-player-container .video-js {
    display: block !important;
    width: 100% !important;
    /* Aspect ratio via padding hack (universal browser support) */
    height: 0 !important;
    padding-top: 56.25% !important; /* 16:9 */
    position: relative;
    background: #000;
    overflow: hidden;
}

/* Restore internal elements inside video-js */
.tvp-player-container .video-js .vjs-tech,
.tvp-player-container .video-js video {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.tvp-player-container .vjs-big-play-button {
    background: var(--tvp-accent) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 64px !important;
    height: 64px !important;
    line-height: 64px !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    transition: background var(--tvp-trans), transform var(--tvp-trans) !important;
    margin: 0 !important;
}
.tvp-player-container .vjs-big-play-button:hover,
.tvp-player-container .vjs-big-play-button:focus {
    background: var(--tvp-accent-h) !important;
    transform: translate(-50%, -50%) scale(1.1) !important;
    outline: none !important;
}

.tvp-player-container .vjs-control-bar {
    background: linear-gradient(to top, rgba(0,0,0,.85) 0%, transparent 100%) !important;
    height: 44px !important;
    padding: 0 8px !important;
    display: flex !important;
    align-items: center !important;
    bottom: 0 !important;
}

.tvp-player-container .vjs-play-progress,
.tvp-player-container .vjs-volume-level {
    background: var(--tvp-accent) !important;
}

.tvp-player-container .vjs-progress-control { flex: 1 !important; }
.tvp-player-container .vjs-slider:focus { outline: none !important; box-shadow: none !important; }
.tvp-player-container .vjs-playback-rate .vjs-playback-rate-value { font-size: 12px !important; }
.tvp-player-container .vjs-menu-button-popup .vjs-menu { z-index: 999 !important; }

/* ══════════════════════════════════════════════════════════════════════════════
   4. Lazy poster overlay
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-lazy-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    outline: none;
    border: none;
    padding: 0;
    /* Maintain 16:9 even before JS loads */
    aspect-ratio: 16 / 9;
    width: 100%;
}
/* Fallback for older browsers */
@supports not (aspect-ratio: 16 / 9) {
    .tvp-lazy-overlay::before {
        content: '';
        display: block;
        padding-top: 56.25%;
    }
}

.tvp-lazy-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}
.tvp-lazy-overlay:hover .tvp-lazy-poster,
.tvp-lazy-overlay:focus .tvp-lazy-poster {
    transform: scale(1.03);
}

.tvp-big-play {
    position: relative;
    z-index: 2;
    transition: transform var(--tvp-trans);
    filter: drop-shadow(0 2px 12px rgba(0,0,0,.7));
    /* Prevent theme float/margin overrides */
    float: none !important;
    margin: 0 !important;
}
.tvp-lazy-overlay:hover .tvp-big-play,
.tvp-lazy-overlay:focus .tvp-big-play {
    transform: scale(1.12);
}

.tvp-hd-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--tvp-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
    letter-spacing: .5px;
    line-height: 1.2;
    z-index: 3;
}

/* ══════════════════════════════════════════════════════════════════════════════
   5. Embed wrapper (YouTube / Vimeo / Dailymotion)
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-embed-wrap {
    position: relative;
    width: 100%;
    height: 0;
    padding-top: 56.25%; /* 16:9 */
    overflow: hidden;
    background: #000;
}
.tvp-embed-wrap iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   6. No-video placeholder
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-no-video {
    background: #111;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tvp-no-video-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--tvp-muted);
    text-align: center;
    padding: 20px;
}
.tvp-no-video-inner p { font-size: 13px; margin: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   7. Ad overlay
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-ad-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(0,0,0,.88);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 12px 16px;
    pointer-events: none;
}
.tvp-ad-overlay:not([hidden]) { display: flex; }

.tvp-ad-label {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: .5px;
    pointer-events: none;
}

.tvp-skip-btn {
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,.7);
    color: #fff;
    border: 1px solid rgba(255,255,255,.4);
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    margin-left: auto;
    pointer-events: all;
    transition: background var(--tvp-trans);
    font-family: inherit;
    line-height: 1;
}
.tvp-skip-btn:hover { background: rgba(255,255,255,.2); }
.tvp-skip-btn:not([hidden]) { display: flex; }

.tvp-skip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tvp-accent);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   8. Autoplay overlay
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-autoplay-overlay {
    position: absolute;
    inset: 0;
    z-index: 25;
    background: rgba(0,0,0,.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    padding: 20px;
    gap: 8px;
}
.tvp-autoplay-overlay:not([hidden]) { display: flex; }
.tvp-up-next {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: .7;
    margin: 0;
}
.tvp-next-title {
    font-size: 15px;
    font-weight: 600;
    max-width: 300px;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tvp-countdown-wrap {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}
.tvp-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.tvp-ring-bg   { fill: none; stroke: rgba(255,255,255,.2); stroke-width: 4; }
.tvp-ring-fill {
    fill: none;
    stroke: var(--tvp-accent);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 113;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}
.tvp-count-num {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}
.tvp-cancel-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: 6px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: background var(--tvp-trans);
    margin-top: 4px;
}
.tvp-cancel-btn:hover { background: rgba(255,255,255,.15); }

/* ══════════════════════════════════════════════════════════════════════════════
   9. Like / Dislike vote bar
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-vote-bar {
    display: block;
    margin: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    /* Reset any theme margin/padding */
    padding: 0;
    border: none;
    background: none;
}
.tvp-vote-buttons {
    display: inline-flex;
    align-items: stretch;
    border-radius: 50px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.15);
    background: rgba(0,0,0,.06);
}
/* Light fallback */
@media (prefers-color-scheme: light) {
    .tvp-vote-buttons { border-color: #ddd; background: #f5f5f5; }
}
.tvp-btn-vote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    transition: background var(--tvp-trans);
}
.tvp-btn-vote:hover { background: rgba(0,0,0,.08); }
.tvp-btn-vote.active { background: rgba(0,0,0,.12); }
.tvp-vote-icon { font-size: 16px; line-height: 1; }
.tvp-vote-divider { width: 1px; background: rgba(0,0,0,.15); align-self: stretch; flex-shrink: 0; }
.tvp-vote-progress {
    height: 3px;
    background: rgba(0,0,0,.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    max-width: 280px;
}
.tvp-vote-bar-fill {
    height: 100%;
    background: #f00;
    border-radius: 2px;
    transition: width .4s ease;
    min-width: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   10. View count badge
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-view-count {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #888;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 8px 0;
    padding: 0;
    border: none;
    background: none;
}

/* ══════════════════════════════════════════════════════════════════════════════
   11. Playlist
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-playlist {
    background: var(--tvp-surface, #1a1a1a);
    border-radius: var(--tvp-radius, 6px);
    overflow: hidden;
    border: 1px solid var(--tvp-border, #303030);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--tvp-text, #fff);
    margin: 0;
    padding: 0;
}
.tvp-playlist-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--tvp-border, #303030);
    font-weight: 600;
    font-size: 14px;
}
.tvp-pl-icon  { color: var(--tvp-accent, #f00); font-size: 11px; }
.tvp-pl-count { margin-left: auto; font-size: 12px; background: rgba(255,255,255,.1); border-radius: 50px; padding: 1px 8px; color: var(--tvp-muted, #aaa); }
.tvp-pl-items { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.tvp-pl-items::-webkit-scrollbar { width: 4px; }
.tvp-pl-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
.tvp-pl-item { border-bottom: 1px solid var(--tvp-border, #303030); }
.tvp-pl-item:last-child { border-bottom: none; }
.tvp-pl-item.is-active { background: rgba(255,255,255,.06); }
.tvp-pl-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none !important;
    color: inherit !important;
    transition: background var(--tvp-trans, .2s ease);
}
.tvp-pl-link:hover { background: rgba(255,255,255,.05); }
.tvp-pl-thumb {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
}
.tvp-pl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tvp-pl-nothumb { width: 100%; height: 100%; background: var(--tvp-surface2, #242424); }
.tvp-pl-dur {
    position: absolute;
    bottom: 4px; right: 4px;
    background: rgba(0,0,0,.85); color: #fff;
    font-size: 11px; font-weight: 600;
    padding: 1px 5px; border-radius: 3px; line-height: 1.4;
}
.tvp-pl-hd {
    position: absolute;
    top: 4px; left: 4px;
    background: var(--tvp-accent, #f00); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 1px 4px; border-radius: 2px; letter-spacing: .5px; line-height: 1.4;
}
.tvp-pl-play {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.45); color: #fff; font-size: 18px;
    opacity: 0; transition: opacity var(--tvp-trans, .2s ease);
}
.tvp-pl-link:hover .tvp-pl-play { opacity: 1; }
.tvp-pl-info { flex: 1; overflow: hidden; min-width: 0; }
.tvp-pl-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--tvp-text, #fff);
    margin: 0;
}
.tvp-pl-views {
    display: block;
    font-size: 11px;
    color: var(--tvp-muted, #aaa);
    margin-top: 4px;
}
.tvp-pl-empty { padding: 20px; color: var(--tvp-muted, #aaa); font-size: 13px; }

/* ══════════════════════════════════════════════════════════════════════════════
   12. Trending grid
   ══════════════════════════════════════════════════════════════════════════════ */

.tvp-trending {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 24px 0;
}
.tvp-trending-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    padding: 0;
    border: none;
    color: inherit;
}
.tvp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.tvp-card {
    background: var(--tvp-surface, #1a1a1a);
    border-radius: var(--tvp-radius, 6px);
    overflow: hidden;
    transition: transform var(--tvp-trans, .2s ease), box-shadow var(--tvp-trans, .2s ease);
}
.tvp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.tvp-card-thumb-a { display: block; text-decoration: none; }
.tvp-card-thumb-wrap {
    position: relative;
    width: 100%;
    height: 0;
    padding-top: 56.25%;
    overflow: hidden;
    background: #000;
}
.tvp-card-img {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform var(--tvp-trans, .2s ease);
    display: block;
}
.tvp-card:hover .tvp-card-img { transform: scale(1.04); }
.tvp-card-nothumb { position: absolute; inset: 0; background: var(--tvp-surface2, #242424); }
.tvp-card-dur {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,.85); color: #fff;
    font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 3px;
}
.tvp-card-hd {
    position: absolute; top: 6px; left: 6px;
    background: var(--tvp-accent, #f00); color: #fff;
    font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 2px;
}
.tvp-card-hover {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; color: #fff;
    background: rgba(0,0,0,.4);
    opacity: 0; transition: opacity var(--tvp-trans, .2s ease);
}
.tvp-card:hover .tvp-card-hover { opacity: 1; }
.tvp-card-info { padding: 10px 12px; }
.tvp-card-title {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 600;
    padding: 0;
    border: none;
    color: inherit;
}
.tvp-card-title a {
    color: inherit;
    text-decoration: none;
}
.tvp-card-title a:hover { color: var(--tvp-accent, #f00); }
.tvp-card-views { font-size: 11px; color: var(--tvp-muted, #aaa); }

/* ══════════════════════════════════════════════════════════════════════════════
   13. Responsive
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .tvp-pl-thumb { width: 100px; height: 56px; }
    .tvp-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .tvp-btn-vote { padding: 7px 12px; }
    .tvp-big-play svg { width: 60px; height: 60px; }
}
@media (max-width: 480px) {
    .tvp-pl-thumb { width: 88px; height: 50px; }
    .tvp-next-title { font-size: 13px; }
    .tvp-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media (max-width: 360px) {
    .tvp-grid { grid-template-columns: 1fr; }
}
