/* ==========================================================================
   Crunchyroll "Vilos" Player Theme & Controls
   High-performance, modern, cinematic streaming UI
   ========================================================================== */

:root {
    --vilos-primary: #ff640a;
    --vilos-primary-glow: rgba(255, 100, 10, 0.55);
    --vilos-primary-light: #ff8533;
    --vilos-bg: #000000;
    --vilos-overlay-bg: rgba(14, 15, 20, 0.88);
    --vilos-panel-bg: rgba(20, 21, 26, 0.95);
    --vilos-text: #ffffff;
    --vilos-text-dim: #a0a0a0;
    --vilos-bar-bg: rgba(255, 255, 255, 0.25);
    --vilos-buffered: rgba(255, 255, 255, 0.45);
    --vilos-font: 'Crunchyroll Atyp', 'Atyp BL Text', 'Atyp', 'Outfit', 'Poppins', -apple-system, sans-serif;
}

body.vilos-active {
    margin: 0;
    padding: 0;
    background: #000;
    overflow: hidden;
    font-family: var(--vilos-font);
    user-select: none;
    -webkit-user-select: none;
}

/* Player Container */
.vilos-player-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vilos-player-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.vilos-player-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Auto-hide UI layer */
.vilos-ui-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.35s cubic-bezier(0.2, 0, 0, 1), visibility 0.35s;
    pointer-events: none;
}

.vilos-player-wrapper.user-inactive.is-playing .vilos-ui-overlay {
    opacity: 0;
    visibility: hidden;
}

.vilos-player-wrapper.user-inactive.is-playing {
    cursor: none;
}

.vilos-ui-overlay * {
    pointer-events: auto;
}

/* Gradient Shadows */
.vilos-top-bar {
    padding: 20px 30px;
    background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vilos-bottom-bar {
    padding: 0 30px 20px 30px;
    background: linear-gradient(0deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 65%, rgba(0,0,0,0) 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Top Bar Details */
.vilos-back-btn {
    color: #fff;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    transition: all 0.25s ease;
}

.vilos-back-btn:hover {
    background: var(--vilos-primary);
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 0 16px var(--vilos-primary-glow);
}

.vilos-video-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-left: 20px;
    flex-grow: 1;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vilos-brand-logo img {
    height: 38px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.8));
}

/* Scrubber / Progress Bar (Crunchyroll Signature Orange) */
.vilos-progress-container {
    position: relative;
    width: 100%;
    height: 18px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.vilos-progress-bar {
    position: relative;
    width: 100%;
    height: 5px;
    background: var(--vilos-bar-bg);
    border-radius: 4px;
    transition: height 0.15s ease;
}

.vilos-progress-container:hover .vilos-progress-bar {
    height: 8px;
}

.vilos-progress-buffered {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--vilos-buffered);
    border-radius: 4px;
}

.vilos-progress-played {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, #ff640a 0%, #ff8c37 100%);
    border-radius: 4px;
    box-shadow: 0 0 10px var(--vilos-primary-glow);
}

/* Scrubber Thumb */
.vilos-scrubber-thumb {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 12px var(--vilos-primary), 0 2px 6px rgba(0,0,0,0.6);
    border: 2px solid var(--vilos-primary);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.vilos-progress-container:hover .vilos-scrubber-thumb {
    transform: translateY(-50%) scale(1);
}

/* Time Tooltip on Hover */
.vilos-time-tooltip {
    position: absolute;
    bottom: 25px;
    transform: translateX(-50%);
    background: rgba(14, 15, 20, 0.95);
    border: 1px solid rgba(255, 100, 10, 0.4);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.vilos-progress-container:hover .vilos-time-tooltip {
    opacity: 1;
}

/* Controls Row */
.vilos-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vilos-controls-left,
.vilos-controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Control Buttons */
.vilos-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.vilos-btn:hover {
    color: var(--vilos-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}

.vilos-btn:active {
    transform: scale(0.95);
}

.vilos-play-btn {
    font-size: 22px;
}

/* Volume Control */
.vilos-volume-group {
    display: flex;
    align-items: center;
    position: relative;
}

.vilos-volume-slider-wrap {
    width: 0;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    align-items: center;
}

.vilos-volume-group:hover .vilos-volume-slider-wrap {
    width: 80px;
    margin-left: 6px;
    margin-right: 8px;
}

.vilos-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    cursor: pointer;
}

.vilos-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--vilos-primary);
    box-shadow: 0 0 8px var(--vilos-primary-glow);
    cursor: pointer;
}

/* Time Display */
.vilos-time-display {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-left: 8px;
    letter-spacing: 0.5px;
}

.vilos-time-separator {
    color: var(--vilos-text-dim);
    margin: 0 4px;
}

.vilos-duration {
    color: var(--vilos-text-dim);
}

/* Big Central Play Button */
.vilos-center-action {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: rgba(14, 15, 20, 0.85);
    border: 2px solid var(--vilos-primary);
    box-shadow: 0 0 35px var(--vilos-primary-glow), 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 36px;
    cursor: pointer;
    transition: transform 0.3s var(--vilos-primary-glow), background 0.3s ease;
    z-index: 8;
    pointer-events: auto;
}

.vilos-center-action:hover {
    transform: translate(-50%, -50%) scale(1.12);
    background: var(--vilos-primary);
}

.vilos-player-wrapper.is-playing .vilos-center-action {
    display: none;
}

/* Loading Buffering Spinner */
.vilos-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top: 4px solid var(--vilos-primary);
    border-radius: 50%;
    animation: vilos-spin 0.8s linear infinite;
    z-index: 7;
    display: none;
    pointer-events: none;
}

.vilos-player-wrapper.is-buffering .vilos-spinner {
    display: block;
}

@keyframes vilos-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Next Episode Pill Button */
.vilos-next-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 100, 10, 0.2);
    border: 1.5px solid var(--vilos-primary);
    color: #fff !important;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    transition: all 0.25s ease;
}

.vilos-next-btn:hover {
    background: var(--vilos-primary);
    box-shadow: 0 0 18px var(--vilos-primary-glow);
    transform: scale(1.05);
}

/* Settings Menu Popovers (Quality, Subtitles, Speed) */
.vilos-menu-popup {
    position: absolute;
    bottom: 75px;
    right: 30px;
    background: var(--vilos-panel-bg);
    border: 1px solid rgba(255, 100, 10, 0.4);
    border-radius: 10px;
    padding: 10px 0;
    min-width: 180px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.85);
    backdrop-filter: blur(14px);
    display: none;
    z-index: 30;
}

.vilos-menu-popup.is-open {
    display: block;
    animation: vilos-fade-up 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes vilos-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.vilos-menu-header {
    padding: 6px 16px 10px 16px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--vilos-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: 0.5px;
}

.vilos-menu-item {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s, color 0.2s;
    text-decoration: none !important;
}

.vilos-menu-item:hover {
    background: rgba(255, 100, 10, 0.15);
    color: #ffffff;
}

.vilos-menu-item.is-selected {
    color: var(--vilos-primary);
    font-weight: 800;
}

.vilos-menu-item.is-selected::after {
    content: '✓';
    font-size: 14px;
    color: var(--vilos-primary);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .vilos-top-bar {
        padding: 12px 16px;
    }
    .vilos-bottom-bar {
        padding: 0 16px 14px 16px;
    }
    .vilos-video-title {
        font-size: 14px;
        margin-left: 10px;
    }
    .vilos-brand-logo img {
        height: 28px;
    }
    .vilos-volume-group {
        display: none;
    }
    .vilos-time-display {
        font-size: 11px;
    }
    .vilos-center-action {
        width: 64px;
        height: 64px;
        font-size: 26px;
    }
}

/* ==========================================================================
   Live Streaming Additions
   ========================================================================== */
.vilos-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: #e50914;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.8px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.6);
    animation: vilos-live-pulse 1.8s infinite;
}

.vilos-live-badge i {
    font-size: 8px;
}

@keyframes vilos-live-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.98); }
}

.vilos-player-wrapper.is-live .vilos-progress-container,
.vilos-player-wrapper.is-live .vilos-rewind-btn,
.vilos-player-wrapper.is-live .vilos-forward-btn,
.vilos-player-wrapper.is-live .vilos-duration,
.vilos-player-wrapper.is-live .vilos-time-separator {
    display: none !important;
}

/* ==========================================================================
   DRM Dynamic Anti-Capture Watermark
   ========================================================================== */
.vilos-drm-watermark {
    position: absolute;
    top: 20%;
    left: 20%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.16);
    font-size: 11px;
    font-family: monospace;
    font-weight: 700;
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 9;
    user-select: none;
    transition: top 2.5s cubic-bezier(0.2, 0.8, 0.2, 1), left 2.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.85);
}
