:root {
  --vs-primary: #4f46e5;
  --vs-primary-dark: #4338ca;
  --vs-accent: #06b6d4;
  --vs-bg: #f7f8fc;
  --vs-card: #ffffff;
  --vs-text: #1f2937;
  --vs-muted: #6b7280;
  --vs-border: #e5e7eb;
  --vs-success: #16a34a;
  --vs-danger: #dc2626;
  --vs-warning: #d97706;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--vs-bg);
  color: var(--vs-text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}

.container { max-width: 1100px; }

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--vs-primary) 0%, var(--vs-primary-dark) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.site-header .brand { color: #fff; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.18);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-right: 10px;
}
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.site-header .nav-link {
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.site-header .nav-link:hover { color: #fff; background: rgba(255,255,255,0.12); }
.site-header .nav-link.active { color: #fff; background: rgba(255,255,255,0.18); }

/* Upload area */
.upload-zone {
  border: 2px dashed var(--vs-border);
  border-radius: 14px;
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--vs-card);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}
.upload-zone:hover {
  border-color: var(--vs-primary);
  background: #fbfbff;
}
.upload-zone.dragging {
  border-color: var(--vs-primary);
  background: #eef2ff;
  transform: scale(1.01);
}
.upload-zone .upload-icon {
  font-size: 3rem;
  color: var(--vs-primary);
  margin-bottom: 1rem;
}
.upload-zone h4 { font-weight: 700; margin-bottom: 0.25rem; }
.upload-zone .text-muted { font-size: 0.9rem; }

/* Cards */
.card {
  background: var(--vs-card);
  border: 1px solid var(--vs-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.card-title { font-weight: 700; }

/* Buttons */
.btn-primary {
  background: var(--vs-primary);
  border-color: var(--vs-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--vs-primary-dark);
  border-color: var(--vs-primary-dark);
}
.btn-outline-primary {
  color: var(--vs-primary);
  border-color: var(--vs-primary);
}
.btn-outline-primary:hover {
  background: var(--vs-primary);
  border-color: var(--vs-primary);
}

/* Duration picker */
.duration-options { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.duration-option {
  flex: 1;
  min-width: 110px;
  padding: 1rem 0.5rem;
  border: 2px solid var(--vs-border);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
}
.duration-option:hover { border-color: var(--vs-primary); }
.duration-option.selected {
  border-color: var(--vs-primary);
  background: #eef2ff;
  color: var(--vs-primary-dark);
}
.duration-option .duration-num {
  font-size: 1.6rem;
  font-weight: 700;
  display: block;
  line-height: 1;
}
.duration-option .duration-unit { font-size: 0.8rem; color: var(--vs-muted); }

/* Progress */
.progress {
  background: var(--vs-border);
  border-radius: 8px;
  height: 10px;
}
.progress-bar {
  background: var(--vs-primary);
  transition: width 0.3s ease;
}

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem; font-weight: 600;
}
.status-uploaded   { background: #e5e7eb; color: #374151; }
.status-queued     { background: #cffafe; color: #0e7490; }
.status-processing { background: #fef3c7; color: #92400e; }
.status-completed  { background: #dcfce7; color: #166534; }
.status-failed     { background: #fee2e2; color: #991b1b; }
.status-stopped    { background: #e5e7eb; color: #374151; }
.status-waiting    { background: #cffafe; color: #0e7490; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.status-processing .status-dot { animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Video info card */
.video-info-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.video-info-card .info-cell {
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-radius: 8px;
}
.video-info-card .info-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--vs-muted);
  font-weight: 600;
}
.video-info-card .info-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--vs-text);
  margin-top: 0.15rem;
}

/* Result grid */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.result-card {
  background: #fff;
  border: 1px solid var(--vs-border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.result-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.result-card .thumb-wrap {
  position: relative;
  background: #000;
  aspect-ratio: 16/9;
  cursor: pointer;
}
.result-card .thumb-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.result-card .thumb-wrap .play-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2rem;
  opacity: 0; transition: opacity 0.15s;
}
.result-card .thumb-wrap:hover .play-overlay { opacity: 1; }
.result-card .thumb-wrap .part-tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(15,23,42,0.85);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.result-card .thumb-wrap .duration-tag {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(15,23,42,0.85);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
}
.result-card .card-body { padding: 0.75rem 1rem; }
.result-card .file-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.result-card .file-meta {
  font-size: 0.78rem;
  color: var(--vs-muted);
  margin-bottom: 0.6rem;
}
.result-card .btn-group-compact .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

/* Spinner */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
}
.spinner-border { width: 3rem; height: 3rem; color: var(--vs-primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--vs-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

/* Mobile */
@media (max-width: 575.98px) {
  .container { padding-left: 0.85rem; padding-right: 0.85rem; }
  .upload-zone { padding: 2rem 0.75rem; }
  .upload-zone .upload-icon { font-size: 2.25rem; }
  .duration-option { min-width: calc(33% - 4px); padding: 0.75rem 0.25rem; }
  .duration-option .duration-num { font-size: 1.25rem; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.65rem; }
  .result-card .card-body { padding: 0.5rem 0.65rem; }
  .btn-mobile-full { width: 100%; }
}

/* Admin */
.admin-sidebar {
  background: #fff;
  border-right: 1px solid var(--vs-border);
  min-height: calc(100vh - 0px);
}
.admin-sidebar .nav-link {
  color: var(--vs-text);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 4px;
  font-weight: 500;
}
.admin-sidebar .nav-link:hover { background: #f3f4f6; }
.admin-sidebar .nav-link.active {
  background: #eef2ff;
  color: var(--vs-primary-dark);
}
.stat-card {
  background: #fff;
  border: 1px solid var(--vs-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--vs-muted); margin-top: 4px; }

.login-card {
  max-width: 380px;
  margin: 5vh auto 0;
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--vs-primary), var(--vs-primary-dark));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.8rem;
}

/* Toast notifications */
.toast-container {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999;
  max-width: 360px;
}

/* Logs / code blocks */
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Video Output Settings (v2) ---------- */
.output-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .5rem .75rem;
    padding: .85rem 1rem;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: .6rem;
    background: rgba(13, 110, 253, .04);
}
.output-summary .summary-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.output-summary .summary-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6c757d;
}
.output-summary .summary-value {
    font-weight: 600;
    font-size: .9rem;
    overflow-wrap: anywhere;
}
@media (max-width: 575.98px) {
    .output-summary { grid-template-columns: 1fr 1fr; }
}
