/* WebView 电视 - 网页版样式 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #1a1a2e;
    --secondary-bg: #16213e;
    --sidebar-bg: #0f0f23;
    --accent-color: #e94560;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a4a;
    --hover-bg: #252545;
    --selected-bg: #e94560;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 顶部标题栏 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--hover-bg);
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧频道列表 */
.channel-sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.channel-item {
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-item:hover {
    background: var(--hover-bg);
}

.channel-item.active {
    background: var(--selected-bg);
}

.channel-item .channel-name {
    font-size: 14px;
    font-weight: 500;
}

.channel-item .channel-group {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--border-color);
    padding: 2px 8px;
    border-radius: 10px;
}

.channel-item.active .channel-group {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* 播放器区域 */
.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
}

.player-container {
    flex: 1;
    position: relative;
    background: #000;
}

#playerFrame {
    width: 100%;
    height: 100%;
    border: none;
}

.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s;
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    margin-top: 16px;
    color: var(--text-secondary);
}

/* 底部控制栏 */
.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--secondary-bg);
    border-top: 1px solid var(--border-color);
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#currentChannelName {
    font-size: 16px;
    font-weight: 600;
}

.channel-group {
    font-size: 12px;
    color: var(--text-secondary);
}

.control-buttons {
    display: flex;
    gap: 12px;
}

.control-buttons button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.control-buttons button:hover {
    background: var(--hover-bg);
    border-color: var(--accent-color);
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--secondary-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.setting-item input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--primary-bg);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 10px;
}

.setting-item input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

.setting-item button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: var(--accent-color);
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.setting-item button:hover {
    opacity: 0.9;
}

.danger-btn {
    background: #dc3545 !important;
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .channel-sidebar {
        width: 200px;
    }
    
    .control-bar {
        flex-direction: column;
        gap: 12px;
    }
    
    .control-buttons {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .main-content {
        flex-direction: column;
    }

    .channel-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

/* ============== 密码门 ============== */
.gate {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.gate-box {
    background: rgba(15, 15, 35, 0.95);
    border: 1px solid var(--border-color, #2a2a4e);
    border-radius: 12px;
    padding: 40px 32px;
    width: min(90%, 360px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.gate-box h1 {
    font-size: 22px;
    color: var(--text-primary, #fff);
    margin-bottom: 8px;
}

.gate-sub {
    color: var(--text-secondary, #a0a0a0);
    font-size: 13px;
    margin-bottom: 20px;
}

#gatePassword {
    width: 100%;
    padding: 12px 14px;
    background: var(--secondary-bg, #16213e);
    border: 1px solid var(--border-color, #2a2a4e);
    border-radius: 6px;
    color: var(--text-primary, #fff);
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.2s;
}

#gatePassword:focus {
    border-color: var(--accent-color, #e94560);
}

#gateSubmit {
    width: 100%;
    padding: 12px;
    background: var(--accent-color, #e94560);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

#gateSubmit:hover {
    opacity: 0.9;
}

#gateSubmit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gate-msg {
    margin-top: 12px;
    font-size: 13px;
    min-height: 18px;
    color: var(--accent-color, #e94560);
}
