/* Modern Video Player Controls */

/* Suppress native browser video controls */
#video-player-wrapper video::-webkit-media-controls { display: none !important; }
#video-player-wrapper video::-webkit-media-controls-enclosure { display: none !important; }
#video-player-wrapper video::-webkit-media-controls-panel { display: none !important; }
#ad-container video::-webkit-media-controls { display: none !important; }
#ad-container video::-webkit-media-controls-enclosure { display: none !important; }
#ad-container video::-webkit-media-controls-panel { display: none !important; }

#video-player-wrapper .hidden {
    display: none !important;
}

.custom-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 50%, transparent 100%);
    padding: 4px 4px 4px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.custom-video-controls.hidden-controls {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.hide-cursor { cursor: none; }

/* ========== Progress Bar ========== */
.control-progress-wrapper {
    position: relative;
    margin-bottom: 6px;
    height: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.control-progress-bg {
    position: absolute;
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    overflow: hidden;
    top: 50%;
    transform: translateY(-50%);
    transition: height 0.15s ease;
}

.control-progress-buffered {
    position: absolute;
    height: 100%;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 2px;
    width: 0%;
    transition: width 0.2s ease;
}

.control-progress-played {
    position: absolute;
    height: 100%;
    background: #EF4444;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.control-progress-seek {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    z-index: 2;
}

.control-progress-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    opacity: 1;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.control-progress-seek::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    opacity: 1;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.control-progress-seek:active::-webkit-slider-thumb { transform: scale(1.5); }
.control-progress-seek:active::-moz-range-thumb { transform: scale(1.5); }

/* Seek Tooltip */
.control-progress-tooltip {
    position: absolute;
    bottom: 100%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Roboto Condensed', sans-serif;
    pointer-events: none;
    white-space: nowrap;
    margin-bottom: 4px;
    z-index: 15;
}

/* ========== Control Buttons ========== */
.control-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.control-buttons-left,
.control-buttons-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.15s ease;
    position: relative;
}

.control-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.18);
}

.control-btn:focus-visible {
    outline: 2px solid #EF4444;
    outline-offset: 2px;
}

.control-icon {
    width: 20px;
    height: 20px;
    fill: white;
    stroke: white;
    stroke-width: 0;
}

.control-icon path {
    transform: scale(1.3);
    transform-origin: center center;
}

.control-seek-label {
    font-size: 11px;
    font-weight: bold;
    position: absolute;
    bottom: 50%;
    transform: translateY(50%);
}

#rewind-btn .control-seek-label { right: 6px; }
#forward-btn .control-seek-label { left: 6px; }

/* ========== Volume ========== */
.control-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.control-volume-slider {
    width: 0;
    opacity: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.control-volume-wrapper:hover .control-volume-slider,
.control-volume-wrapper.volume-expanded .control-volume-slider {
    width: 80px;
    opacity: 1;
}

.control-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.control-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
}

/* ========== Time Display ========== */
.control-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Roboto Condensed', sans-serif;
    color: white;
    padding: 0 4px;
    user-select: none;
    letter-spacing: 0.02em;
}

.control-time-separator { opacity: 0.6; }

/* ========== Quality Selector ========== */
.control-quality-wrapper { position: relative; }

.control-quality-label {
    font-size: 12px;
    font-weight: 600;
    font-family: 'Roboto Condensed', sans-serif;
    margin-left: 2px;
    letter-spacing: 0.03em;
}

.control-quality-menu {
    position: absolute;
    bottom: 40px;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 8px;
    padding: 8px;
    min-width: 100px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.quality-option {
    display: block;
    width: 100%;
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.quality-option.active {
    color: #EF4444;
    font-weight: 600;
}

.quality-bandwidth {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    padding: 2px 10px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 4px;
    min-height: 18px;
}

/* ========== Speed Selector ========== */
.control-speed-wrapper { position: relative; }

.control-speed-label {
    font-size: 14px;
    font-weight: 700;
    color: white;
    font-family: 'Roboto Condensed', sans-serif;
}

.control-speed-menu {
    position: absolute;
    bottom: 40px;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    border-radius: 8px;
    padding: 8px;
    min-width: 100px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.speed-option {
    display: block;
    width: 100%;
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.speed-option.active {
    color: #EF4444;
    font-weight: 600;
}

/* ========== Seek Feedback (Double-tap) ========== */
.seek-feedback {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 28px;
    font-weight: 700;
    pointer-events: none;
    z-index: 9;
    animation: fadeInOut 0.6s ease forwards;
}
.seek-feedback-left { left: 20%; }
.seek-feedback-right { right: 20%; }

/* ========== Error State ========== */
.video-error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.video-error-content {
    text-align: center;
    color: white;
}

.video-error-message {
    margin: 16px 0;
    font-size: 16px;
    opacity: 0.9;
}

.video-error-retry {
    padding: 10px 28px;
    background: #EF4444;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.video-error-retry:hover {
    background: #DC2626;
}

/* ========== End State (Replay) ========== */
.video-end-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.video-replay-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: transform 0.2s;
}

.video-replay-btn:hover {
    transform: scale(1.1);
}

/* ========== Loading Spinner ========== */
.video-spinner-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 8;
    pointer-events: none;
}

.video-spinner-overlay.hidden { display: none !important; }

.video-loading.hidden { display: none !important; }

.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 5;
}

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

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
    50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.9); }
}

/* ========== Big Play Button ========== */
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 5;
    box-shadow: 0 8px 24px rgba(var(--primary-rgb, 233, 30, 99), 0.4);
}

.video-play-overlay:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 12px 32px rgba(var(--primary-rgb, 233, 30, 99), 0.6);
}

.video-play-overlay svg {
    width: 32px;
    height: 32px;
    fill: white;
    margin-left: 4px;
}

.video-play-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
    .control-time { font-size: 12px; }

    .control-btn {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    .control-icon { width: 20px; height: 20px; }

    .control-volume-wrapper:hover .control-volume-slider,
    .control-volume-wrapper.volume-expanded .control-volume-slider {
        width: 60px;
    }

    .control-quality-label { display: none; }

    .control-progress-wrapper {
        height: 24px;
    }

    .control-progress-bg {
        height: 6px;
    }

    .control-progress-tooltip { display: none; }
}

/* ========== Fullscreen ========== */
:fullscreen .custom-video-controls,
:-webkit-full-screen .custom-video-controls,
:-moz-full-screen .custom-video-controls {
    padding: 30px 20px 20px;
}

:fullscreen .control-btn,
:-webkit-full-screen .control-btn,
:-moz-full-screen .control-btn {
    padding: 10px;
}

:fullscreen .control-icon,
:-webkit-full-screen .control-icon,
:-moz-full-screen .control-icon {
    width: 22px;
    height: 22px;
}

/* Focus indicators */
.control-progress-seek:focus-visible {
    outline: 2px solid #EF4444;
    outline-offset: 2px;
}
