/* ============================================================
   Gcable-Player 前端样式
   现代深色主题，左频道列表 + 右播放器/管理
   ============================================================ */

:root {
    /* 与旧版 index.php 保持一致的蓝色深色主题 */
    --bg: #0f1923;
    --bg-elevated: #1a2733;
    --bg-hover: #1e2d3a;
    --border: #2a3a4a;
    --border-strong: #243446;
    --text: #e0e6ed;
    --text-muted: #7a8a9a;
    --text-dim: #5a6a7a;
    /* 旧版主色：蓝色系 */
    --accent: #378add;
    --accent-hover: #185FA5;
    --accent-dim: rgba(55, 138, 221, 0.12);
    --success: #1D9E75;
    --danger: #E24B4A;
    --warning: #EF9F27;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --font: -apple-system, "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", BlinkMacSystemFont, Arial, sans-serif;
    --mono: "SF Mono", "Menlo", "Consolas", monospace;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button {
    font-family: inherit;
    font-size: 13px;
    padding: 8px 16px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}
button:hover { background: var(--bg-hover); border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
button.danger:hover { background: var(--danger); color: white; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

input, select {
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-dim); }

/* ===== 顶栏 ===== */
.topbar {
    height: 56px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: relative;
    z-index: 10;
    min-width: 0;  /* 允许 flex 子元素收缩 */
}
.topbar .logo { color: var(--text); display: flex; align-items: center; flex-shrink: 1; min-width: 0; }
.topbar .logo svg { height: 26px; width: auto; max-width: 100%; }
.topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar .user-chip {
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 12px;
}

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at top, #1a1f26 0%, #0f1419 70%);
}
.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    width: 360px;
    box-shadow: var(--shadow);
}
.login-card .logo {
    color: var(--text);
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}
.login-card .logo svg { height: 40px; }
.login-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    text-align: center;
    color: var(--text);
}
.login-card .sub {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
}
.login-card .field { margin-bottom: 16px; }
.login-card label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.login-card input { width: 100%; }
.login-card button.primary { width: 100%; padding: 10px; margin-top: 4px; }
.login-card .err {
    color: var(--danger);
    font-size: 12px;
    margin-top: 12px;
    text-align: center;
    min-height: 16px;
}
.login-card .alt-link {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-dim);
}

/* ===== 主布局 ===== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.app-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ===== 左侧栏 ===== */
.sidebar {
    width: 320px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
    font-weight: 600;
}
.server-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.server-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    gap: 10px;
}
.server-item:hover { background: var(--bg-hover); }
.server-item.active {
    background: var(--accent-dim);
    border-color: var(--accent);
}
.server-item .signal-icon {
    width: 22px;
    height: 17px;
    flex-shrink: 0;
    object-fit: contain;
}
.server-item .server-info { flex: 1; min-width: 0; }
.server-item .server-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.server-item .server-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.server-item .server-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    flex-shrink: 0;
}
.server-status.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.server-status.offline { background: var(--text-dim); }
.server-status.loading { background: var(--warning); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* CPU 进度条 */
.cpu-bar {
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.cpu-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, var(--warning) 60%, var(--danger) 90%);
    transition: width 0.5s ease;
}

/* 频道列表 */
.channels-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.channels-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.channels-search input { width: 100%; }
.channels-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}
.channel-item {
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.channel-item:hover { background: var(--bg-hover); }
.channel-item.active {
    background: var(--accent-dim);
    border-left-color: var(--accent);
    color: var(--accent);
}
.channel-item .ch-group {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 6px;
}
.channels-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
}

/* ===== 右侧播放区 ===== */
.player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #000;
}
.player-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #000;
}
.player-wrap video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.player-empty {
    color: var(--text-dim);
    text-align: center;
    font-size: 14px;
}
.player-empty svg { width: 64px; height: 64px; opacity: 0.3; margin-bottom: 12px; }

/* now-playing 底部栏 */
.now-playing {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
}
.now-playing .np-info { flex: 1; min-width: 0; }
.now-playing .np-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.now-playing .np-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.now-playing .np-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}
.now-playing .np-stats .stat-label { color: var(--text-dim); margin-right: 4px; }
.now-playing .np-stats .stat-value { color: var(--text); font-weight: 600; }

/* ===== Footer Copyright ===== */
.footer {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 8px 20px;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer a { color: var(--text-muted); }

/* ===== Admin 页面 ===== */
.admin-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.admin-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* 设备管理表格 */
.device-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    overflow: hidden;
}
.device-table th, .device-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.device-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.device-table input { padding: 6px 8px; width: 100%; min-width: 80px; }
.device-table tr:last-child td { border-bottom: none; }

/* ===== 穿梭框 Transfer ===== */
.transfer {
    display: flex;
    gap: 16px;
    background: var(--bg-elevated);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    align-items: stretch;
    min-height: 420px;
}
.transfer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 0;
}
.transfer-panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}
.transfer-panel-header .tp-title {
    font-weight: 600;
    color: var(--text);
}
.transfer-panel-header .tp-count {
    color: var(--text-muted);
    font-family: var(--mono);
}
.transfer-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.transfer-search input { width: 100%; font-size: 12px; padding: 6px 10px; }
.transfer-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    min-height: 0;
}
.transfer-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.transfer-item:hover { background: var(--bg-hover); }
.transfer-item.selected { background: var(--accent-dim); }
.transfer-item .ti-checkbox {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 2px;
    flex-shrink: 0;
    position: relative;
}
.transfer-item.selected .ti-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}
.transfer-item.selected .ti-checkbox::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.transfer-item .ti-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.transfer-item .ti-group {
    font-size: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
}
.transfer-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
}
.transfer-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}
.transfer-buttons button {
    padding: 8px 12px;
    font-size: 16px;
    line-height: 1;
}
.transfer-footer {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.transfer-footer .tf-info {
    font-size: 12px;
    color: var(--text-muted);
}
.transfer-footer .tf-info .changed { color: var(--warning); font-weight: 600; margin-left: 8px; }

/* 密码管理 */
.password-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    max-width: 480px;
    margin-bottom: 16px;
}
.password-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}
.password-card .field { margin-bottom: 12px; }
.password-card label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.password-card input { width: 100%; }
.password-card .msg {
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}
.password-card .msg.ok { color: var(--success); }
.password-card .msg.err { color: var(--danger); }

/* 服务器状态网格（admin） */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}
.stat-card .sc-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.stat-card .sc-name .signal-icon {
    width: 26px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}
.stat-card .sc-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.stat-card .sc-row .sc-val {
    color: var(--text);
    font-family: var(--mono);
    font-weight: 600;
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 13px;
    z-index: 1000;
    animation: slideIn 0.2s;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* 响应式 —— 手机端 */
@media (max-width: 768px) {
    /* 顶栏：缩小 logo，增大按钮 */
    .topbar { padding: 0 12px; gap: 8px; height: 48px; }
    .topbar .logo svg { height: 22px; }
    .topbar .topbar-right { gap: 6px; }
    .topbar .topbar-right a { font-size: 11px; }

    /* 侧边栏变成抽屉，默认隐藏 */
    .sidebar {
        position: fixed;
        top: 48px;
        left: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0); }

    /* 抽屉遮罩 */
    .drawer-mask {
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
        display: none;
    }
    .drawer-mask.show { display: block; }

    /* 浮动"选台"按钮 */
    .fab-channels {
        position: fixed;
        right: 16px;
        bottom: 80px;
        z-index: 50;
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: var(--accent);
        color: #fff;
        border: none;
        font-size: 20px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 播放器占满 */
    .player-area { width: 100%; }
    .player-wrap { flex: 1; }

    /* now-playing 紧凑化 */
    .now-playing {
        padding: 8px 12px;
        gap: 8px;
        flex-wrap: wrap;
        min-height: 48px;
    }
    .now-playing .np-info { flex: 1 1 100%; min-width: 0; }
    .now-playing .np-title { font-size: 13px; }
    .now-playing .np-meta { font-size: 10px; }
    .now-playing .np-stats {
        gap: 12px;
        font-size: 11px;
    }
    .now-playing #stopBtn { padding: 6px 12px; font-size: 12px; }

    /* footer 简化 */
    .footer { font-size: 10px; padding: 6px 12px; }

    /* admin 页面适配 */
    .admin-body { padding: 12px; }
    .admin-tab { padding: 8px 12px; font-size: 12px; }
    .device-table { font-size: 11px; }
    .device-table th, .device-table td { padding: 6px 8px; }
    .device-table input { padding: 4px 6px; font-size: 11px; }

    /* 穿梭框竖排 */
    .transfer { flex-direction: column; min-height: auto; gap: 8px; }
    .transfer-panel { min-height: 200px; }
    .transfer-buttons { flex-direction: row; justify-content: center; }
    .transfer-buttons button { padding: 6px 16px; }

    /* 登录页 */
    .login-card { width: 90%; max-width: 340px; padding: 28px 24px; }

    /* 状态卡片 */
    .stats-grid { grid-template-columns: 1fr; }
}
