:root {
  --bg-primary: #080811;
  --bg-secondary: #0f0f1d;
  --bg-card: rgba(22, 22, 38, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(168, 85, 247, 0.5);
  
  --primary: #8b5cf6;
  --primary-glow: rgba(139, 92, 246, 0.35);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --font-en: 'Outfit', sans-serif;
  --font-th: 'Kanit', sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-th);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
}

/* NAVBAR */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 36px;
  background: rgba(15, 15, 29, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-text h1 {
  font-family: var(--font-en);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.2);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
}

.dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

/* APP CONTAINER */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* WORKSPACE GRID */
.studio-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  min-height: calc(100vh - 120px);
}

@media (max-width: 1200px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

/* CARDS */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* LEFT COLUMN: VIDEO PLAYER & CONTROLS */
.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upload-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(15, 15, 29, 0.8);
}

.upload-placeholder:hover {
  border-color: var(--primary);
  background: rgba(22, 22, 45, 0.9);
}

.upload-icon-pulse {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* STEPPER WIZARD */
.stepper {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.step-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}

.step-item:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.6);
  color: #fff;
  transform: translateY(-2px);
}

.step-item.active {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.step-item.done {
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.step-item.done:hover {
  background: rgba(16, 185, 129, 0.22);
  border-color: #34d399;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* SETTINGS & ACTION BAR */
.config-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.custom-select, .custom-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.custom-select:focus, .custom-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

/* BUTTONS */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* RIGHT COLUMN: SUBTITLE TIMELINE EDITOR */
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 16px;
}

.subtitle-list {
  flex: 1;
  overflow-y: auto;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}

.subtitle-list::-webkit-scrollbar {
  width: 6px;
}

.subtitle-list::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 3px;
}

.sub-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: all 0.2s;
  cursor: pointer;
}

.sub-item:hover, .sub-item.active {
  border-color: var(--primary);
  background: rgba(30, 27, 75, 0.6);
}

.sub-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--accent-cyan);
  font-family: var(--font-en);
  margin-bottom: 8px;
}

.sub-dual-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sub-input-box {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 48px;
  font-family: inherit;
}

.sub-input-box.translated {
  border-color: rgba(139, 92, 246, 0.3);
  color: #e2e8f0;
}

/* PROGRESS OVERLAY */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.progress-card {
  width: 100%;
  max-width: 660px;
  background: rgba(18, 18, 38, 0.96);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 20px;
  padding: 28px;
  text-align: left;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(139, 92, 246, 0.15);
  position: relative;
  overflow: hidden;
}

/* TOP HEADER */
.proc-header {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.proc-status-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.proc-status-ring.running {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 2px solid #8b5cf6;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
  animation: pulse-ring 2s infinite;
}

.proc-status-ring.completed {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 2px solid #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.proc-status-ring.error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 2px solid #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
  animation: shake 0.5s;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.proc-title-col {
  flex: 1;
  min-width: 0;
}

.proc-title-col h3 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proc-title-col p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.badge-pill.timer {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-family: var(--font-en);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* PROGRESS BAR SECTION */
.proc-bar-section {
  background: rgba(10, 10, 24, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.proc-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.proc-pct-label {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-en);
  color: #38bdf8;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

.proc-audio-time {
  font-size: 12.5px;
  font-family: var(--font-en);
  color: #cbd5e1;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.proc-progress-track {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.proc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #38bdf8);
  border-radius: 6px;
  transition: width 0.3s ease-out;
  position: relative;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
}

.proc-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* SPEECH BUBBLE PREVIEW */
.proc-live-bubble {
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  position: relative;
}

.live-bubble-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: #a78bfa;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-bubble-text {
  font-size: 13.5px;
  color: #f1f5f9;
  line-height: 1.5;
  font-style: italic;
  min-height: 22px;
  word-break: break-word;
}

/* TERMINAL CONSOLE LOGS */
.proc-console-box {
  background: #090912;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--font-en);
}

.console-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

.console-body {
  height: 120px;
  overflow-y: auto;
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.console-body::-webkit-scrollbar {
  width: 5px;
}
.console-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.log-line {
  display: flex;
  gap: 8px;
  word-break: break-all;
}

.log-time {
  color: #64748b;
  flex-shrink: 0;
  font-size: 11px;
}

.log-line.info .log-msg { color: #cbd5e1; }
.log-line.success .log-msg { color: #34d399; font-weight: 500; }
.log-line.error .log-msg { color: #f87171; font-weight: 600; }

/* ERROR CARD */
.proc-error-card {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 16px;
}

.error-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.error-icon {
  font-size: 24px;
  color: #ef4444;
  margin-top: 2px;
  flex-shrink: 0;
}

.error-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: #fee2e2;
  margin: 0 0 4px;
}

.error-details-collapsible {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #cbd5e1;
}

.error-details-collapsible summary {
  cursor: pointer;
  font-weight: 600;
  color: #fca5a5;
  outline: none;
}

.error-pre {
  margin-top: 8px;
  max-height: 140px;
  overflow-y: auto;
  font-family: var(--font-en);
  font-size: 11px;
  color: #fecaca;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px;
  border-radius: 6px;
}

.error-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.fa-spin-slow {
  animation: spin 3s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
