/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0c;
  --surface: #111115;
  --surface2: #18181f;
  --surface3: #1e1e28;
  --border: rgba(255,255,255,0.07);
  --border-bright: rgba(255,255,255,0.14);
  --accent: #c8f057;
  --accent2: #7b5cfa;
  --accent3: #f05798;
  --text: #f0f0f5;
  --text-muted: #6b6b80;
  --text-dim: #3a3a4a;
  --danger: #ff4a6e;
  --success: #57f0a8;
  --radius: 14px;
  --radius-sm: 8px;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
  --panel-w: 340px;
  --preview-min-h: 500px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-head);
  overflow: hidden;
}

/* ===== APP SHELL ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,12,0.9);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo-icon {
  color: var(--accent);
  font-size: 18px;
  animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.logo-text em {
  font-style: normal;
  color: var(--accent);
}

.header-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 100px;
  letter-spacing: 0.5px;
}

/* ===== WORKSPACE ===== */
.workspace {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  flex: 1;
  overflow: hidden;
}

/* ===== PANELS ===== */
.panel {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--surface3) transparent;
}
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 2px; }

.controls-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.preview-panel {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px 32px;
  gap: 18px;
  position: relative;
}

/* ===== CONTROL SECTIONS ===== */
.control-section {
  padding: 22px 22px 24px;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition);
}

.control-section.locked {
  opacity: 0.38;
  pointer-events: none;
}
.control-section.locked .section-label .dot { background: var(--text-dim); }

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent);
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 1.5px dashed var(--border-bright);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--surface2);
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(200,240,87,0.04);
}

.upload-icon {
  font-size: 28px;
  margin-bottom: 10px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.upload-zone:hover .upload-icon { color: var(--accent); }

.upload-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.upload-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.file-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}
.btn-reset {
  background: none;
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-reset:hover { border-color: var(--danger); color: var(--danger); }

/* ===== SLIDERS ===== */
.trim-block { display: flex; flex-direction: column; gap: 16px; }

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slider-row label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.time-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 5px;
  color: var(--accent);
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: background var(--transition);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
  box-shadow: 0 0 0 3px rgba(200,240,87,0.2), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform var(--transition), box-shadow var(--transition);
}
.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
  box-shadow: 0 0 0 6px rgba(200,240,87,0.15), 0 2px 12px rgba(0,0,0,0.5);
}
.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: grab;
}

.duration-warning {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--danger);
  background: rgba(255,74,110,0.08);
  border: 1px solid rgba(255,74,110,0.25);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* ===== PLAYBACK ===== */
.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.playback-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-head);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-upload {
  background: var(--accent);
  color: #0a0a0c;
  padding: 10px 22px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.btn-upload:hover { background: #d8ff6a; transform: translateY(-1px); }

.btn-play {
  background: var(--surface3);
  border: 1.5px solid var(--border-bright);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-play:hover { border-color: var(--accent); color: var(--accent); }
.btn-play.playing { background: rgba(200,240,87,0.1); border-color: var(--accent); color: var(--accent); }

.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, var(--accent2), var(--accent3));
  color: #fff;
  padding: 14px 20px;
  font-size: 15px;
  border-radius: var(--radius);
  letter-spacing: -0.2px;
  box-shadow: 0 4px 24px rgba(123,92,250,0.3);
  cursor: pointer;
  border: none;
  font-family: var(--font-head);
  font-weight: 700;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(123,92,250,0.45);
}
.btn-generate:active { transform: translateY(0); }
.btn-generate-icon { font-size: 18px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.btn-download {
  width: 100%;
  background: var(--success);
  color: #0a0a0c;
  padding: 14px 20px;
  font-size: 15px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font-head);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 12px;
}
.btn-download:hover { background: #6fffc2; transform: translateY(-2px); }

/* ===== PROGRESS ===== */
.progress-wrap {
  margin-top: 16px;
}
.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--surface3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent3));
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(123,92,250,0.5);
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* ===== PREVIEW TOOLBAR ===== */
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  width: 100%;
  max-width: 520px;
}
.tool-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(200,240,87,0.05); }
.zoom-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 42px;
  text-align: center;
}
.toolbar-sep { flex: 1; }
.ratio-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(123,92,250,0.15);
  border: 1px solid rgba(123,92,250,0.3);
  color: var(--accent2);
  padding: 4px 10px;
  border-radius: 100px;
}

/* ===== PREVIEW STAGE ===== */
.preview-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse at 30% 40%, rgba(123,92,250,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(240,87,152,0.05) 0%, transparent 60%),
    var(--surface);
  min-height: var(--preview-min-h);
  max-height: calc(100vh - 180px);
}

.placeholder-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.placeholder-icon {
  font-size: 48px;
  color: var(--text-dim);
}
.placeholder-text {
  font-size: 16px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

/* ===== CROP FRAME ===== */
.crop-frame {
  position: relative;
  overflow: hidden;
  /* 9:16 ratio — height set by JS based on available space */
  background: #000;
  flex-shrink: 0;
}

.video-drag-area {
  position: absolute;
  inset: 0;
  cursor: grab;
  overflow: hidden;
}
.video-drag-area:active { cursor: grabbing; }

#previewVideo {
  position: absolute;
  display: block;
  transform-origin: 0 0;
  /* position + scale driven by JS */
  user-select: none;
  pointer-events: none;
}

.crop-border {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(200,240,87,0.6);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(200,240,87,0.15);
}

/* corner decorators */
.crop-border::before, .crop-border::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}
.crop-border::before {
  top: -1px; left: -1px;
  border-top-width: 3px;
  border-left-width: 3px;
}
.crop-border::after {
  bottom: -1px; right: -1px;
  border-bottom-width: 3px;
  border-right-width: 3px;
}

.preview-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hand-icon { font-size: 16px; }

/* ===== SCROLLBAR ===== */
.controls-panel::-webkit-scrollbar { width: 3px; }
.controls-panel::-webkit-scrollbar-thumb { background: var(--surface3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
  :root { --panel-w: 100%; }
  .workspace { grid-template-columns: 1fr; overflow-y: auto; }
  .preview-panel { min-height: 60vw; }
  html, body { overflow: auto; }
  .app { height: auto; }
}

/* ===== PREVIEW CONTROLS BAR ===== */
.preview-controls-bar {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Timeline */
.timeline-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.time-current, .time-total {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 42px;
}
.time-current { color: var(--accent); text-align: right; }

.timeline-track-wrap {
  position: relative;
  flex: 1;
  height: 20px;
  display: flex;
  align-items: center;
}

/* highlight the selected trim region on the timeline */
.timeline-range-highlight {
  position: absolute;
  height: 4px;
  background: rgba(200,240,87,0.25);
  border-radius: 2px;
  pointer-events: none;
  left: 0; right: 0; /* updated via JS */
  top: 50%; transform: translateY(-50%);
}

.timeline-slider {
  position: relative;
  z-index: 2;
  background: transparent;
}
.timeline-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--surface3);
  border-radius: 2px;
}
.timeline-slider::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  box-shadow: 0 0 0 2px rgba(200,240,87,0.3), 0 2px 6px rgba(0,0,0,0.4);
}

/* Bottom row */
.preview-bottom-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Inline play/pause under video */
.btn-preview-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1.5px solid var(--border-bright);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.btn-preview-play:hover { border-color: var(--accent); color: var(--accent); }
.btn-preview-play.playing { background: rgba(200,240,87,0.1); border-color: var(--accent); color: var(--accent); }

/* Volume */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vol-icon { color: var(--text-muted); flex-shrink: 0; }

.volume-slider {
  width: 80px;
  height: 3px;
  background: var(--surface3);
  border-radius: 2px;
}
.volume-slider::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  background: var(--text);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
}
.volume-slider::-webkit-slider-thumb:hover {
  background: var(--accent);
}

.hint-inline {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
}
