/* ============================================================
   Video Scroll — Dark Tool UI (Left Panel + Right Preview)
   Inspired by React Bits / Background Studio layout
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-deep:       #0a0a0f;
    --bg-panel:      #111118;
    --bg-surface:    #1a1a24;
    --bg-hover:      #22222e;
    --bg-input:      #16161e;
    --border:        #2a2a38;
    --border-focus:  #7c3aed;
    --text-primary:  #e8e8ed;
    --text-secondary:#8888a0;
    --text-muted:    #555568;
    --accent:        #7c3aed;
    --accent-glow:   rgba(124,58,237,.25);
    --accent-soft:   rgba(124,58,237,.12);
    --success:       #22c55e;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --radius-sm:     6px;
    --radius-md:     10px;
    --radius-lg:     14px;
    --panel-width:   320px;
    --topbar-h:      48px;
    --font-mono:     'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    overflow: hidden; /* 全屏应用，禁止 body 滚动 */
}

/* ── Top Bar ── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.topbar-brand {
    display: flex; align-items: center; gap: 10px;
}
.brand-icon { font-size: 20px; }
.brand-name {
    font-size: 15px; font-weight: 700; letter-spacing: .02em;
    color: var(--text-primary);
}
.topbar-meta { display: flex; align-items: center; gap: 12px; }
.meta-tag {
    font-size: 12px; color: var(--text-muted);
    padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px;
}

/* ── Workspace (below topbar) ── */
.workspace {
    position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
    display: flex;
}

/* ═══ Left Control Panel ═══ */
.panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    height: 100%;
    display: flex; flex-direction: column;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    /* 自定义滚动条 */
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Panel Block */
.panel-block {
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.block-label {
    font-size: 11px; font-weight: 700; letter-spacing: .12em;
    color: var(--text-muted); text-transform: uppercase;
    margin-bottom: 12px;
}

/* Upload Zone */
.upload-zone {
    border: 1.5px dashed var(--border); border-radius: var(--radius-md);
    padding: 28px 16px; text-align: center; cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--bg-input);
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }

.upload-icon {
    width: 44px; height: 44px; margin: 0 auto 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: var(--accent);
    border: 1.5px solid var(--accent); border-radius: 50%;
    background: var(--accent-soft);
}
.upload-content p { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.upload-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.upload-info {
    margin-top: 10px; padding: 10px 14px;
    background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.25);
    border-radius: var(--radius-sm); color: var(--success); font-size: 13px;
    word-break: break-all;
}

/* Transcode Box */
.transcode-box {
    margin-top: 12px; padding: 14px;
    background: rgba(245,158,11,.06); border: 1px solid rgba(245,158,11,.25);
    border-radius: var(--radius-md);
}
.transcode-header { font-size: 13px; font-weight: 600; color: var(--warning); margin-bottom: 10px; }
.transcode-track {
    height: 8px; background: rgba(245,158,11,.15); border-radius: 4px; overflow: hidden;
}
.transcode-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--warning), #ea580c);
    transition: width .2s;
    border-radius: 4px;
}
/* 忙碌态（不确定进度）：分析视频 / 加载转码引擎这两个阶段没有百分比可报，
   用左右流动的光带 + 计时告诉用户"还活着"，避免被当成卡死。 */
.transcode-box.busy .transcode-fill {
    width: 100% !important;
    background: linear-gradient(90deg,
        rgba(245,158,11,.10) 0%, rgba(245,158,11,.10) 30%,
        var(--warning) 50%,
        rgba(245,158,11,.10) 70%, rgba(245,158,11,.10) 100%);
    background-size: 220% 100%;
    animation: v2s-busy-sweep 1.15s linear infinite;
    transition: none;
}
@keyframes v2s-busy-sweep {
    0%   { background-position: 220% 0; }
    100% { background-position: -220% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .transcode-box.busy .transcode-fill { animation-duration: 2.6s; }
}
.transcode-pct { font-size: 12px; color: var(--warning); margin-top: 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.transcode-eta { font-size: 11px; color: var(--text-muted); font-weight: 400; text-align: right; }
.transcode-note { font-size: 11px; color: var(--text-muted); margin-top: 4px; opacity: .75; }
.transcode-cancel {
    margin-top: 10px; width: 100%; padding: 7px 12px;
    font-size: 12px; font-family: inherit; cursor: pointer;
    background: transparent; color: var(--text-muted);
    border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
    transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.transcode-cancel:hover { color: #fff; border-color: rgba(255,255,255,.42); background: rgba(255,255,255,.06); }

/* Control Rows (label left, field right) */
.ctrl-row { margin-bottom: 16px; }
.ctrl-row:last-child { margin-bottom: 0; }

.ctrl-label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
    letter-spacing: .03em;
}

.ctrl-field {
    display: flex; align-items: center; gap: 10px;
}

/* Range Slider */
.range-input {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 5px; background: var(--bg-surface); border-radius: 3px;
    outline: none;
}
.range-input::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    background: var(--accent); border-radius: 50%; cursor: pointer;
    box-shadow: 0 0 8px var(--accent-glow);
    transition: transform .15s;
}
.range-input::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-input::-moz-range-thumb {
    width: 16px; height: 16px; background: var(--accent); border-radius: 50%;
    cursor: pointer; border: none; box-shadow: 0 0 8px var(--accent-glow);
}
.range-value {
    min-width: 48px; text-align: right;
    font-family: var(--font-mono); font-size: 13px; font-weight: 600;
    color: var(--accent);
}

/* Text Input */
.text-input {
    width: 100%; padding: 9px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 13px; outline: none; transition: border-color .2s;
}
.text-input::placeholder { color: var(--text-muted); }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Field Hint（输入框下方提示文字） */
.field-hint {
    display: block; margin-top: 6px;
    font-size: 12px; color: var(--text-muted);
    line-height: 1.55; letter-spacing: .01em;
}

/* English sub-line（双语界面英文副行） */
.hint-en {
    display: block; margin-top: 3px;
    font-size: 11px; color: #6a6a82; line-height: 1.45; letter-spacing: .01em;
}
.upload-hint .hint-en,
.transcode-note .hint-en { margin-top: 2px; }

/* Progress Badge */
.progress-badge {
    display: inline-flex; align-items: center;
    padding: 4px 10px; background: var(--accent-soft);
    border: 1px solid rgba(124,58,237,.3); border-radius: 20px;
    font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--accent);
}

/* Generate Button */
.btn-generate {
    width: 100%; margin-top: 8px; padding: 12px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-md);
    font-size: 14px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .2s, transform .1s, box-shadow .2s;
    letter-spacing: .02em;
}
.btn-generate:hover {
    background: #6d28d9; box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}
.btn-generate:active { transform: translateY(0); }
.btn-generate:disabled { background: var(--text-muted); cursor: not-allowed; box-shadow: none; transform: none; }
.btn-icon { font-size: 16px; }

/* ═══ Panel Help Button（面板内触发按钮） ═══ */
.panel-help {
    padding: 0;
    border-bottom: none;
}
.btn-guide {
    width: 100%; padding: 11px 14px;
    background: rgba(124,58,237,.1); border: 1px solid rgba(124,58,237,.35);
    border-radius: var(--radius-md);
    color: var(--accent); font-size: 13px; font-weight: 600;
    cursor: pointer; text-align: left; transition: all .2s;
}
.btn-guide:hover {
    background: rgba(124,58,237,.18); border-color: var(--accent);
    box-shadow: 0 2px 14px var(--accent-glow);
}

/* ═══ Guide Modal（弹窗子页面） ═══ */
.guide-modal {
    display: none;            /* 默认隐藏，点击按钮打开 */
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.62); backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
    padding: 32px;
}
.guide-modal.open { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.guide-modal-box {
    width: min(820px, 100%); max-height: 86vh;
    display: flex; flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
    overflow: hidden;
}
.guide-modal-head {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(124,58,237,.06);
}
.guide-modal-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    letter-spacing: .01em;
}
.guide-modal-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 14px;
    cursor: pointer; transition: all .2s; line-height: 1;
}
.guide-modal-close:hover {
    background: rgba(220,38,38,.12); border-color: #dc2626; color: #f87171;
}
.guide-modal-body {
    overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.guide-modal-body::-webkit-scrollbar { width: 8px; }
.guide-modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ═══ Help Body（弹窗内共用） ═══ */
.help-body { padding: 18px 20px 22px; line-height: 1.7; font-size: 13px; color: var(--text-secondary); }
.help-body p { margin: 6px 0; }
.help-body strong { color: var(--text-primary); }
.help-body code {
    padding: 1px 5px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 12px; color: #a8b9c8; font-family: var(--font-mono);
}
.help-body pre {
    margin: 6px 0; padding: 8px 10px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 11px; color: #c8d4e0;
    overflow-x: auto; font-family: var(--font-mono); white-space: pre-wrap;
}

/* 步骤编号 */
.help-step { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; }
.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.help-step + p { margin-top: 2px; }

/* 小节标题 */
.help-section-title {
    margin: 18px 0 10px; padding: 8px 10px;
    background: rgba(124,58,237,.08); border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 13px; font-weight: 700; color: var(--text-primary);
}

/* 配置参数表格 */
.config-table {
    width: 100%; border-collapse: collapse; margin: 8px 0;
    font-size: 12px;
}
.config-table thead th {
    padding: 8px 8px; text-align: left;
    background: rgba(124,58,237,.1); color: var(--text-primary);
    font-weight: 600; font-size: 11px; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.config-table thead th small { font-weight: 400; color: var(--text-muted); display: block; }
.config-table td {
    padding: 7px 8px; vertical-align: top;
    border-bottom: 1px solid rgba(255,255,255,.04);
    color: var(--text-secondary); line-height: 1.55;
}
.config-table tr:last-child td { border-bottom: none; }
.config-table td:first-child { white-space: nowrap; }
.config-table td code {
    background: transparent; border: none; padding: 0;
    color: #b4c4d4; font-size: 11.5px;
}
.config-table td small { display: block; color: var(--text-muted); font-size: 11px; }

/* 场景卡片 */
.scenario-card {
    margin: 8px 0; padding: 10px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.scenario-name {
    font-size: 12.5px; font-weight: 700; color: var(--accent);
    margin-bottom: 4px;
}
.scenario-card p { font-size: 12.5px; margin: 3px 0 6px; }
.scenario-card pre {
    margin: 4px 0 0; padding: 7px 9px;
    background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.06);
    font-size: 11px; color: #9aacbe;
}

/* FFmpeg 卡片 */
.ffmpeg-card {
    margin: 10px 0; padding: 10px 12px;
    background: rgba(34,197,94,.05); border: 1px solid rgba(34,197,94,.15);
    border-radius: var(--radius-sm);
}
.ffmpeg-name {
    font-size: 12.5px; font-weight: 700; color: #4ade80;
    margin-bottom: 6px;
}
.ffmpeg-card pre {
    margin: 4px 0 8px; padding: 7px 9px;
    background: rgba(0,0,0,.35); border-color: rgba(34,197,94,.1);
    font-size: 11px; color: #86efac;
}
.param-list {
    margin: 4px 0 0; padding-left: 16px;
    list-style: disc;
}
.param-list li {
    font-size: 12px; color: var(--text-secondary);
    margin: 3px 0; line-height: 1.6;
}
.param-list li code {
    background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.2);
    color: #86efac;
}

/* ═══ Right Preview Area ═══ */
.preview-area {
    flex: 1; position: relative;
    background: var(--bg-deep);
    overflow: hidden;
}

/* Empty State */
.preview-empty {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px;
}
.empty-icon {
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: var(--text-muted);
    border: 2px solid var(--border); border-radius: 50%;
    background: var(--bg-panel);
}
.preview-empty p { font-size: 16px; font-weight: 500; color: var(--text-secondary); }
.preview-empty span { font-size: 13px; color: var(--text-muted); }

/* Preview Scroller (active) */
.preview-scroller {
    position: absolute; inset: 0;
    overflow-y: scroll; cursor: ns-resize;
    /* 隐藏滚动条（保持可滚动） */
    scrollbar-width: none;
}
.preview-scroller::-webkit-scrollbar { display: none; }

.preview-track { position: relative; }
.preview-sticky {
    position: sticky; top: 0;
    height: 100vh; /* 占满整个预览区高度 */
    display: flex; align-items: center; justify-content: center;
    background: #000;
}
.preview-sticky video {
    width: 100%; height: 100%; object-fit: contain;
}

/* Preview Badge */
.preview-badge {
    position: absolute; bottom: 20px; right: 24px; z-index: 10;
    padding: 6px 14px;
    background: rgba(0,0,0,.65); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.1); border-radius: 20px;
    font-size: 12px; font-weight: 600; color: rgba(255,255,255,.7);
    letter-spacing: .05em; pointer-events: none;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    :root { --panel-width: 100%; }
    .workspace { flex-direction: column; overflow-y: auto; }
    .panel {
        width: 100%; min-width: 100%; max-height: 55vh;
        border-right: none; border-bottom: 1px solid var(--border);
    }
    .preview-area {
        position: relative; min-height: 45vh;
        overflow: hidden;
    }
    .preview-sticky { height: 45vh; }
    .preview-badge { bottom: 10px; right: 12px; }
    body { overflow: auto; }
    html { overflow: auto; }
    .workspace { position: static; height: auto; }
    .topbar { position: relative; }
}
