/* ═══════════════════════════════════════════════════════════════════
   用户设置面板 — 视频测试 / 音频测试 / 虚拟背景
   风格：深邃暗色 + 玻璃质感 + Zoom 风格侧边栏选项卡
   ═══════════════════════════════════════════════════════════════════ */

/* ── 遮罩层 ── */
#settings-overlay {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(0,0,0,0.65);
    display: none;
    align-items: center; justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: settingsFadeIn 0.25s ease;
}
#settings-overlay.open { display: flex; }
@keyframes settingsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── 设置卡片 ── */
#settings-card {
    display: flex;
    width: 860px; max-width: 94vw; height: 580px; max-height: 88vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: settingsSlideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes settingsSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── 左侧选项卡栏 ── */
#settings-tabs {
    width: 200px; flex-shrink: 0;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 16px 0;
}
.settings-tab {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 20px;
    margin: 0 8px 2px;
    border: none; border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px; font-weight: 500;
    transition: all var(--transition);
    text-align: left;
}
.settings-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.settings-tab.active {
    background: var(--accent-bg);
    color: var(--accent);
}
.settings-tab svg {
    width: 20px; height: 20px; flex-shrink: 0;
}

/* ── 右侧内容区 ── */
#settings-content {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0;
}

/* ── 内容区头部 ── */
#settings-content-header {
    padding: 20px 28px 0;
}
#settings-content-header h2 {
    font-size: 18px; font-weight: 700; color: var(--text-primary);
    margin: 0 0 4px;
}
#settings-content-header p {
    font-size: 12px; color: var(--text-muted); margin: 0;
}

/* ── 内容区主体（可滚动） ── */
#settings-content-body {
    flex: 1; overflow-y: auto; padding: 18px 28px 8px;
}

/* ── 内容区底部按钮 ── */
#settings-content-footer {
    padding: 14px 28px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}
.settings-btn {
    padding: 9px 22px; border: none; border-radius: var(--radius-xs);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all var(--transition);
}
.settings-btn-cancel {
    background: var(--bg-hover); color: var(--text-secondary);
}
.settings-btn-cancel:hover { background: #2a3045; color: var(--text-primary); }
.settings-btn-apply {
    background: var(--accent); color: #fff;
}
.settings-btn-apply:hover { background: var(--accent-hover); }

/* ═══════════════════════════════════════════════════════════════════
   通用表单元素
   ═══════════════════════════════════════════════════════════════════ */
.settings-section {
    margin-bottom: 22px;
}
.settings-label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 8px;
}
.settings-select {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border-light); border-radius: var(--radius-xs);
    background: var(--bg-primary); color: var(--text-primary);
    font-size: 13px; outline: none; cursor: pointer;
    transition: border var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
.settings-select:focus { border-color: var(--accent); }
.settings-select option { background: var(--bg-secondary); color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════════════
   视频预览区
   ═══════════════════════════════════════════════════════════════════ */
.settings-video-preview-wrap {
    position: relative;
    width: 100%; max-width: 480px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-light);
    margin-bottom: 16px;
    aspect-ratio: 16/9;
}
.settings-video-preview-wrap video,
.settings-video-preview-wrap canvas {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.settings-video-preview-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted);
}
.settings-video-preview-placeholder svg { opacity: 0.3; margin-bottom: 8px; }
.settings-video-preview-label {
    position: absolute; bottom: 10px; left: 14px;
    font-size: 11px; color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.5); padding: 2px 8px;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════
   音频测试区
   ═══════════════════════════════════════════════════════════════════ */
.settings-audio-test-row {
    display: flex; align-items: center; gap: 14px; margin-bottom: 12px;
}
.settings-volume-bar-wrap {
    flex: 1; height: 12px; background: var(--bg-primary);
    border-radius: 6px; overflow: hidden;
}
.settings-volume-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--green), #22c55e);
    border-radius: 6px; transition: width 0.1s ease;
}
.settings-volume-bar.hot {
    background: linear-gradient(90deg, #f59e0b, var(--red));
}
.settings-volume-text {
    font-size: 12px; color: var(--text-muted);
    min-width: 40px; text-align: right;
}
.settings-test-tone-btn {
    padding: 7px 16px; border: 1px solid var(--border-light);
    border-radius: var(--radius-xs); background: var(--bg-primary);
    color: var(--text-secondary); font-size: 12px; cursor: pointer;
    transition: all var(--transition);
}
.settings-test-tone-btn:hover { border-color: var(--accent); color: var(--accent); }
.settings-test-tone-btn.playing {
    background: var(--accent); color: #fff; border-color: var(--accent);
}
.settings-test-tone-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border-light);
    color: var(--text-muted);
}
.settings-mic-test-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 4px;
}
.settings-mic-test-status {
    font-size: 12px; color: var(--text-muted);
    min-width: 80px; text-align: left;
}
.settings-audio-hint {
    font-size: 11px; color: var(--text-muted); margin: 2px 0 0;
}

/* ═══════════════════════════════════════════════════════════════════
   虚拟背景选择区
   ═══════════════════════════════════════════════════════════════════ */
.settings-bg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.settings-bg-option {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition);
    aspect-ratio: 16/10;
    background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
}
.settings-bg-option:hover { border-color: var(--border-accent); }
.settings-bg-option.selected { border-color: var(--accent); }
.settings-bg-option.selected::after {
    content: '✓';
    position: absolute; top: 6px; right: 6px;
    width: 22px; height: 22px;
    background: var(--accent); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    z-index: 2;
}
.settings-bg-thumb {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.settings-bg-label {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 4px 8px; font-size: 11px; color: #fff;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    text-align: center;
}
/* 无背景 / 模糊 / 纯色 预设 */
.settings-bg-preset-blur {
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
}
.settings-bg-preset-blur::before {
    content: ''; position: absolute; inset: 20%;
    background: rgba(255,255,255,0.08); border-radius: 50%;
    filter: blur(10px);
}
.settings-bg-preset-color {
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
}

/* 自定义颜色选择器 */
.settings-color-input {
    width: 40px; height: 40px; border: 2px solid var(--border-light);
    border-radius: var(--radius-xs); cursor: pointer;
    background: none; padding: 0;
    transition: border var(--transition);
}
.settings-color-input:hover { border-color: var(--accent); }

/* 自定义图片上传按钮 */
.settings-upload-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; padding: 9px 16px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-xs);
    background: transparent; color: var(--text-secondary);
    font-size: 12px; cursor: pointer;
    transition: all var(--transition);
    margin-top: 12px;
}
.settings-upload-btn:hover {
    border-color: var(--accent); color: var(--accent);
    background: var(--accent-bg);
}
.settings-upload-btn svg { opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════════
   分辨率选择器
   ═══════════════════════════════════════════════════════════════════ */
.settings-resolution-grid {
    display: flex; gap: 10px; flex-wrap: wrap;
}
.settings-resolution-chip {
    padding: 7px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: transparent; color: var(--text-secondary);
    font-size: 12px; cursor: pointer;
    transition: all var(--transition);
}
.settings-resolution-chip:hover { border-color: var(--accent); color: var(--accent); }
.settings-resolution-chip.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════
   虚拟背景 — 空背景采集倒计时遮罩
   ═══════════════════════════════════════════════════════════════════ */
.settings-bg-countdown-overlay {
    position: absolute; inset: 0; z-index: 10;
    background: rgba(0,0,0,0.75);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px;
    animation: settingsFadeIn 0.3s ease;
}
.settings-bg-countdown-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.settings-bg-countdown-circle::before {
    content: '';
    position: absolute; inset: -3px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    border-top-color: transparent;
    animation: countdownSpin 1s linear infinite;
}
@keyframes countdownSpin {
    to { transform: rotate(360deg); }
}
.settings-bg-countdown-number {
    font-size: 36px; font-weight: 700; color: #fff;
    line-height: 1;
}
.settings-bg-countdown-text {
    font-size: 14px; color: rgba(255,255,255,0.85);
    text-align: center; line-height: 1.5;
}
.settings-bg-countdown-skip {
    margin-top: 12px; padding: 6px 20px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px; background: transparent;
    color: rgba(255,255,255,0.6); font-size: 12px;
    cursor: pointer; transition: all 0.2s;
}
.settings-bg-countdown-skip:hover {
    border-color: rgba(255,255,255,0.6);
    color: rgba(255,255,255,0.9);
}

/* ═══════════════════════════════════════════════════════════════════
   虚拟背景 — 建模进度条
   ═══════════════════════════════════════════════════════════════════ */
.settings-bg-info {
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    margin-top: 8px;
}
.settings-bg-info-bar {
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
    margin-bottom: 6px;
}
#settings-bg-info-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════
   加载/错误状态
   ═══════════════════════════════════════════════════════════════════ */
.settings-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 40px; color: var(--text-muted); font-size: 13px;
    gap: 10px;
}
.settings-loading-spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: settingsSpin 0.7s linear infinite;
}
@keyframes settingsSpin {
    to { transform: rotate(360deg); }
}
.settings-error {
    padding: 12px 16px; border-radius: var(--radius-xs);
    background: var(--red-bg); color: var(--red);
    font-size: 12px; margin: 8px 0;
}

/* ═══════════════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
    #settings-card {
        flex-direction: column; width: 100vw; height: 100vh;
        max-width: none; max-height: none; border-radius: 0;
    }
    #settings-tabs {
        width: 100%; flex-direction: row; padding: 8px; overflow-x: auto;
        border-right: none; border-bottom: 1px solid var(--border);
    }
    .settings-tab { flex-shrink: 0; padding: 10px 16px; font-size: 12px; }
    #settings-content-body { padding: 14px 16px 4px; }
    #settings-content-header { padding: 14px 16px 0; }
    #settings-content-footer { padding: 10px 16px; }
}
