/* ========== 全局样式 ========== */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --sidebar-width: 240px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; }

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text);
    transition: all 0.2s;
    border: 1px solid var(--border);
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ========== 布局 ========== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
}
.logo-icon { font-size: 28px; }

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.2s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.logout-link {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}
.logout-link:hover { color: var(--danger); }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 0;
    min-width: 0;
}

/* ========== 内容头部 ========== */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
}
.content-header h1 { font-size: 24px; }
.stat-badge {
    background: var(--bg-card);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ========== 筛选栏 ========== */
.filter-bar {
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
}
.filter-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.search-box input,
.filter-form select,
.filter-form input {
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    min-width: 200px;
}
.search-box input { flex: 1; max-width: 320px; }
.filter-form select { min-width: 140px; cursor: pointer; }

/* ========== 视频网格 ========== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px 32px;
}

.video-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}
.video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.video-thumb {
    position: relative;
    aspect-ratio: 9/12;
    background: #000;
    overflow: hidden;
}
.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.thumb-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, #1e293b, #334155);
}

.platform-badge {
    position: absolute;
    top: 8px; left: 8px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.duration-badge {
    position: absolute;
    bottom: 8px; right: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: rgba(0,0,0,0.7);
    color: #fff;
}

.status-badge {
    position: absolute;
    top: 8px; right: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.status-failed { background: var(--danger); color: #fff; }
.status-pending { background: var(--warning); color: #000; }

.video-info {
    padding: 14px;
}
.video-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}

.video-meta { margin-bottom: 10px; }
.author-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.author-avatar {
    width: 24px; height: 24px;
    border-radius: 50%;
    object-fit: cover;
}
.author-name {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.video-date {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.video-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg-hover);
    color: var(--text-muted);
}
.category-tag { background: var(--primary); color: #fff; }

.video-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
}
.page-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.page-btn:hover { background: var(--primary); color: #fff; }
.page-info { color: var(--text-muted); font-size: 14px; }

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* ========== 弹窗 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border);
}
.modal-sm { max-width: 360px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.form-row input { flex: 1; }

/* ========== 登录页 ========== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}
.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 14px; }
.login-form .form-group { margin-bottom: 18px; }
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid var(--danger); color: #fca5a5; }
.login-footer { text-align: center; margin-top: 20px; color: var(--text-muted); }

/* ========== 分类管理 ========== */
.categories-container { padding: 24px 32px; }
.add-category-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}
.add-form .form-row { display: flex; gap: 10px; }
.add-form input { flex: 1; min-width: 200px; }

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.category-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.category-card:hover { border-color: var(--primary); }
.cat-icon { font-size: 32px; }
.cat-info { flex: 1; }
.cat-info h4 { font-size: 14px; }
.cat-info small { color: var(--text-muted); font-size: 12px; }
.cat-actions { display: flex; gap: 4px; }

/* ========== 统计卡片 ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px 32px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}
.stat-icon { font-size: 36px; }
.stat-value { font-size: 24px; font-weight: 700; display: block; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* ========== 设置区域 ========== */
.settings-section {
    margin: 0 32px 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
}
.settings-section h2 { font-size: 18px; margin-bottom: 12px; }
.section-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

.config-block { margin-bottom: 24px; }
.config-item { margin-bottom: 16px; }
.config-item label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.code-copy {
    display: flex;
    gap: 10px;
    align-items: center;
}
.code-copy code {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    border: 1px solid var(--border);
    word-break: break-all;
}

.steps-list {
    padding-left: 20px;
    line-height: 2;
    font-size: 14px;
}
.steps-list ul {
    padding-left: 20px;
    margin: 4px 0;
}
.steps-list code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.warning-section { border-color: var(--warning); }
.warning-list {
    padding-left: 20px;
    line-height: 2;
    font-size: 14px;
    color: var(--warning);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .main-content { margin-left: 0; }
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
        padding: 16px;
    }
    .content-header { padding: 16px; }
    .filter-bar { padding: 12px 16px; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .search-box input { max-width: none; }
    .stats-grid { padding: 16px; }
    .settings-section { margin: 0 16px 16px; }
}
