/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, sans-serif;
}

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #0b0e14;
    color: #e0e6ee;
}

/* ===== 左侧边栏（PC及横屏手机） ===== */
#sidebar {
    width: 280px;
    min-width: 200px;
    background: #141a22;
    border-right: 1px solid #2a323c;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid #2a323c;
    background: #1a212b;
}
.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.btn-manage {
    background: #2a3a4a;
    border: none;
    color: #c8d0d8;
    font-size: 20px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-manage:hover {
    background: #3a4a5a;
}

.filter-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #0f161e;
    border-bottom: 1px solid #2a323c;
}
.filter-bar input {
    flex: 1;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #e0e6ee;
    font-size: 13px;
}
.filter-bar select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #e0e6ee;
    font-size: 13px;
}

.video-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.video-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}
.video-item:hover {
    background: #1f2935;
}
.video-item.active {
    background: #1e2a38;
    border-left-color: #4a9eff;
}
.video-item img {
    width: 48px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    background: #2a323c;
}
.video-item .info {
    flex: 1;
    min-width: 0;
}
.video-item .name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.video-item .category {
    font-size: 11px;
    color: #8a9aa8;
    background: #1f2935;
    padding: 1px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
}

.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid #2a323c;
    font-size: 13px;
    color: #8a9aa8;
    text-align: center;
}
.load-more {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #1f2a3a;
    border: none;
    border-radius: 6px;
    color: #a0b0c0;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.load-more:hover {
    background: #2a3a4a;
}

/* ===== 右侧播放区域 ===== */
#playerArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b0e14;
}
#playerWrapper {
    position: relative;
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
#videoPlayer {
    width: 100%;
    height: 100%;
    max-height: 80vh;
    background: #000;
    display: none;
    object-fit: contain;
}
#videoPlayer:not([src=""]) {
    display: block;
}
#playerPlaceholder {
    text-align: center;
    color: #5a6a7a;
}
#playerPlaceholder span {
    font-size: 60px;
    display: block;
}
#playerPlaceholder p {
    margin-top: 12px;
    font-size: 16px;
}

.video-info {
    padding: 14px 24px;
    background: #141a22;
    border-top: 1px solid #2a323c;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
#videoTitle {
    font-size: 18px;
    font-weight: 500;
}
.tag {
    background: #1f2a3a;
    padding: 2px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #8ab4f8;
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-content {
    background: #1a212b;
    padding: 30px 28px;
    border-radius: 16px;
    max-width: 780px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #2a323c;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 22px;
    font-size: 28px;
    color: #8a9aa8;
    cursor: pointer;
}
.modal-close:hover {
    color: #fff;
}
.modal h2 {
    margin-bottom: 18px;
    font-size: 22px;
}
.modal h3 {
    font-size: 16px;
    margin: 18px 0 10px 0;
    color: #b0c0ce;
}

.tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #2a323c;
    margin-bottom: 16px;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    color: #8a9aa8;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tab-btn.active {
    color: #e0e6ee;
    border-bottom-color: #4a9eff;
}
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

.form-section form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.form-section form input,
.form-section form select {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #e0e6ee;
    font-size: 14px;
}
.form-section form input:focus,
.form-section form select:focus {
    outline: none;
    border-color: #4a9eff;
}
.form-section form button {
    grid-column: 1 / -1;
    padding: 10px;
    background: #2a6b9a;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}
.form-section form button:hover {
    background: #3a7bba;
}

.batch-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.batch-bar input,
.batch-bar select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #e0e6ee;
    font-size: 13px;
    flex: 1 0 100px;
}
.batch-bar button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: #2a3a4a;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
}
.batch-bar button:hover {
    background: #3a4a5a;
}
.btn-danger {
    background: #8a3a3a !important;
}
.btn-danger:hover {
    background: #aa4a4a !important;
}

.admin-list-wrap {
    margin-top: 16px;
    border-top: 1px solid #2a323c;
    padding-top: 12px;
}
.admin-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
    color: #8a9aa8;
}
.admin-list-header input[type="checkbox"] {
    accent-color: #4a9eff;
    width: 16px;
    height: 16px;
    margin-right: 6px;
}
.admin-list {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: #0b0e14;
    border-radius: 6px;
    font-size: 14px;
}
.admin-item input[type="checkbox"] {
    accent-color: #4a9eff;
    width: 16px;
    height: 16px;
}
.admin-item .admin-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-item .admin-url {
    color: #6a8a9a;
    font-size: 12px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-row {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    align-items: center;
    flex-wrap: wrap;
}
.form-row input,
.form-row select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #e0e6ee;
    font-size: 14px;
    flex: 1;
}
.form-row button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    background: #2a6b9a;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.category-list {
    list-style: none;
    padding: 0;
}
.category-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #0b0e14;
    margin-bottom: 4px;
    border-radius: 4px;
}
.category-list li .cat-actions button {
    background: transparent;
    border: none;
    color: #8a9aa8;
    cursor: pointer;
    margin-left: 8px;
}
.category-list li .cat-actions button:hover {
    color: #e0e6ee;
}
.category-list li .cat-actions .delete-cat {
    color: #d06060;
}

.auth-box {
    max-width: 380px;
    text-align: center;
}
.auth-box input {
    width: 100%;
    padding: 12px;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid #2a323c;
    background: #0b0e14;
    color: #fff;
    font-size: 16px;
}
.auth-box button {
    width: 100%;
    padding: 12px;
    background: #2a6b9a;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
}
.auth-box .error-msg {
    color: #e06060;
    font-size: 14px;
    display: block;
    margin-top: 8px;
}

.btn-logout {
    background: #5a3a3a;
    border: none;
    color: #e0e6ee;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.btn-logout:hover {
    background: #7a4a4a;
}

/* ===== 响应式（竖屏手机） ===== */
@media (max-width: 680px) {
    body {
        flex-direction: column;
    }
    #sidebar {
        width: 100%;
        min-width: unset;
        height: 30vh;
        order: 2;
        border-right: none;
        border-top: 1px solid #2a323c;
        border-bottom: none;
    }
    #playerArea {
        flex: 1;
        order: 1;
        min-height: 50vh;
    }
    #playerWrapper {
        flex: 1;
        min-height: 40vh;
    }
    .video-info {
        padding: 8px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    #videoTitle {
        font-size: 16px;
    }
    .video-item {
        padding: 12px 16px;
    }
    .video-item img {
        width: 56px;
        height: 38px;
    }
    .video-item .name {
        font-size: 15px;
    }
    .modal-content {
        padding: 20px;
        max-height: 95vh;
        width: 98%;
    }
    .form-section form {
        grid-template-columns: 1fr;
    }
    .batch-bar input {
        flex: 1 0 60px;
    }
}

/* ===== 手机横屏：恢复左右框架 ===== */
@media (orientation: landscape) and (max-height: 500px) {
    body {
        flex-direction: row;
    }
    #sidebar {
        width: 35vw;            /* 宽度占屏幕宽度的35% */
        max-width: 300px;       /* 最大宽度限制，避免过宽 */
        height: 100vh;
        order: 0;
        border-right: 1px solid #2a323c;
        border-top: none;
        border-bottom: none;
        min-width: unset;
    }
    #playerArea {
        flex: 1;
        height: 100vh;
        order: 1;
        min-height: unset;
        width: 65vw;
    }
    #playerWrapper {
        flex: 1;
        min-height: unset;
        height: calc(100vh - 60px); /* 减去底部信息栏高度 */
    }
    #videoPlayer {
        max-height: calc(100vh - 60px);
    }
    .video-info {
        padding: 8px 16px;
        min-height: 50px;
        flex-wrap: nowrap;
        gap: 12px;
    }
    #videoTitle {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }
    .tag {
        font-size: 12px;
        padding: 2px 12px;
    }

    /* 列表项紧凑 */
    .video-item {
        padding: 6px 12px;
        gap: 8px;
    }
    .video-item img {
        width: 40px;
        height: 28px;
    }
    .video-item .name {
        font-size: 13px;
    }
    .video-item .category {
        font-size: 10px;
        padding: 1px 6px;
    }

    /* 头部和搜索栏 */
    .sidebar-header {
        padding: 10px 14px;
    }
    .sidebar-header h1 {
        font-size: 16px;
    }
    .btn-manage {
        font-size: 18px;
        padding: 2px 8px;
    }
    .filter-bar {
        padding: 6px 12px;
        gap: 6px;
    }
    .filter-bar input,
    .filter-bar select {
        font-size: 12px;
        padding: 4px 8px;
    }
    .sidebar-footer {
        padding: 6px 12px;
        font-size: 12px;
    }
    .load-more {
        padding: 4px;
        font-size: 12px;
        margin-top: 4px;
    }
    .video-list {
        padding: 4px 0;
    }

    /* 管理弹窗在横屏时自适应 */
    .modal-content {
        max-width: 90%;
        padding: 16px;
        max-height: 85vh;
    }
    .form-section form {
        grid-template-columns: 1fr 1fr;
    }
    .batch-bar input {
        flex: 1 0 80px;
    }
}
