/* ============================================================
   数字人混剪系统 - 全局样式
   ============================================================ */

:root {
    --primary: #667eea;
    --primary-dark: #5563d1;
    --sidebar-bg: linear-gradient(180deg, #2c3e50 0%, #1a1a2e 100%);
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --bg-main: #f0f2f5;
    --border-color: #e0e3e9;
    --text-main: #303133;
    --text-secondary: #909399;
}

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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 14px;
}

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

.admin-sidebar, .merchant-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow: hidden;
}

.admin-sidebar.collapsed, .merchant-sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header h5 {
    color: #fff;
    font-size: 16px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-header small {
    color: rgba(255,255,255,0.5);
    font-size: 12px;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav li {
    margin: 2px 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-nav li a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar-nav li.active a {
    color: #fff;
    background: rgba(102,126,234,0.3);
    border-left: 3px solid var(--primary);
}

.sidebar-nav li a i {
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.credits-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.8);
}

.credits-box strong {
    font-size: 24px;
    color: #ffc107;
}

.admin-main, .merchant-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
}

.admin-main.expanded, .merchant-main.expanded {
    margin-left: 60px;
}

.admin-topbar, .merchant-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.toggle-sidebar {
    text-decoration: none;
    border: none;
    background: none;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.admin-content, .merchant-content {
    padding: 20px;
}

/* ============ 卡片 ============ */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.card-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
    margin-bottom: 20px;
}

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

.card-box-header h6 {
    margin: 0;
    font-weight: 600;
}

.card-box-body {
    padding: 20px;
}

/* ============ 表格 ============ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    vertical-align: middle;
}

/* ============ 按钮 ============ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ============ 徽章 ============ */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.login-card {
    position: relative;
    width: 420px;
    max-width: 90%;
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h3 {
    text-align: center;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-card .form-control {
    height: 44px;
    border-radius: 8px;
}

.login-card .btn {
    height: 44px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
}

.login-copyright {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 2;
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
    padding: 0 16px;
}

/* ============ 设置页 ============ */
.settings-tabs .nav-link {
    border: none;
    padding: 12px 20px;
    color: var(--text-secondary);
    border-radius: 8px 8px 0 0;
}

.settings-tabs .nav-link.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    background: transparent;
}

/* ============ 上传组件 ============ */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(102,126,234,0.05);
}

.upload-area i {
    font-size: 36px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ============ 进度条 ============ */
.progress {
    height: 8px;
    border-radius: 4px;
}

.progress-bar {
    background: var(--primary);
}

/* ============ 任务卡片 ============ */
.task-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    overflow: hidden;
    margin-bottom: 20px;
    transition: all 0.25s ease;
    border: 1px solid var(--border-color);
    position: relative;
}

.task-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border-color: rgba(102,126,234,0.25);
}

/* 状态色条 */
.task-card.status-pending::before { background: var(--secondary); }
.task-card.status-processing::before { background: var(--primary); }
.task-card.status-success::before { background: var(--success); }
.task-card.status-failed::before { background: var(--danger); }
.task-card.status-partial::before { background: var(--warning); }

.task-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, rgba(102,126,234,0.04) 0%, transparent 100%);
    gap: 12px;
}

.task-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.task-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.task-card-meta code {
    background: rgba(0,0,0,0.04);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.task-card-body {
    padding: 20px;
}

.task-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.task-stat {
    text-align: center;
    padding: 14px 10px;
    background: var(--bg-main);
    border-radius: 12px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.task-stat:hover {
    border-color: var(--border-color);
}

.task-stat-icon {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 6px;
    opacity: 0.85;
}

.task-stat-value {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.task-stat-value small {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
}

.task-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.task-progress-wrap {
    margin-top: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-main);
    padding: 12px 14px;
    border-radius: 10px;
}

.task-progress-wrap .progress {
    flex: 1;
    height: 10px;
    border-radius: 5px;
    background: #e2e5e9;
    margin: 0;
}

.task-progress-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    min-width: 42px;
    text-align: right;
}

.task-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.task-actions .btn {
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.task-thumbnail {
    width: 120px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
}

/* ============ 声音/数字人卡片 ============ */
.clone-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
    margin-bottom: 16px;
    transition: transform 0.2s;
}

.clone-card:hover {
    transform: translateY(-1px);
}

.clone-card .card-thumb {
    height: 140px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 48px;
    position: relative;
    overflow: hidden;
}

.clone-card .card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.clone-card .card-body {
    padding: 16px;
}

/* ============ 表单 ============ */
.form-label {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-color: var(--border-color);
    border-radius: 8px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(102,126,234,0.15);
}

/* ============ 其他 ============ */
.text-primary { color: var(--primary) !important; }
.bg-primary-light { background: rgba(102,126,234,0.1); }
.cursor-pointer { cursor: pointer; }
.opacity-50 { opacity: 0.5; }
.no-select { user-select: none; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--border-color);
}

/* ============ 素材库相关 ============ */
.lib-scene-item.selected .clone-card {
    box-shadow: 0 0 0 3px var(--primary);
}
.thumb-duration {
    position: absolute;
    right: 6px;
    bottom: 6px;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 6px;
}
.material-card .play-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.music-thumb { background: linear-gradient(135deg, #2c3e50 0%, #667eea 100%); }
.scene-thumb { background: #222; }
.material-card { position: relative; }
.material-card .card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bg-music-list .form-check {
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.bg-music-list .form-check:hover { background: #f8f9fa; }
.bg-music-list input:checked ~ label { color: var(--primary); font-weight: 600; }

/* ============ 响应式 ============ */
@media (max-width: 767.98px) {
    /* 商家端侧边栏 → 抽屉 */
    .merchant-sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.18);
    }
    /* 后台管理端移动端保持图标栏折叠（商家端已是抽屉） */
    .admin-sidebar {
        width: 60px;
    }
    .admin-sidebar .sidebar-header h5,
    .admin-sidebar .sidebar-header small,
    .admin-sidebar .sidebar-nav li a span,
    .admin-sidebar .sidebar-footer {
        display: none;
    }
    .admin-main {
        margin-left: 60px;
    }
    .merchant-sidebar.sidebar-open {
        transform: translateX(0);
    }
    .merchant-sidebar.collapsed {
        width: var(--sidebar-width);
    }
    .merchant-main {
        margin-left: 0;
    }
    .merchant-main.expanded {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 998;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .merchant-topbar {
        height: 54px;
        padding: 0 12px;
    }
    .merchant-content {
        padding: 14px 12px calc(82px + env(safe-area-inset-bottom));
    }

    /* 移动端底部导航 */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        border-top: 1px solid var(--border-color);
        z-index: 1100;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    }
    .mobile-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 0 6px;
        font-size: 11px;
        color: var(--text-secondary);
        text-decoration: none;
        transition: color 0.2s;
    }
    .mobile-bottom-nav a i {
        font-size: 20px;
    }
    .mobile-bottom-nav a.active {
        color: var(--primary);
        font-weight: 600;
    }
    .mobile-bottom-nav a:active {
        color: var(--primary-dark);
    }

    /* 卡片与触屏优化 */
    .stat-card {
        padding: 14px;
        gap: 12px;
    }
    .stat-card .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
        border-radius: 10px;
    }
    .stat-card .stat-value { font-size: 24px; }
    .card-box-header { padding: 13px 16px; }
    .card-box-body { padding: 14px; }
    .btn-lg { font-size: 16px; padding: 12px 16px; }
    .form-control, .form-select { height: 44px; font-size: 15px; }
    textarea.form-control { height: auto; }
    .upload-area { padding: 22px 14px; }
    .upload-area i { font-size: 30px; }
    .nav-pills .nav-link { padding: 8px 14px; font-size: 14px; }

    /* 任务卡片堆叠 */
    .task-card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
        padding: 14px 16px;
    }
    .task-card-meta {
        flex-wrap: wrap;
        white-space: normal;
        width: 100%;
    }
    .task-card-body { padding: 14px; }
    .task-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .task-stat { padding: 10px 8px; }
    .task-stat-icon { font-size: 16px; margin-bottom: 4px; }
    .task-stat-value { font-size: 15px; }
    .task-actions {
        justify-content: flex-start;
        margin-top: 14px;
    }
    .task-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
    }

    /* 混剪页素材库选择 */
    .lib-scene-item .card-thumb { height: 90px !important; }
    .material-card .card-thumb { height: 110px; }
    .bg-music-list { max-height: 200px !important; }

    /* 登录页 */
    .login-card { padding: 28px 20px; }
    .login-card h3 { font-size: 22px; }
}

/* 桌面端默认隐藏移动端控件 */
.mobile-bottom-nav { display: none; }
.sidebar-overlay { display: none; }

/* ============================================================
   系统风格设置（主题色调）- 通过 data-theme 切换
   ============================================================ */
[data-theme="default"] { --primary: #667eea; --primary-dark: #5563d1; --sidebar-bg: linear-gradient(180deg, #2c3e50 0%, #1a1a2e 100%); }
[data-theme="teal"]    { --primary: #0d9488; --primary-dark: #0f766e; --sidebar-bg: linear-gradient(180deg, #0d9488 0%, #134e4a 100%); }
[data-theme="sunset"]  { --primary: #f97316; --primary-dark: #ea580c; --sidebar-bg: linear-gradient(180deg, #f97316 0%, #9a3412 100%); }
[data-theme="rose"]    { --primary: #ec4899; --primary-dark: #db2777; --sidebar-bg: linear-gradient(180deg, #ec4899 0%, #831843 100%); }
[data-theme="indigo"]  { --primary: #4f46e5; --primary-dark: #4338ca; --sidebar-bg: linear-gradient(180deg, #4f46e5 0%, #312e81 100%); }
[data-theme="forest"]  { --primary: #16a34a; --primary-dark: #15803d; --sidebar-bg: linear-gradient(180deg, #16a34a 0%, #14532d 100%); }
[data-theme="amber"]   { --primary: #f59e0b; --primary-dark: #d97706; --sidebar-bg: linear-gradient(180deg, #f59e0b 0%, #92400e 100%); }
[data-theme="slate"]   { --primary: #64748b; --primary-dark: #475569; --sidebar-bg: linear-gradient(180deg, #334155 0%, #0f172a 100%); }

/* 风格设置入口按钮 */
.theme-toggle-btn {
    border: none;
    background: transparent;
    padding: 0;
    color: #333;
    line-height: 1;
    transition: transform 0.15s ease, color 0.15s ease;
}
.theme-toggle-btn:hover { color: var(--primary); transform: scale(1.08); }
.theme-toggle-btn:focus { outline: none; box-shadow: none; }

/* 风格设置面板（offcanvas） */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border: 2px solid #eef0f6;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
}
.theme-swatch:hover { border-color: var(--primary); transform: translateY(-1px); }
.theme-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,0.06); background: #f8f9fc; }
.theme-swatch .swatch-color {
    width: 100%;
    height: 38px;
    border-radius: 8px;
    display: block;
}
.theme-swatch .swatch-name { font-size: 13px; color: #333; font-weight: 500; }
.theme-swatch .swatch-check { display: none; color: var(--primary); font-size: 12px; }
.theme-swatch.active .swatch-check { display: inline; }
