/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========== 播放器容器 ========== */
.player-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
    overflow: hidden;
    transition: transform 0.3s ease;
}

/* ========== 视频元素 ========== */
.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ========== Logo ========== */
.player-logo {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    z-index: 10;
    pointer-events: none;
    letter-spacing: 2px;
}

/* ========== 播放前提示 ========== */
.play-hint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    cursor: pointer;
    transition: opacity 0.3s;
}

.play-hint.hide {
    opacity: 0;
    pointer-events: none;
}

.hint-content {
    text-align: center;
}

/* ========== 上次观看位置提示 ========== */
.resume-position {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 30px;
    backdrop-filter: blur(20px);
    animation: fadeIn 0.3s ease;
}

.resume-text {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

.resume-text span {
    color: #667eea;
    font-weight: 600;
}

.resume-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.resume-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.resume-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.resume-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.resume-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.play-btn {
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease;
    animation: pulse 2s infinite;
}

.play-btn:hover {
    transform: scale(1.1);
}

.play-btn svg {
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
}

.hint-text {
    margin-top: 20px;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 3px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== 加载广告 ========== */
.loading-ad {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.loading-ad .ad-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-ad .ad-html {
    max-width: 80%;
    max-height: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-ad .ad-html img,
.loading-ad .ad-html video,
.loading-ad .ad-html iframe {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}

.loading-ad .ad-default {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.ad-title {
    font-size: 24px;
    color: #fff;
    margin-bottom: 20px;
    letter-spacing: 2px;
    font-weight: 300;
}

.ad-timer {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== 暂停广告 ========== */
.pause-ad {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(26, 26, 46, 0.98) 0%, rgba(22, 33, 62, 0.98) 100%);
    padding: 12px 20px;
    border-radius: 0 0 12px 12px;
    z-index: 25;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.pause-ad .ad-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    position: relative;
}

.pause-ad .ad-html {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.pause-ad .ad-html img,
.pause-ad .ad-html video {
    max-height: 80px;
    max-width: 200px;
    object-fit: contain;
    border-radius: 4px;
}

.pause-ad .ad-default {
    font-size: var(--pause-ad-font-size, 14px);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.close-ad {
    background: none;
    color: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.2s;
    white-space: nowrap;
    padding: 5px 10px;
    flex-shrink: 0;
}

.close-ad:hover {
    color: #fff;
    transform: scale(1.2);
}

/* ========== 控制条 ========== */
.controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, transparent 100%);
    padding: 10px 20px 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 15;
}

.player-container:hover .controls,
.player-container.show-controls .controls {
    opacity: 1;
}

/* ========== 进度条 ========== */
.progress-bar {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 15px;
    overflow: visible;
}

.progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    pointer-events: none;
}

.progress-current {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.1s linear;
}

.seek-slider {
    position: absolute;
    top: -7px;
    left: 0;
    width: 100%;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    outline: none;
}

.seek-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.8);
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-bar:hover .seek-slider::-webkit-slider-thumb {
    opacity: 1;
}

/* ========== 控制按钮 ========== */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-left,
.controls-center,
.controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

/* 触摸设备上的点击反馈 */
@media (hover: none) and (pointer: coarse) {
    .control-btn:active {
        transform: scale(0.95);
        opacity: 0.7;
    }

    .progress-bar:active .seek-slider::-webkit-slider-thumb {
        transform: scale(1.3);
    }
}

.control-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.icon-pause {
    display: none;
}

.video-player.paused .icon-play {
    display: block;
}

.video-player.paused .icon-pause {
    display: none;
}

.video-player.playing .icon-play {
    display: none;
}

.video-player.playing .icon-pause {
    display: block;
}

.time-display {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    min-width: 100px;
}

#speed-display {
    font-size: 14px;
    font-weight: bold;
}

#quality-display {
    font-size: 14px;
    font-weight: bold;
}

/* ========== 速度菜单 ========== */
.speed-menu {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 8px 0;
    display: none;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.speed-menu.show {
    display: block;
}

.speed-item {
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.speed-item:hover {
    background: rgba(102, 126, 234, 0.5);
}

.speed-item.active {
    background: rgba(102, 126, 234, 0.8);
}

/* ========== 画质菜单 ========== */
.quality-menu {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 8px 0;
    display: none;
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}

.quality-menu.show {
    display: block;
}

.quality-item {
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.quality-item:hover {
    background: rgba(102, 126, 234, 0.5);
}

.quality-item.active {
    background: rgba(102, 126, 234, 0.8);
}

/* ========== 字幕显示 ========== */
video::cue {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
}

/* ========== 截图动画 ========== */
.screenshot-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.screenshot-flash.show {
    animation: flash 0.3s ease;
}

@keyframes flash {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ========== 双击区域提示 ========== */
.double-click-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 50;
}

.double-click-hint.show {
    opacity: 1;
}

.double-click-hint.left {
    left: 40px;
}

.double-click-hint.right {
    right: 40px;
}

/* ========== 音量滑块 ========== */
.volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

/* ========== Toast提示 ========== */
.toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.toast.show {
    opacity: 1;
}

/* ========== 亮度调节层 ========== */
.brightness-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 20px 30px;
    border-radius: 10px;
    display: none;
    z-index: 50;
}

.brightness-overlay.show {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brightness-overlay svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

.brightness-value {
    font-size: 24px;
    font-weight: bold;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .controls {
        padding: 8px 12px 15px;
    }

    .progress-bar {
        height: 4px;
        margin-bottom: 12px;
    }

    .seek-slider {
        top: -8px;
        height: 20px;
    }

    .seek-slider::-webkit-slider-thumb {
        width: 12px;
        height: 12px;
    }

    .controls-row {
        align-items: center;
        gap: 8px;
    }

    .controls-left {
        gap: 8px;
    }

    .controls-center {
        flex: 1;
        gap: 6px;
        justify-content: center;
    }

    .controls-right {
        gap: 6px;
    }

    .control-btn {
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
    }

    .control-btn svg {
        width: 22px;
        height: 22px;
    }

    #speed-display,
    #quality-display {
        font-size: 12px;
        font-weight: 600;
    }

    .time-display {
        font-size: 11px;
        min-width: 85px;
    }

    /* 隐藏音量滑块 */
    .volume-slider {
        display: none;
    }

    .player-logo {
        font-size: 16px;
        top: 12px;
        right: 12px;
    }

    .pause-ad {
        top: 8px;
        left: 8px;
        right: 8px;
        padding: 8px 12px;
    }

    .pause-ad .ad-wrapper {
        gap: 8px;
    }

    .pause-ad .ad-html img,
    .pause-ad .ad-html video {
        max-height: 60px;
        max-width: 150px;
    }

    .close-ad {
        font-size: 20px;
        padding: 8px;
    }

    .resume-position {
        padding: 16px;
        margin: 0 15px;
        margin-bottom: 20px;
    }

    .resume-text {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .resume-actions {
        gap: 10px;
    }

    .resume-btn {
        padding: 10px 18px;
        font-size: 13px;
    }

    /* 确保控制条在手机端显示 */
    .controls {
        opacity: 1 !important;
    }

    /* 按钮行在手机端换行显示 */
    .controls-row {
        flex-wrap: nowrap;
    }
}

/* 小屏手机 (小于375px) */
@media (max-width: 374px) {
    .controls {
        padding: 6px 10px 12px;
    }

    .controls-center {
        gap: 4px;
    }

    .control-btn {
        padding: 4px;
        min-width: 32px;
        min-height: 32px;
    }

    .control-btn svg {
        width: 20px;
        height: 20px;
    }

    /* 小屏隐藏截图和字幕按钮 */
    #btn-screenshot,
    #btn-subtitle {
        display: none;
    }

    #speed-display,
    #quality-display {
        font-size: 11px;
    }

    .time-display {
        font-size: 10px;
        min-width: 70px;
    }

    .resume-text {
        font-size: 13px;
    }

    .resume-btn {
        padding: 8px 14px;
        font-size: 12px;
    }
}

/* 大屏手机/平板 (375px-480px) */
@media (min-width: 375px) and (max-width: 480px) {
    .control-btn svg {
        width: 24px;
        height: 24px;
    }

    #speed-display,
    #quality-display {
        font-size: 13px;
    }

    .time-display {
        font-size: 12px;
    }
}

/* 平板横屏 (大于480px小于768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .control-btn svg {
        width: 26px;
        height: 26px;
    }

    #speed-display,
    #quality-display {
        font-size: 14px;
    }

    .time-display {
        font-size: 13px;
        min-width: 95px;
    }
}

/* 超小屏横屏优化 */
@media (max-width: 374px) and (orientation: landscape) {
    .controls {
        padding: 6px 8px 10px;
    }

    .controls-left,
    .controls-center,
    .controls-right {
        gap: 4px;
    }

    .control-btn {
        padding: 3px;
        min-width: 30px;
        min-height: 30px;
    }

    /* 横屏模式隐藏更多按钮 */
    #btn-pip {
        display: none;
    }

    .resume-position {
        margin: 0 10px;
        padding: 12px;
    }

    .resume-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* 增加触摸目标大小 */
@media (hover: none) and (pointer: coarse) {
    .control-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .control-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* ========== 视频旋转 ========== */
.player-container.rotate-90 {
    transform: rotate(90deg);
}

.player-container.rotate-180 {
    transform: rotate(180deg);
}

.player-container.rotate-270 {
    transform: rotate(270deg);
}

/* ========== 全屏 ========== */
.player-container:fullscreen {
    background: #000;
}

.player-container:-webkit-full-screen {
    background: #000;
}

/* ========== 加载动画 ========== */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.loading-spinner.show {
    display: block;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}
