/* 公共样式文件 - 星怀蓝梦网站 */
:root {
    --primary-color: #2196f3;
    --primary-hover: #1784db;
    --background-color: #f1f1f1;
    --white: #ffffff;
    --text-color: #333;
    --border-color: #e0e6ed;
    --footer-text: #666;
}

/* 基础样式 - 关键：禁止页面整体横向溢出 */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* 核心：禁止页面横向滚动 */
    width: 100vw; /* 强制占满屏幕宽度 */
    box-sizing: border-box;
}

/* 容器样式 - 移动端占满宽度，无额外边距 */
.container {
    width: 100%; /* 改为100%宽度，避免固定百分比导致的溢出 */
    max-width: 1200px; /* 桌面端最大宽度限制 */
    margin: 0 auto;
    padding: 20px;
    flex: 1;
    box-sizing: border-box; /* 内边距不影响整体宽度 */
}

/* 头部样式 - 适配移动端 */
header {
    background-color: var(--white);
    padding: 15px 10px; /* 移动端缩减内边距 */
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

header h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.8rem; /* 移动端字体适配 */
}

/* 导航栏样式 - 核心优化：移动端无横向溢出 */
nav {
    background-color: var(--primary-color);
    width: 100%;
    overflow-x: auto; /* 导航项过多时，仅导航栏内部横向滚动，不影响页面 */
    -webkit-overflow-scrolling: touch; /* 移动端顺滑滚动 */
    box-sizing: border-box;
    padding: 0 5px; /* 左右留少量间距，避免贴边 */
}

.nav-container {
    width: 100%; /* 占满导航栏宽度 */
    margin: 0; /* 去掉左右margin，避免额外宽度 */
    display: flex; /* 弹性布局，适配导航项 */
    align-items: center;
}

nav a {
    color: var(--white);
    text-decoration: none;
    padding: 12px 15px;
    font-weight: bold;
    display: inline-flex; /* 弹性布局，文字垂直居中更稳定 */
    align-items: center;
    justify-content: center;
    min-width: 80px; /* 移动端最小宽度，避免过窄 */
    max-width: 120px; /* 桌面端最大宽度 */
    text-align: center;
    box-sizing: border-box;
    height: 45px;
    line-height: 1.2; /* 文字换行时垂直居中 */
    white-space: nowrap; /* 防止文字换行导致宽度异常 */
}

nav a:hover {
    background-color: var(--primary-hover);
}

/* 下拉菜单样式 - 适配移动端导航 */
.dropdown {
    position: relative;
    display: inline-flex; /* 与导航项布局一致 */
    align-items: center;
    height: 45px;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--primary-color);
    min-width: 120px; /* 下拉菜单最小宽度 */
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 9999; /* 提高层级，避免被遮挡 */
    top: 100%; /* 紧贴导航栏底部 */
    left: 0;
}

.dropdown-content a {
    display: block;
    padding: 12px 15px;
    width: 100%; /* 下拉项占满宽度 */
    min-width: auto; /* 取消最小宽度限制 */
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* 内容区域样式 - 确保无横向溢出 */
.content {
    background-color: var(--white);
    padding: 20px;
    margin-top: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 4px;
    box-sizing: border-box;
}

/* 页脚样式 - 适配移动端 */
footer {
    background-color: var(--white);
    color: var(--footer-text);
    text-align: center;
    padding: 15px 10px;
    font-size: 14px;
    border-top: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
    margin-top: auto; /* 确保页脚在底部 */
}

/* 视频相关样式 - 优化移动端适配 */
.video-container {
    width: 100%; /* 占满父容器宽度 */
    margin: 0 auto;
    box-sizing: border-box;
}

#video-player {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    background-color: #000;
    border-radius: 4px;
    object-fit: contain; /* 防止视频拉伸 */
}

/* 视频控制按钮样式 - 优化移动端布局 */
.video-controls {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.video-controls input,
.video-url-input {
    flex: 1;
    min-width: 150px; /* 移动端最小宽度适配 */
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.video-controls button {
    padding: 8px 16px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.video-controls button:hover {
    background: #1976d2;
}

.video-controls button:active {
    background: #1565c0;
}

/* 切换频道按钮特殊样式 */
#prev-channel, #next-channel {
    background: #ff9800;
}

#prev-channel:hover, #next-channel:hover {
    background: #f57c00;
}

#prev-channel:active, #next-channel:active {
    background: #ef6c00;
}

/* 全屏播放时的控制按钮样式 - 优化移动端适配 */
:fullscreen .video-controls,
:-webkit-full-screen .video-controls,
:-moz-full-screen .video-controls,
:-ms-fullscreen .video-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 8px;
    z-index: 1000;
    width: 90%; /* 全屏时控制栏占90%宽度，避免溢出 */
    max-width: 600px; /* 最大宽度限制 */
}

:fullscreen .video-controls button,
:-webkit-full-screen .video-controls button,
:-moz-full-screen .video-controls button,
:-ms-fullscreen .video-controls button {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

:fullscreen .video-controls button:hover,
:-webkit-full-screen .video-controls button:hover,
:-moz-full-screen .video-controls button:hover,
:-ms-fullscreen .video-controls button:hover {
    background: white;
}

/* 视频列表样式 - 移动端垂直排列，无横向溢出 */
.video-list {
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.video-list ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.video-list li {
    margin: 0;
    width: calc((100% - 40px) / 5);
    min-width: 120px;
    box-sizing: border-box;
}

.video-list a {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 10px;
    border: 1px solid #eee;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    background-color: var(--white);
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.3s ease;
}

.video-list a:hover, .video-list a.on {
    background-color: #e3f2fd;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* 数字方框样式 */
.number-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: #2196f3;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
    transition: all 0.3s ease;
}

.video-list a:hover .number-box {
    background-color: #1976d2;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

.video-list a.on .number-box {
    background-color: #1565c0;
    box-shadow: 0 3px 6px rgba(33, 150, 243, 0.5);
}

/* 响应式设计 - 平板端 */
@media (max-width: 992px) {
    .video-list li {
        width: calc((100% - 30px) / 4);
    }
    
    header h1 {
        font-size: 1.6rem;
    }
}

/* 移动端优化 - 核心适配，彻底禁止横向滚动 */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    .container {
        padding: 10px; /* 缩减内边距，避免挤压 */
    }
    
    .video-container {
        margin-bottom: 15px;
    }
    
    /* 视频控制按钮组 - 移动端垂直排列，占满宽度 */
    .video-controls {
        flex-direction: column;
        gap: 8px;
        margin: 10px 0;
    }
    
    .video-controls input,
    .video-url-input {
        width: 100%;
        min-width: auto;
        padding: 12px;
        font-size: 16px;
    }
    
    .video-controls button {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        margin: 2px 0;
    }
    
    /* 视频播放器 - 限制最大高度，避免溢出 */
    #video-player {
        max-height: 50vh;
        background: #000;
    }
    
    /* 导航优化 - 移动端适配 */
    nav a {
        padding: 10px 12px;
        font-size: 14px;
        min-width: 70px; /* 进一步缩小最小宽度 */
    }
    
    /* 视频列表 - 移动端垂直排列，占满宽度 */
    .video-list {
        max-height: 40vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-right: 5px; /* 滚动条预留空间，避免内容被遮挡 */
    }
    
    .video-list li {
        width: 100%;
        margin: 0 0 8px 0;
    }
    
    .video-list a {
        padding: 12px 15px;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .number-box {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
}

/* 小屏移动端适配 */
@media (max-width: 576px) {
    .video-list li {
        width: 100%;
        margin: 0 0 8px 0;
    }
    
    .video-list a {
        padding: 15px;
        font-size: 14px;
        line-height: 1.4;
    }
    
    .region-section h4 {
        font-size: 16px;
        margin: 15px 0 8px 0;
    }
    
    header h1 {
        font-size: 1.2rem;
    }
    
    /* 进一步缩小导航项内边距，适配小屏 */
    nav a {
        padding: 10px 8px;
        font-size: 13px;
        min-width: 60px;
    }
}