/* ========================================
   iOS 全屏模式 - 简化修复版本
   ======================================== */

/* 1. 隐藏非视频元素 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen > .header,
body.ios-fullscreen-active .app.player-page.ios-fullscreen > .player-tabs,
body.ios-fullscreen-active .app.player-page.ios-fullscreen > .player-content {
    display: none !important;
}

/* 2. video-container 填满屏幕 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen > .video-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: block !important;
    z-index: 10000 !important;
}

/* 3. 视频元素 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-player {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    object-fit: contain !important;
    z-index: 1 !important;
    background: #000 !important;
}

/* 4. 弹幕容器 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .danmaku-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100vh !important;
    z-index: 2 !important;
    pointer-events: none !important;
}

/* 5. 顶部控件 - 固定在左上角 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-top {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 12px !important;
    padding-top: calc(env(safe-area-inset-top, 20px) + 12px) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    z-index: 10001 !important;
    background: transparent !important;
    pointer-events: auto !important;
}

/* 5.1 返回按钮 - 确保可点击 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-back-btn {
    z-index: 10002 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
}

/* 6. 底部控件 - 固定在底部 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 10px 16px !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 20px) + 12px) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    z-index: 99999 !important;
    background: transparent !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* 6.0 确保video-controls可见 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls.hidden {
    opacity: 0 !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-side-lock {
    display: flex !important;
    position: fixed !important;
    left: calc(env(safe-area-inset-left, 0px) + 12px) !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 100002 !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-container.controls-locked .video-controls {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 6.1 底部控件元素对齐 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .play-btn,
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .episodes-btn,
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .fullscreen-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 36px !important;
    min-height: 36px !important;
    height: 36px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .progress-bar {
    display: flex !important;
    align-items: center !important;
    height: 4px !important;
    min-height: 4px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .time-display {
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

/* 6.2 选集面板 - 固定在右侧 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-episodes-panel {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    left: auto !important;
    width: 40% !important;
    max-width: 420px !important;
    height: 100vh !important;
    z-index: 10000 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: right 0.3s ease, opacity 0.3s ease !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-episodes-panel.show {
    right: 0 !important;
    left: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 6.3 选集弹窗显示时，video-play-overlay可点击关闭弹窗 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-episodes-panel.show ~ .video-play-overlay {
    display: flex !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
}

/* 7. 播放覆盖层 - 只在暂停时显示 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-play-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important;
    z-index: 50 !important;
    background: transparent !important;
    pointer-events: auto !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-play-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
}

/* 8. video-controls 容器本身不需要定位 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls {
    position: static !important;
}

/* 9. 返回按钮 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-back-btn {
    flex-shrink: 0 !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    margin-right: 10px !important;
    background: transparent !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-back-btn img {
    width: 16px !important;
    height: 16px !important;
}

/* 9.1 所有按钮透明背景 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .control-btn {
    background: transparent !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .episodes-btn {
    background: transparent !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-btn {
    background: transparent !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .play-btn {
    background: transparent !important;
}

/* 10. video-info */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .progress-row,
body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .control-row {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    align-items: center !important;
    gap: 12px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .small-screen-only {
    display: none !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .image-control {
    flex: 0 0 32px !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 2px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .image-control img {
    display: block !important;
    width: 27px !important;
    height: 27px !important;
    object-fit: contain !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .seek-back-btn img {
    width: 26px !important;
    height: 26px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .play-btn .pause-state-icon {
    display: none !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .play-btn.is-playing .play-icon-glyph {
    display: none !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .play-btn.is-playing .pause-state-icon {
    display: block !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .danmaku-input-player {
    display: block !important;
    flex: 0 0 200px !important;
    width: 200px !important;
    min-width: 120px !important;
    margin: 0 !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .settings-btn {
    margin-right: 6px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .control-actions {
    display: flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    gap: 8px !important;
    margin-left: auto !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .exit-fullscreen-image {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    object-fit: contain !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .danmaku-input-player input {
    display: block !important;
    width: 100% !important;
    height: 32px !important;
    background: #fff !important;
    color: #222 !important;
    border: 1px solid rgba(255, 255, 255, 0.7) !important;
    border-radius: 16px !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .text-control {
    flex: 0 0 auto !important;
    min-width: 42px !important;
    min-height: 32px !important;
    height: 32px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
}

@media screen and (max-width: 420px) {
    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom {
        padding-left: 8px !important;
        padding-right: 8px !important;
        gap: 6px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .control-row {
        gap: 7px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .image-control {
        flex-basis: 28px !important;
        width: 28px !important;
        min-width: 28px !important;
        height: 30px !important;
        min-height: 30px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .image-control img {
        width: 24px !important;
        height: 24px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .text-control {
        min-width: 38px !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        font-size: 12px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .danmaku-input-player {
        flex-basis: 120px !important;
        width: 120px !important;
        min-width: 72px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .settings-btn {
        margin-right: 3px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom .control-actions {
        gap: 4px !important;
    }
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-title {
    flex-shrink: 1 !important;
    font-size: 14px !important;
    color: #fff !important;
}

body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-episode {
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    font-size: 14px !important;
    color: #fff !important;
    white-space: nowrap !important;
}

/* 11. 进度条 */
body.ios-fullscreen-active .app.player-page.ios-fullscreen .progress-bar {
    flex: 1 !important;
    min-width: 0 !important;
}

/* 12. 横屏模式 */
@media screen and (orientation: landscape) {
    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-title,
    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-episode {
        font-size: 13px !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-player {
        height: 100vh !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .danmaku-container {
        height: 100vh !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-top {
        padding-top: calc(env(safe-area-inset-top, 10px) + 12px) !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .controls-bottom {
        padding-bottom: calc(env(safe-area-inset-bottom, 10px) + 12px) !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .fullscreen-episodes-panel {
        width: 40% !important;
        max-width: 420px !important;
    }
}
/* iOS 主屏幕独立模式：全屏顶部操作栏固定显示。
 * 外层网页 header 仍保持隐藏，避免重复出现两套标题栏；此处的返回和剧名属于视频容器内部。 */
@media (display-mode: standalone) {
    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top,
    body.ios-fullscreen-active .app.player-page.ios-fullscreen.wechat-env .video-controls .controls-top {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .fullscreen-back-btn,
    body.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .video-info {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* iOS Safari 添加到主屏幕后，display-mode 在部分版本不稳定，使用 JS 标记兜底。
   顶部栏固定在横屏左侧安全区内，避免被黑色安全区或自动隐藏逻辑吞掉。 */
body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls,
body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls.hidden {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .fullscreen-back-btn,
body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .video-info,
body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .video-title,
body.ios-standalone.ios-fullscreen-active .app.player-page.ios-fullscreen .video-controls .controls-top .video-episode {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: #fff !important;
}

.ios-standalone-top-bar {
    display: none !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .app.player-page.ios-fullscreen .video-controls .controls-top {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-top-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 56px !important;
    width: 100vw !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 8px 16px !important;
    padding-left: calc(env(safe-area-inset-left, 0px) + 16px) !important;
    padding-right: calc(env(safe-area-inset-right, 0px) + 16px) !important;
    color: #fff !important;
    background: linear-gradient(rgba(0, 0, 0, 0.65), transparent) !important;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
    -webkit-transform: translate3d(0, 0, 0) !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-back {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 8px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-back img {
    width: 22px !important;
    height: 22px !important;
    display: block !important;
    object-fit: contain !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-info {
    min-width: 0 !important;
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    overflow: hidden !important;
    font-size: 18px !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45) !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-title {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

body.ios-standalone.ios-fullscreen-active.ios-landscape-fullscreen .ios-standalone-episode {
    flex: 0 0 auto !important;
}
