/**
 * M2F-PORN-V1 HLS Player Styles
 * Original pink accent player theme
 *
 * @package M2F-PORN-V1
 * @since 1.0.0
 */

:root {
    --player-bg: #08080c;
    --player-radius: 10px;
    /* fallback สำหรับ player.css — ใช้ --accent-neon ของ theme ถ้ามี */
    --accent: var(--accent-neon, #ff2d75);
    --accent-rgb: 255, 45, 117;
}

/* ===== Player Section ===== */
.player-section {
    margin-bottom: 24px;
}

#m2f-hls-player {
    position: relative;
    background-color: #000;
    border-radius: var(--player-radius);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    width: 100%;
}

#m2f-video-player {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#m2f-video-player::-webkit-media-controls-loading-indicator,
#m2f-video-player::-webkit-media-controls-buffering-indicator {
    display: none !important;
}

/* Play overlay */
.m2f-play-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center center;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.m2f-play-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    transition: background 0.3s ease;
}

.m2f-play-overlay:hover::before {
    background: rgba(0, 0, 0, 0.2);
}

.m2f-play-overlay svg {
    position: relative;
    z-index: 11;
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 4px 16px rgba(var(--accent-rgb), 0.35));
    transform: scale(1);
    opacity: 1;
    transition: opacity 0.25s ease, transform 0.2s ease;
}

.m2f-play-overlay:hover svg {
    transform: scale(1.1);
}

.m2f-play-overlay.m2f-loading svg {
    opacity: 0;
    transform: scale(0.7);
}

.m2f-play-overlay.m2f-fade-out {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.m2f-play-overlay.m2f-fade-out svg,
.m2f-play-overlay.m2f-fade-out::before {
    opacity: 0 !important;
    transition: opacity 0.15s ease;
}

/* Loading spinner */
.m2f-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    z-index: 12;
    opacity: 0;
    visibility: hidden;
    animation: m2f-spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease 0.12s, visibility 0.3s ease 0.12s;
}

.m2f-loading-spinner.active {
    opacity: 1;
    visibility: visible;
}

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

/* Player logo */
.m2f-player-logo {
    position: absolute;
    top: 20px;
    right: 10px;
    z-index: 15;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.m2f-player-logo img {
    max-height: 50px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

#m2f-hls-player.playing:hover .m2f-player-logo {
    opacity: 0.9;
}

@media (max-width: 1024px) {
    .m2f-player-logo {
        top: 8px;
        right: 6px;
    }
    .m2f-player-logo img {
        max-height: 32px;
    }
}

@media (max-width: 639px) {
    .m2f-player-logo {
        top: 6px;
        right: 4px;
    }
    .m2f-player-logo img {
        max-height: 24px;
    }
}

/* Custom control bar */
.m2f-control-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#m2f-hls-player.playing .m2f-control-bar {
    pointer-events: auto;
}

#m2f-hls-player.playing .m2f-control-bar.m2f-show,
#m2f-hls-player.playing .m2f-control-bar:active,
#m2f-hls-player.playing.m2f-paused .m2f-control-bar {
    opacity: 1;
}

.m2f-ctrl-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    flex-shrink: 0;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.m2f-ctrl-btn:hover {
    color: var(--accent);
}

.m2f-ctrl-time,
.m2f-ctrl-duration {
    color: #fff;
    font-size: 0.8rem;
    flex-shrink: 0;
    min-width: 40px;
    text-align: center;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Center play/pause button */
.m2f-center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    cursor: pointer;
    z-index: 14;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.m2f-center-btn.m2f-center-show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.m2f-center-btn svg circle {
    fill: rgba(0, 0, 0, 0.5);
    transition: fill 0.2s ease;
}

.m2f-center-btn:hover svg circle {
    fill: rgba(var(--accent-rgb), 0.7);
}

/* Skip buttons */
.m2f-ctrl-skip-back,
.m2f-ctrl-skip-fwd {
    padding: 0 4px;
}

.m2f-ctrl-skip-back svg,
.m2f-ctrl-skip-fwd svg {
    width: 18px;
    height: 18px;
}

/* Volume control — vertical slider via rotate */
.m2f-ctrl-volume-wrap {
    position: relative;
    flex-shrink: 0;
}

.m2f-ctrl-volume {
    padding: 0 4px;
}

.m2f-ctrl-volume svg {
    width: 18px;
    height: 18px;
}

.m2f-ctrl-volume-slider {
    position: absolute;
    bottom: calc(100% + 37px);
    left: 50%;
    width: 80px;
    height: 5px;
    margin: 0;
    transform: translateX(-50%) rotate(-90deg);
    transform-origin: 50% 50%;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 20;
}

.m2f-ctrl-volume-wrap:hover .m2f-ctrl-volume-slider,
.m2f-ctrl-volume-slider:focus {
    opacity: 1;
    pointer-events: auto;
}

.m2f-ctrl-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: -80px 0 0 75px var(--accent);
}

.m2f-ctrl-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

.m2f-ctrl-volume-slider::-moz-range-progress {
    background: var(--accent);
    height: 5px;
    border-radius: 3px;
}

/* Quality selector */
.m2f-ctrl-quality-wrap {
    position: relative;
    flex-shrink: 0;
}

.m2f-ctrl-quality {
    min-width: 36px;
    font-size: 0.75rem;
    font-weight: bold;
}

.m2f-quality-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 80px;
    z-index: 20;
}

.m2f-quality-menu.m2f-quality-open {
    display: block;
}

.m2f-quality-item {
    padding: 8px 16px;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: background 0.2s;
}

.m2f-quality-item:hover {
    background: rgba(var(--accent-rgb), 0.25);
}

.m2f-quality-item.active {
    color: var(--accent);
    font-weight: bold;
}

/* Seek bar */
.m2f-ctrl-seek {
    flex: 1;
    height: 5px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    background-image: linear-gradient(to right, var(--accent) 0%, var(--accent) 0%, transparent 0%, transparent 100%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.m2f-ctrl-seek.m2f-buffered {
    background-image: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--seek-pct, 0%), rgba(255, 255, 255, 0.5) var(--seek-pct, 0%), rgba(255, 255, 255, 0.5) var(--buffer-pct, 0%), transparent var(--buffer-pct, 0%), transparent 100%);
}

.m2f-ctrl-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
}

.m2f-ctrl-seek::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
}

/* Fullscreen */
#m2f-hls-player:fullscreen {
    border-radius: 0;
    aspect-ratio: auto;
    height: 100vh;
}

#m2f-hls-player:fullscreen #m2f-video-player {
    height: 100vh;
}

/* Error / no video message */
.error-message,
.no-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    z-index: 20;
}

@media (max-width: 640px) {
    .m2f-play-overlay svg {
        width: 64px;
        height: 64px;
    }

    .m2f-control-bar {
        padding: 8px;
        gap: 4px;
    }

    .m2f-ctrl-btn {
        padding: 0 4px;
    }

    .m2f-ctrl-time,
    .m2f-ctrl-duration {
        min-width: 30px;
        font-size: 0.7rem;
    }

    .m2f-ctrl-seek {
        min-width: 0;
        flex: 1 1 0;
    }

    .m2f-ctrl-quality {
        min-width: 30px;
    }

    .m2f-ctrl-volume-slider {
        width: 60px;
        bottom: calc(100% + 27px);
    }

    .m2f-ctrl-volume-slider::-webkit-slider-thumb {
        box-shadow: -60px 0 0 55px var(--accent);
    }
}

/* ===== Video Ad Overlay ===== */
.m2f-video-ad-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.m2f-video-ad-player {
    object-fit: contain;
    width: 100%;
    height: 100%;
}

.m2f-video-ad-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    z-index: 51;
}

.m2f-video-ad-label {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.m2f-video-ad-countdown {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0,0,0,0.5);
    padding: 5px 12px;
    border-radius: 4px;
}

.m2f-video-ad-skip {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.m2f-video-ad-skip:hover {
    background: rgba(255,255,255,0.25);
}
