/* DAG Editor - estilos globais (extraído do index.html na modularização) */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #666;
  margin-bottom: 40px;
  font-size: 16px;
}

/* Upload */
.upload-zone {
  border: 2px dashed #333;
  border-radius: 16px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #111;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #6366f1;
  background: #1a1a2e;
}
.upload-zone.has-file {
  border-color: #22c55e;
  background: #0a1f0a;
}
.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}
.upload-text { font-size: 18px; color: #888; }
.upload-hint { font-size: 13px; color: #555; margin-top: 8px; }
.file-name {
  font-size: 16px;
  color: #22c55e;
  font-weight: 600;
  margin-top: 12px;
}
input[type="file"] { display: none; }

/* Opções */
.options-section { margin-top: 20px; }
.options-label {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.option-card {
  flex: 1;
  min-width: 140px;
  padding: 16px;
  background: #111;
  border: 2px solid #333;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}
.option-card:hover { border-color: #6366f1; background: #1a1a2e; }
.option-card.selected { border-color: #a855f7; background: #1a1a2e; }
.option-card .option-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.option-card .option-title { font-size: 14px; font-weight: 600; color: #e0e0e0; }
.option-card .option-desc { font-size: 11px; color: #666; margin-top: 4px; }

/* Botão */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 24px;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: white;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99,102,241,0.3); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-download {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  text-decoration: none;
}

/* Pipeline */
.pipeline { margin-top: 40px; display: none; }
.pipeline.active { display: block; }

.pipeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.pipeline-title { font-size: 20px; font-weight: 600; }
.pipeline-progress-text { font-size: 14px; color: #888; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 32px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

/* Steps */
.steps { display: flex; flex-direction: column; gap: 12px; }
.step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #111;
  border-radius: 12px;
  border: 1px solid #222;
  transition: all 0.3s;
}
.step.active {
  border-color: #6366f1;
  background: #1a1a2e;
}
.step.done {
  border-color: #22c55e;
  background: #0a1f0a;
}
.step.error {
  border-color: #ef4444;
  background: #1f0a0a;
}
.step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: #222;
}
.step.active .step-icon { background: #6366f1; }
.step.done .step-icon { background: #22c55e; }
.step.error .step-icon { background: #ef4444; }
.step-text { font-size: 15px; flex: 1; }
.step-timer {
  font-size: 12px;
  color: #555;
  font-family: monospace;
  min-width: 45px;
  text-align: right;
}
.step.active .step-timer { color: #a855f7; }
.step.done .step-timer { color: #22c55e; }

/* Resultado */
.result {
  margin-top: 32px;
  padding: 24px;
  background: #111;
  border-radius: 16px;
  border: 1px solid #22c55e;
  text-align: center;
  display: none;
}
.result.active { display: block; }
.result-title {
  font-size: 20px;
  font-weight: 600;
  color: #22c55e;
  margin-bottom: 16px;
}

/* Custo */
.cost-box {
  display: none;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}
.cost-box.active { display: block; }
.cost-title { font-size: 14px; color: #888; margin-bottom: 10px; font-weight: 600; }
.cost-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: #aaa;
}
.cost-row.total {
  border-top: 1px solid #333;
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 15px;
  color: #a855f7;
}

/* Revisão */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Modo embed: esconder só o histórico */
body.embed-mode .history { display: none !important; }
body.embed-mode .container { padding-top: 10px; }

.review-panel { display: none; margin-top: 32px; }
.review-panel.active { display: block; }
.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.review-title { font-size: 20px; font-weight: 600; }
.review-info { font-size: 13px; color: #888; }

/* Indicador de autosave */
.save-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.save-status.saved { color: #22c55e; background: #0a1f0a; }
.save-status.dirty { color: #eab308; background: #1f1a0a; }
.save-status.saving { color: #6366f1; background: #1a1a2e; }
.save-status.error { color: #ef4444; background: #1f0a0a; cursor: pointer; }

/* Player */
.review-player { margin-bottom: 16px; }
.player-wrapper { position: relative; border-radius: 12px; overflow: hidden; background: #000; }
.review-video {
  width: 100%;
  max-height: 400px;
  display: block;
}
.preview-overlay-top {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #E11D48;
  color: white;
  font-weight: 900;
  font-size: 16px;
  padding: 4px 14px;
  border-radius: 4px;
  text-transform: uppercase;
  display: none;
  text-align: center;
  max-width: 90%;
  z-index: 5;
}
.preview-overlay-top.visible { display: block; }
.preview-overlay-bottom {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-weight: 800;
  font-size: 18px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.5);
  display: none;
  text-align: center;
  max-width: 85%;
  z-index: 5;
}
.preview-overlay-bottom.visible { display: block; }
.preview-zoom-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(99,102,241,0.8);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  display: none;
  z-index: 5;
}
.preview-zoom-badge.visible { display: block; }
.review-player-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  font-size: 12px;
  color: #666;
  gap: 8px;
  flex-wrap: wrap;
}
.preview-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; font-size: 11px; color: #888; }
.preview-toggle input { cursor: pointer; }
.preview-btn {
  padding: 6px 16px;
  background: #6366f1;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.preview-btn:hover { background: #818cf8; }

/* Timeline v2 - representa o vídeo FINAL (output), não o original */
.timeline-container { margin-bottom: 20px; }
.timeline-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}
.timeline-toolbar .tl-group { display: flex; align-items: center; gap: 4px; }
.tl-btn {
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1a1a;
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tl-btn:hover { background: #333; color: white; border-color: #6366f1; }
.tl-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tl-sep { width: 1px; height: 18px; background: #333; margin: 0 4px; }

.timeline-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  background: #141414;
  padding-bottom: 2px;
}
.timeline-track {
  position: relative;
  height: 64px;
  background: #1a1a1a;
  border-radius: 8px;
  min-width: 100%;
}
.tl-clip {
  position: absolute;
  top: 4px;
  height: 56px;
  background: #26264a;
  border: 1px solid #4f4f8f;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}
.tl-clip.active { border-color: #a855f7; box-shadow: 0 0 0 1px #a855f7; }
.tl-clip.dragging { opacity: 0.45; cursor: grabbing; }
.tl-thumbs {
  display: flex;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.tl-thumb {
  flex: 1;
  min-width: 0;
  object-fit: cover;
  opacity: 0.8;
}
.tl-label {
  position: absolute;
  left: 5px;
  top: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.6);
  padding: 1px 6px;
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}
.tl-clip .clip-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  background: rgba(255,255,255,0.18);
  z-index: 3;
}
.tl-clip .clip-handle:hover { background: rgba(255,255,255,0.45); }
.clip-handle-left { left: 0; border-radius: 6px 0 0 6px; }
.clip-handle-right { right: 0; border-radius: 0 6px 6px 0; }
.tl-insert-indicator {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: #22c55e;
  border-radius: 2px;
  z-index: 12;
  pointer-events: none;
}
.timeline-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #ef4444;
  z-index: 10;
  pointer-events: none;
  left: 0;
}
.timeline-ruler {
  position: relative;
  height: 18px;
  font-size: 10px;
  color: #555;
  font-family: monospace;
}
.ruler-tick {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  white-space: nowrap;
}
.timeline-hint {
  font-size: 10px;
  color: #444;
  margin-top: 6px;
}
.timeline-hint kbd {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0 4px;
  font-family: inherit;
}

/* Lista compacta */
.scenes-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.scene-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
}
.scene-chip:hover { border-color: #6366f1; color: white; }
.scene-chip.active { border-color: #a855f7; background: #1a1a2e; color: white; }
.scene-chip .chip-play { color: #6366f1; }
.scene-chip .chip-remove {
  color: #555;
  cursor: pointer;
  margin-left: 4px;
}
.scene-chip .chip-remove:hover { color: #ef4444; }

/* Painel de ajuste fino - popup flutuante */
.scene-edit-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 700px;
  padding: 14px 18px;
  background: #111;
  border: 1px solid #6366f1;
  border-radius: 12px;
  display: none;
  z-index: 100;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.6);
}
.scene-edit-panel.open { display: block; }
.scene-edit-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
}
.scene-edit-close:hover { color: white; }
.scene-edit-title { font-size: 13px; color: #888; font-weight: 600; margin-bottom: 8px; }
.scene-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.scene-edit-row label {
  font-size: 12px;
  color: #888;
  min-width: 45px;
}
.scene-edit-row input {
  width: 80px;
  padding: 6px 8px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-family: monospace;
  text-align: center;
}
.scene-edit-row input:focus { outline: none; border-color: #6366f1; }
.nudge-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1a1a;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.nudge-btn:hover { background: #333; color: white; border-color: #6366f1; }
.nudge-label { font-size: 10px; color: #555; }
.scene-edit-preview {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.scene-edit-preview button {
  padding: 5px 14px;
  background: #6366f1;
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  cursor: pointer;
}
.scene-edit-preview button:hover { background: #818cf8; }
.overlay-controls { margin-top: 8px; padding-top: 8px; border-top: 1px solid #222; }
.overlay-controls label { font-size: 11px; color: #888; }
.overlay-controls input[type="range"] {
  width: 100%;
  accent-color: #a855f7;
  margin: 4px 0;
}
.overlay-pos-label { font-size: 11px; color: #666; display: flex; justify-content: space-between; }
.overlay-text-edit {
  width: 100%;
  padding: 6px 8px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: white;
  font-size: 13px;
  margin-top: 4px;
}
.overlay-text-edit:focus { outline: none; border-color: #a855f7; }
/* Cores */
.color-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.color-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  width: 100%;
  margin-bottom: 2px;
}
.color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.color-row label { font-size: 11px; color: #666; white-space: nowrap; }
.color-row input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid #333;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 0;
}

.review-actions { display: flex; gap: 12px; }

/* Duração máxima */
.duration-row {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.duration-row label {
  font-size: 14px;
  color: #888;
  white-space: nowrap;
}
.duration-input {
  width: 80px;
  padding: 8px 12px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  text-align: center;
}
.duration-input:focus { outline: none; border-color: #6366f1; }
.duration-hint { font-size: 11px; color: #555; }

/* Histórico */
.history {
  margin-top: 48px;
  border-top: 1px solid #1a1a1a;
  padding-top: 32px;
}
.history-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #888;
}
.history-empty { font-size: 14px; color: #444; }
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  gap: 12px;
}
.history-item .hi-info { flex: 1; min-width: 0; }
.history-item .hi-id { font-size: 12px; color: #555; font-family: monospace; }
.history-item .hi-meta {
  font-size: 13px;
  color: #aaa;
  margin-top: 4px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.history-item .hi-meta span { white-space: nowrap; }
.hi-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.hi-status.completed { background: #0a1f0a; color: #22c55e; border: 1px solid #22c55e33; }
.hi-status.error { background: #1f0a0a; color: #ef4444; border: 1px solid #ef444433; }
.hi-status.processing { background: #1a1a2e; color: #6366f1; border: 1px solid #6366f133; }
.hi-actions { display: flex; gap: 8px; flex-shrink: 0; }
.hi-actions a {
  font-size: 12px;
  padding: 6px 14px;
  background: #222;
  border-radius: 6px;
  color: #aaa;
  text-decoration: none;
  transition: all 0.2s;
}
.hi-actions a:hover { background: #333; color: white; }
.hi-cost-detail {
  display: none;
  margin-top: 8px;
  padding: 8px 12px;
  background: #0a0a0a;
  border-radius: 6px;
  font-size: 12px;
  color: #777;
}
.hi-cost-detail.open { display: block; }
.hi-cost-detail div { display: flex; justify-content: space-between; padding: 2px 0; }
.hi-cost-toggle {
  font-size: 11px;
  color: #555;
  cursor: pointer;
  text-decoration: underline;
}
.hi-cost-toggle:hover { color: #a855f7; }
.history-total {
  margin-top: 16px;
  padding: 12px 18px;
  background: #1a1a2e;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
}
.history-total .ht-label { color: #888; }
.history-total .ht-value { color: #a855f7; }
.history-pager {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.pager-btn {
  padding: 6px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
}
.pager-btn:hover { border-color: #6366f1; color: white; }
.pager-btn.active { background: #6366f1; border-color: #6366f1; color: white; }

/* Erro */
.error-box {
  margin-top: 16px;
  padding: 16px;
  background: #1f0a0a;
  border: 1px solid #ef4444;
  border-radius: 8px;
  color: #ef4444;
  font-size: 14px;
  display: none;
}
.error-box.active { display: block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
