/* ============================================================
   CSS Variables - Design Tokens
   ============================================================ */
:root {
  --bg-primary: #F0F2F5;
  --bg-secondary: #FFFFFF;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F5F7FA;
  --bg-elevated: #F8F9FC;
  --bg-input: #F0F2F5;
  --border-color: #E2E5EA;
  --border-light: #D0D4DB;
  --accent: #4C7CFF;
  --accent-hover: #3B6AE8;
  --accent-dim: rgba(76,124,255,0.08);
  --accent-glow: rgba(76,124,255,0.15);
  --success: #22C55E;
  --success-dim: rgba(34,197,94,0.08);
  --warning: #F59E0B;
  --warning-dim: rgba(245,158,11,0.08);
  --danger: #EF4444;
  --danger-dim: rgba(239,68,68,0.08);
  --text-primary: #1A1D26;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  --header-height: 0px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html, body {
  width:100%; height:100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border-color); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--border-light); }
button { cursor:pointer; border:none; background:none; font:inherit; color:inherit; }
input, select { font:inherit; color:inherit; }
a { color:var(--accent); text-decoration:none; }

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
  display:flex; width:100%; height:100%;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height:100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  box-shadow: 1px 0 8px rgba(0,0,0,0.03);
  display:flex; flex-direction:column;
  transition: width var(--transition), min-width var(--transition);
  z-index: 100;
  overflow: hidden;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}
.sidebar-brand {
  height: 60px;
  display:flex; align-items:center; gap:12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink:0;
  overflow:hidden;
  white-space:nowrap;
}
.sidebar-brand .brand-icon {
  width:32px; height:32px; flex-shrink:0;
  background: linear-gradient(135deg, var(--accent), #7B5CFF);
  border-radius: var(--radius-sm);
  display:flex; align-items:center; justify-content:center;
}
.sidebar-brand .brand-icon svg { width:18px; height:18px; }
.sidebar-brand .brand-text {
  font-size:16px; font-weight:700;
  background: linear-gradient(135deg, var(--accent), #A78BFA);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent;
  transition: opacity var(--transition);
}
.sidebar.collapsed .brand-text { opacity:0; }
.sidebar-nav {
  flex:1; padding:12px 10px; overflow-y:auto; overflow-x:hidden;
}
.nav-section-title {
  font-size:11px; text-transform:uppercase; letter-spacing:1px;
  color:var(--text-muted); padding:12px 10px 6px;
  white-space:nowrap; overflow:hidden;
}
.sidebar.collapsed .nav-section-title { opacity:0; height:0; padding:0; }
.nav-item {
  display:flex; align-items:center; gap:12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition);
  margin-bottom:2px;
  cursor:pointer;
  white-space:nowrap;
  overflow:hidden;
  position:relative;
}
.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.nav-item.active::before {
  content:'';
  position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:3px; height:20px;
  background:var(--accent);
  border-radius:0 3px 3px 0;
}
.nav-item svg { width:20px; height:20px; flex-shrink:0; }
.nav-item .nav-label { transition: opacity var(--transition); }
.sidebar.collapsed .nav-item .nav-label { opacity:0; }
.sidebar-footer {
  padding:12px 10px;
  border-top:1px solid var(--border-color);
  flex-shrink:0;
}
.sidebar-toggle {
  display:flex; align-items:center; gap:12px;
  padding:10px 14px;
  border-radius:var(--radius-md);
  color:var(--text-muted);
  transition:all var(--transition);
  width:100%;
}
.sidebar-toggle:hover { background:var(--bg-surface-hover); color:var(--text-secondary); }
.sidebar-toggle svg { width:20px; height:20px; flex-shrink:0; transition:transform var(--transition); }
.sidebar.collapsed .sidebar-toggle svg { transform:rotate(180deg); }
.sidebar.collapsed .sidebar-toggle .nav-label { opacity:0; }

/* ============================================================
   Main Content Area
   ============================================================ */
.main-content {
  flex:1; height:100%;
  display:flex; flex-direction:column;
  overflow:hidden;
  min-width:0;
}
.page-header {
  height:60px; flex-shrink:0;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 28px;
  border-bottom:1px solid var(--border-color);
  background:var(--bg-secondary);
}
.page-header h1 {
  font-size:18px; font-weight:600;
}
.page-header-actions { display:flex; gap:8px; align-items:center; }
.page-body {
  flex:1; overflow-y:auto; overflow-x:hidden;
  padding:24px 28px;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

/* ============================================================
   Upload Zone
   ============================================================ */
.upload-zone {
  border:2px dashed var(--border-light);
  border-radius:var(--radius-lg);
  padding:48px 24px;
  text-align:center;
  cursor:pointer;
  transition:all var(--transition);
  background:var(--bg-surface);
  position:relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color:var(--accent);
  background:var(--accent-dim);
}
.upload-zone.drag-over {
  transform:scale(1.01);
}
.upload-zone .upload-icon {
  width:64px; height:64px; margin:0 auto 16px;
  background:var(--accent-dim);
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  color:var(--accent);
}
.upload-zone .upload-icon svg { width:28px; height:28px; }
.upload-zone .upload-title { font-size:16px; font-weight:600; margin-bottom:6px; }
.upload-zone .upload-hint { font-size:13px; color:var(--text-secondary); }
.upload-zone input[type="file"] {
  position:absolute; inset:0; opacity:0; cursor:pointer;
}

/* File Info Card */
.file-info-card {
  background:var(--bg-surface);
  border:1px solid var(--border-color);
  border-radius:var(--radius-lg);
  padding:20px;
  display:none;
  /* 滚动时提升为独立合成层，避免视频/大图预览在主线程反复重绘导致卡顿 */
  transform:translateZ(0);
  contain:layout paint;
}
.file-info-card.visible { display:block; }
.file-info-header {
  display:flex; align-items:center; gap:14px;
  margin-bottom:16px;
}
.file-info-header .file-thumb {
  width:80px; height:80px;
  background:var(--bg-elevated);
  border-radius:var(--radius-md);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  flex-shrink:0;
}
.file-info-header .file-thumb img,
.file-info-header .file-thumb video {
  width:100%; height:100%; object-fit:cover;
}
.file-info-header .file-thumb svg { width:32px; height:32px; color:var(--text-muted); }
.file-info-meta { flex:1; min-width:0; }
.file-info-meta .file-name {
  font-size:15px; font-weight:600;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  margin-bottom:6px;
}
.file-info-meta .file-details {
  display:flex; flex-wrap:wrap; gap:12px;
  font-size:12px; color:var(--text-secondary);
}
.file-info-meta .file-details span {
  display:flex; align-items:center; gap:4px;
}

/* ============================================================
   Form Controls
   ============================================================ */
.settings-panel {
  background:var(--bg-surface);
  border:1px solid var(--border-color);
  border-radius:var(--radius-lg);
  padding:24px;
  margin-top:20px;
  display:none;
}
.settings-panel.visible { display:block; }
.settings-title {
  font-size:15px; font-weight:600;
  margin-bottom:20px;
  display:flex; align-items:center; gap:8px;
}
.settings-title svg { width:18px; height:18px; color:var(--accent); }
.settings-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:16px;
}
.form-group { display:flex; flex-direction:column; gap:6px; }
.form-group label {
  font-size:12px; font-weight:500;
  color:var(--text-secondary);
  text-transform:uppercase;
  letter-spacing:0.5px;
}
.form-group .input-wrap {
  display:flex; align-items:center;
  background:var(--bg-input);
  border:1px solid var(--border-color);
  border-radius:var(--radius-sm);
  overflow:hidden;
  transition:border-color var(--transition);
}
.form-group .input-wrap:focus-within {
  border-color:var(--accent);
}
.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
  flex:1;
  padding:10px 12px;
  background:transparent;
  border:none;
  outline:none;
  color:var(--text-primary);
  font-size:14px;
}
.form-group select { cursor:pointer; }
.form-group select option { background:var(--bg-surface); }
.form-group .input-suffix {
  padding:0 12px;
  font-size:12px;
  color:var(--text-muted);
  white-space:nowrap;
}

/* Range Slider */
.range-group { display:flex; flex-direction:column; gap:6px; }
.range-group label {
  font-size:12px; font-weight:500;
  color:var(--text-secondary);
  text-transform:uppercase;
  letter-spacing:0.5px;
}
.range-row {
  display:flex; align-items:center; gap:12px;
  background:var(--bg-input);
  border:1px solid var(--border-color);
  border-radius:var(--radius-sm);
  padding:10px 12px;
  transition:border-color var(--transition);
}
.range-row:focus-within {
  border-color:var(--accent);
}
/* 拖动时不触发样式重算，保证跟手 */
.range-row input[type="range"] {
  flex:1;
  -webkit-appearance:none;
  height:4px;
  background:var(--border-color);
  border-radius:2px;
  outline:none;
  touch-action:pan-y;
}
.range-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance:none;
  width:16px; height:16px;
  background:var(--accent);
  border-radius:50%;
  cursor:pointer;
  transition:transform var(--transition);
}
.range-row input[type="range"]::-webkit-slider-thumb:hover {
  transform:scale(1.2);
}
.range-value {
  min-width:44px;
  text-align:center;
  font-size:13px;
  font-weight:600;
  color:var(--accent);
  background:var(--accent-dim);
  padding:4px 8px;
  border-radius:var(--radius-sm);
}

/* Toggle Switch */
.toggle-group {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 0;
  border-bottom:1px solid var(--border-color);
}
.toggle-group:last-child { border-bottom:none; }
.toggle-info .toggle-label { font-size:14px; font-weight:500; }
.toggle-info .toggle-desc { font-size:12px; color:var(--text-secondary); margin-top:2px; }
.toggle-switch {
  width:44px; height:24px;
  background:var(--border-color);
  border-radius:12px;
  position:relative;
  cursor:pointer;
  transition:background var(--transition);
  flex-shrink:0;
}
.toggle-switch.active { background:var(--accent); }
.toggle-switch::after {
  content:'';
  position:absolute;
  top:3px; left:3px;
  width:18px; height:18px;
  background:#fff;
  border-radius:50%;
  transition:transform var(--transition);
}
.toggle-switch.active::after { transform:translateX(20px); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 20px;
  border-radius:var(--radius-sm);
  font-size:14px; font-weight:500;
  transition:all var(--transition);
  white-space:nowrap;
}
.btn svg { width:16px; height:16px; }
.btn-primary {
  background:var(--accent);
  color:#fff;
}
.btn-primary:hover { background:var(--accent-hover); box-shadow:0 4px 16px var(--accent-glow); }
.btn-primary:disabled { opacity:0.4; cursor:not-allowed; box-shadow:none; }
.btn:disabled,
.btn:disabled:hover {
  opacity:0.4;
  cursor:not-allowed;
  box-shadow:none;
  pointer-events:none;
}
.btn-secondary {
  background:var(--bg-elevated);
  color:var(--text-primary);
  border:1px solid var(--border-color);
}
.btn-secondary:hover { border-color:var(--border-light); background:var(--bg-surface-hover); }
.btn-danger { background:var(--danger); color:#fff; }
.btn-danger:hover { background:#C0392B; }
.btn-ghost {
  color:var(--text-secondary);
  padding:8px 12px;
}
.btn-ghost:hover { color:var(--text-primary); background:var(--bg-surface-hover); }
.btn-sm { padding:6px 14px; font-size:12px; }
.btn-lg { padding:14px 28px; font-size:16px; }
.btn-icon {
  width:36px; height:36px; padding:0;
  display:flex; align-items:center; justify-content:center;
  border-radius:var(--radius-sm);
  color:var(--text-secondary);
}
.btn-icon:hover { background:var(--bg-surface-hover); color:var(--text-primary); }
.btn-icon svg { width:18px; height:18px; }

/* ============================================================
   Video Player
   ============================================================ */
.video-player-container {
  background:var(--bg-surface);
  border:1px solid var(--border-color);
  border-radius:var(--radius-lg);
  overflow:hidden;
  margin-bottom:16px;
}
.video-preview {
  width:100%;
  aspect-ratio:16/9;
  background:#000;
  display:flex; align-items:center; justify-content:center;
  position:relative;
}
.video-preview video {
  max-width:100%; max-height:100%;
  /* 视频元素独立合成层，滚动时由 GPU 平移而非主线程重绘 */
  transform:translateZ(0);
}
.video-preview .placeholder-text {
  color:var(--text-muted);
  font-size:14px;
}
.video-controls {
  display:flex; align-items:center; gap:8px;
  padding:12px 16px;
  background:var(--bg-elevated);
  border-top:1px solid var(--border-color);
}
.video-controls .time-display {
  font-size:12px;
  font-family:'SF Mono', 'Consolas', monospace;
  color:var(--text-secondary);
  min-width:130px;
}
.video-controls .progress-bar {
  flex:1; height:4px;
  background:var(--border-color);
  border-radius:2px;
  cursor:pointer;
  position:relative;
}
.video-controls .progress-fill {
  height:100%;
  background:var(--accent);
  border-radius:2px;
  width:0%;
  transition:width 0.1s;
}
.frame-step-group {
  display:flex; gap:2px;
}
.frame-step-group .btn-icon { width:28px; height:28px; }
.frame-step-group .btn-icon svg { width:14px; height:14px; }

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position:fixed; inset:0;
  background:rgba(0,0,0,0.3);
  backdrop-filter:blur(6px);
  display:flex; align-items:center; justify-content:center;
  z-index:1000;
  opacity:0;
  visibility:hidden;
  transition:all 0.25s;
}
.modal-overlay.visible {
  opacity:1; visibility:visible;
}
.modal {
  background:var(--bg-surface);
  border:1px solid var(--border-color);
  border-radius:var(--radius-xl);
  min-width:380px;
  max-width:480px;
  box-shadow:var(--shadow-lg);
  transform:scale(0.95) translateY(10px);
  transition:transform 0.25s;
}
.modal-overlay.visible .modal {
  transform:scale(1) translateY(0);
}
.modal-header {
  display:flex; align-items:center; gap:12px;
  padding:20px 24px 0;
}
.modal-icon {
  width:40px; height:40px; flex-shrink:0;
  border-radius:50%;
  display:flex; align-items:center; justify-content:center;
}
.modal-icon svg { width:20px; height:20px; }
.modal-icon.success { background:var(--success-dim); color:var(--success); }
.modal-icon.error { background:var(--danger-dim); color:var(--danger); }
.modal-icon.warning { background:var(--warning-dim); color:var(--warning); }
.modal-icon.info { background:var(--accent-dim); color:var(--accent); }
.modal-title { font-size:16px; font-weight:600; }
.modal-body {
  padding:12px 24px 20px;
  padding-left:76px;
  font-size:14px;
  color:var(--text-secondary);
  line-height:1.6;
}
.modal-footer {
  display:flex; justify-content:flex-end; gap:8px;
  padding:0 24px 20px;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position:fixed;
  top:20px; right:20px;
  z-index:2000;
  display:flex; flex-direction:column; gap:8px;
}
.toast {
  display:flex; align-items:center; gap:10px;
  padding:12px 18px;
  background:var(--bg-elevated);
  border:1px solid var(--border-color);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-md);
  min-width:280px;
  max-width:400px;
  animation:toastIn 0.3s forwards;
}
.toast.removing { animation:toastOut 0.3s forwards; }
.toast-icon { width:20px; height:20px; flex-shrink:0; }
.toast-message { flex:1; font-size:13px; }
.toast-close {
  width:16px; height:16px;
  color:var(--text-muted);
  cursor:pointer;
  flex-shrink:0;
}
.toast.success { border-left:3px solid var(--success); }
.toast.success .toast-icon { color:var(--success); }
.toast.error { border-left:3px solid var(--danger); }
.toast.error .toast-icon { color:var(--danger); }
.toast.warning { border-left:3px solid var(--warning); }
.toast.warning .toast-icon { color:var(--warning); }
.toast.info { border-left:3px solid var(--accent); }
.toast.info .toast-icon { color:var(--accent); }

@keyframes toastIn {
  from { transform:translateX(100%); opacity:0; }
  to { transform:translateX(0); opacity:1; }
}
@keyframes toastOut {
  from { transform:translateX(0); opacity:1; }
  to { transform:translateX(100%); opacity:0; }
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align:center;
  padding:48px 24px;
  color:var(--text-muted);
}
.empty-state svg { width:48px; height:48px; margin-bottom:12px; }
.empty-state p { font-size:14px; }

/* ============================================================
   Section title utility
   ============================================================ */
.section-title {
  font-size:15px; font-weight:600;
  margin-bottom:14px;
  display:flex; align-items:center; gap:8px;
}
.section-title svg { width:18px; height:18px; color:var(--accent); }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn {
  from { opacity:0; transform:translateY(8px); }
  to { opacity:1; transform:translateY(0); }
}
.fade-in { animation:fadeIn 0.3s ease; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width:900px) {
  .sidebar { width:var(--sidebar-collapsed); min-width:var(--sidebar-collapsed); }
  .sidebar .brand-text,
  .sidebar .nav-label,
  .sidebar .nav-section-title { opacity:0; }
}
@media (max-width:700px) {
  .page-body { padding:16px; }
}

/* 图片压缩页大预览：滚动时独立合成层，避免大图重绘卡顿 */
#image-original-preview,
#image-compressed-preview {
  transform:translateZ(0);
}

/* ============================================================
   Output Info Card（压缩后文件名/大小/压缩率）
   ============================================================ */
.output-info {
  background:var(--bg-surface);
  border:1px solid var(--border-color);
  border-radius:var(--radius-lg);
  padding:16px 20px;
}
.output-info-title {
  display:flex; align-items:center; gap:8px;
  font-size:13px; font-weight:600;
  color:var(--text-primary);
  margin-bottom:12px;
  padding-bottom:10px;
  border-bottom:1px solid var(--border-color);
}
.output-info-title svg { color:var(--accent); }
.output-info-row {
  display:flex; align-items:center; justify-content:space-between;
  gap:12px;
  padding:6px 0;
}
.output-info-row .oi-label {
  font-size:12px;
  color:var(--text-muted);
  flex-shrink:0;
}
.output-info-row .oi-value {
  font-size:13px;
  font-weight:500;
  color:var(--text-primary);
  text-align:right;
  word-break:break-all;
  font-family:'SF Mono','Consolas',monospace;
}
.output-info-row .oi-value.oi-accent {
  color:var(--accent);
  font-weight:700;
}
.output-info-row .oi-value.oi-rate {
  color:var(--success);
  font-weight:700;
}
