/* editor.css — AI Editor page styles */
/* Extends tools-dashboard CSS variables (--td-*) */

.editor-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--td-border);
}

.editor-topbar-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--td-text);
  letter-spacing: -0.5px;
}

.editor-topbar-subtitle {
  font-size: 13px;
  color: var(--td-text-2);
  margin-top: 2px;
}

/* ── Section headers ─────────────────────────────────────────────────────── */

.editor-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--td-text);
}

.editor-section-header .icon {
  font-size: 18px;
}

.editor-section-header--mt {
  margin-top: 8px;
}

/* ── Post grid ───────────────────────────────────────────────────────────── */

.editor-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--td-gap);
  margin-bottom: 32px;
}

.editor-post-card {
  background: var(--td-surface);
  border: 2px solid var(--td-border);
  border-radius: var(--td-radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.editor-post-card:hover {
  border-color: var(--td-border-hover);
  transform: translateY(-2px);
}

.editor-post-card.selected {
  border-color: var(--td-cyan);
}

.editor-post-card .thumb {
  width: 100%;
  aspect-ratio: 9/16;
  background: var(--td-surface-2);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--td-text-3);
  font-size: 28px;
}

.editor-post-card .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.editor-post-card .caption {
  font-size: 12px;
  color: var(--td-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-post-card .thumb {
  position: relative;
}

.editor-post-card:hover .thumb::after {
  content: '▶';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 24px;
  border-radius: 8px;
  pointer-events: none;
}

.editor-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--td-text-3);
  font-size: 14px;
}

/* ── Render controls ─────────────────────────────────────────────────────── */

.editor-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.editor-preset-selector {
  display: flex;
  gap: 0;
  background: var(--td-surface);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--td-border);
}

.editor-preset-selector label {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--td-text-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  border-right: 1px solid var(--td-border);
  user-select: none;
}

.editor-preset-selector label:last-child {
  border-right: none;
}

.editor-preset-selector input[type="radio"] {
  display: none;
}

.editor-preset-selector input[type="radio"]:checked + span {
  color: var(--td-cyan);
  background: rgba(0, 242, 234, 0.1);
}

.editor-preset-selector label:has(input:checked) {
  color: var(--td-cyan);
  background: rgba(0, 242, 234, 0.1);
}

.editor-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
}

.editor-btn:active {
  transform: scale(0.97);
}

.editor-btn-primary {
  background: var(--td-cyan);
  color: #000;
}

.editor-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.editor-btn-danger {
  background: var(--td-red);
  color: #fff;
}

.editor-btn-secondary {
  background: var(--td-surface);
  color: var(--td-text-2);
  border: 1px solid var(--td-border);
}

/* ── Active render panel ─────────────────────────────────────────────────── */

.editor-render-panel {
  background: var(--td-surface);
  border: 1px solid var(--td-border);
  border-radius: var(--td-radius);
  padding: 20px;
  margin-bottom: 28px;
}

.editor-render-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.editor-render-panel .panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--td-text);
}

.editor-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--td-surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.editor-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  background: var(--td-cyan);
}

.editor-progress-fill.amber {
  background: var(--td-amber);
}

.editor-progress-fill.green {
  background: var(--td-green);
}

.editor-progress-fill.red {
  background: var(--td-red);
}

.editor-progress-label {
  font-size: 12px;
  color: var(--td-text-2);
  display: flex;
  justify-content: space-between;
}

/* ── Status pills ────────────────────────────────────────────────────────── */

.editor-status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.editor-status-pill.queued {
  background: rgba(255, 255, 255, 0.08);
  color: var(--td-text-2);
}

.editor-status-pill.processing,
.editor-status-pill.rendering,
.editor-status-pill.uploading {
  background: rgba(255, 184, 0, 0.15);
  color: var(--td-amber);
  animation: pill-pulse 2s ease-in-out infinite;
}

.editor-status-pill.completed {
  background: rgba(0, 200, 83, 0.15);
  color: var(--td-green);
}

.editor-status-pill.failed,
.editor-status-pill.timed_out {
  background: rgba(255, 61, 61, 0.15);
  color: var(--td-red);
}

.editor-status-pill.cancelled {
  background: rgba(255, 255, 255, 0.06);
  color: var(--td-text-3);
}

@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── History table ───────────────────────────────────────────────────────── */

.editor-history-table {
  width: 100%;
  border-collapse: collapse;
}

.editor-history-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--td-text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--td-border);
}

.editor-history-table td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--td-text-2);
  border-bottom: 1px solid var(--td-border);
  vertical-align: middle;
}

.editor-history-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.editor-history-table .actions {
  display: flex;
  gap: 8px;
}

.editor-history-table .action-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--td-border);
  background: transparent;
  color: var(--td-text-2);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}

.editor-history-table .action-btn:hover {
  border-color: var(--td-text-3);
  color: var(--td-text);
}

.editor-history-table .action-btn.retry {
  border-color: var(--td-amber);
  color: var(--td-amber);
}

.editor-history-table .action-btn.delete {
  border-color: var(--td-red);
  color: var(--td-red);
}

.editor-history-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.editor-toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: var(--td-surface);
  color: var(--td-text);
  border: 1px solid var(--td-border);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
}

.editor-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.editor-toast.editor-toast-success {
  border-color: var(--td-green);
  color: var(--td-green);
}

.editor-toast.editor-toast-error {
  border-color: var(--td-red);
  color: var(--td-red);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .editor-container { padding: 16px; }
  .editor-post-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .editor-controls { flex-direction: column; align-items: stretch; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AI EDITOR WORKSPACE
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Workspace container ─────────────────────────────────────────────────── */

.editor-workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 32px;
  border: 1px solid var(--td-border);
  border-radius: var(--td-radius);
  overflow: hidden;
}

.editor-ws-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #161823;
  border-bottom: 1px solid var(--td-border);
}

.editor-back-btn {
  background: transparent;
  border: 1px solid var(--td-border);
  color: var(--td-coral, #FF4D6D);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.editor-back-btn:hover {
  background: rgba(255, 77, 109, 0.1);
}

.editor-ws-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--td-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Three-column layout ─────────────────────────────────────────────────── */

.editor-layout {
  display: grid;
  grid-template-columns: 72px 1fr 280px;
  gap: 0;
  height: calc(100vh - 260px);
  min-height: 500px;
}

/* ── Left toolbar ────────────────────────────────────────────────────────── */

.editor-toolbar {
  display: flex;
  flex-direction: column;
  background: #161823;
  border-right: 1px solid var(--td-border);
  padding: 8px 0;
  overflow-y: auto;
}

.editor-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 72px;
  padding: 10px 4px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, background 0.2s;
  text-align: center;
  line-height: 1.2;
}

.editor-tool-btn:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
}

.editor-tool-btn.active {
  color: var(--td-coral, #FF4D6D);
  background: rgba(255, 77, 109, 0.1);
}

/* ── Center: preview + timeline ─────────────────────────────────────────── */

.editor-center {
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}

.editor-preview-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.editor-preview {
  position: relative;
  background: #000;
  max-width: 100%;
  max-height: 100%;
}

#preview-video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.editor-caption-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.editor-reframe-overlay {
  position: absolute;
  inset: 0;
}

.editor-crop-window {
  position: absolute;
  border: 2px solid var(--td-coral, #FF4D6D);
  cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}

/* ── Timeline ────────────────────────────────────────────────────────────── */

.editor-timeline {
  height: 88px;
  border-top: 1px solid var(--td-border);
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.timeline-track {
  flex: 1;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.timeline-waveform {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.6;
}

.timeline-cut-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-cut-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--td-coral, #FF4D6D);
  cursor: pointer;
  pointer-events: all;
  transition: background 0.15s;
}

.timeline-cut-marker:hover {
  background: #fff;
}

.timeline-playhead {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #fff;
  pointer-events: none;
  z-index: 5;
}

.timeline-trim-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  background: var(--td-amber, #FFB800);
  cursor: ew-resize;
  z-index: 10;
  opacity: 0.85;
}

.trim-start { left: 0; border-radius: 2px 0 0 2px; }
.trim-end   { right: 0; border-radius: 0 2px 2px 0; }

.timeline-controls {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--td-text-2);
  flex-shrink: 0;
}

.tl-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--td-text-2);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}

.tl-ctrl-btn:hover {
  color: var(--td-text);
  background: rgba(255, 255, 255, 0.06);
}

.tl-time {
  font-variant-numeric: tabular-nums;
}

/* ── Right panel area ────────────────────────────────────────────────────── */

.editor-panel-area {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--td-border);
  background: #0d0d0d;
  overflow-y: auto;
}

.editor-tool-panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--td-border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--td-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.panel-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--td-text-2);
  margin-bottom: 10px;
}

.panel-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.panel-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.panel-hint {
  font-size: 11px;
  color: var(--td-text-3);
  margin-top: 8px;
  margin-bottom: 0;
}

.editor-tool-panel select,
.editor-tool-panel input[type="range"] {
  background: var(--td-surface);
  border: 1px solid var(--td-border);
  color: var(--td-text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
}

.editor-tool-panel input[type="range"] {
  padding: 0;
  cursor: pointer;
  accent-color: var(--td-coral, #FF4D6D);
}

.editor-tool-panel input[type="color"] {
  border: 1px solid var(--td-border);
  border-radius: 4px;
  background: var(--td-surface);
  cursor: pointer;
  width: 40px;
  height: 28px;
  padding: 2px;
}

.editor-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.editor-btn:active { transform: scale(0.97); }
.editor-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.editor-btn-primary {
  background: var(--td-cyan, #00F2EA);
  color: #000;
}

.editor-btn-secondary {
  background: var(--td-surface);
  color: var(--td-text-2);
  border: 1px solid var(--td-border);
}

.editor-btn-danger {
  background: var(--td-red, #FF3D3D);
  color: #fff;
}

.editor-btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  margin-bottom: 0;
}

/* ── Silence list ────────────────────────────────────────────────────────── */

.silence-list {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 8px;
}

.silence-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--td-border);
  font-size: 11px;
  color: var(--td-text-2);
}

.silence-item .remove-btn {
  font-size: 10px;
  color: var(--td-red, #FF3D3D);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0 4px;
}

.silence-item.removed {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ── Captions cue list ───────────────────────────────────────────────────── */

.captions-cue-list {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 8px;
}

.caption-cue {
  padding: 6px 0;
  border-bottom: 1px solid var(--td-border);
  font-size: 11px;
}

.cue-time {
  color: var(--td-cyan, #00F2EA);
  font-size: 10px;
  margin-bottom: 2px;
}

.cue-text {
  color: var(--td-text-2);
  outline: none;
  display: block;
  width: 100%;
  cursor: text;
}

.cue-text:focus {
  color: var(--td-text);
}

/* ── Aspect ratio buttons ────────────────────────────────────────────────── */

.editor-aspect-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.aspect-btn {
  flex: 1;
  min-width: 48px;
  padding: 7px 4px;
  border-radius: 8px;
  border: 1px solid var(--td-border);
  background: transparent;
  color: var(--td-text-2);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.aspect-btn:hover {
  border-color: var(--td-text-3);
  color: var(--td-text);
}

.aspect-btn.active {
  border-color: var(--td-coral, #FF4D6D);
  color: var(--td-coral, #FF4D6D);
  background: rgba(255, 77, 109, 0.1);
}

/* ── Audio waveform viz ──────────────────────────────────────────────────── */

.audio-waveform-viz {
  margin-top: 12px;
}

.audio-strip-canvas {
  width: 100%;
  height: 32px;
  display: block;
  background: var(--td-surface);
  border-radius: 4px;
}

.waveform-strip-label {
  font-size: 10px;
  color: var(--td-text-3);
  margin-top: 6px;
  margin-bottom: 3px;
}

.waveform-strip-label.after-label {
  color: var(--td-green, #00C853);
}

/* ── Template list ───────────────────────────────────────────────────────── */

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-skeleton {
  font-size: 12px;
  color: var(--td-text-3);
  padding: 8px 0;
}

.template-card {
  background: var(--td-surface);
  border: 1px solid var(--td-border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.template-card:hover {
  border-color: rgba(255, 77, 109, 0.5);
}

.template-card.applied {
  border-color: var(--td-coral, #FF4D6D);
}

.template-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--td-text);
}

.template-card-desc {
  font-size: 11px;
  color: var(--td-text-2);
  margin-top: 3px;
}

/* ── Export panel ────────────────────────────────────────────────────────── */

.editor-export-panel {
  padding: 14px 16px;
  margin-top: auto;
  border-top: 1px solid var(--td-border);
  flex-shrink: 0;
}

.editor-export-panel select {
  background: var(--td-surface);
  border: 1px solid var(--td-border);
  color: var(--td-text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
  margin-top: 2px;
}

.editor-export-panel .panel-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--td-text-2);
  margin-bottom: 10px;
}

.editor-export-progress {
  margin-top: 12px;
}

/* ── Workspace responsive ────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }

  .editor-toolbar {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--td-border);
    overflow-x: auto;
    padding: 0;
  }

  .editor-tool-btn {
    width: auto;
    padding: 8px 14px;
    flex-direction: row;
    gap: 6px;
    font-size: 11px;
    white-space: nowrap;
  }

  .editor-center {
    height: 420px;
  }

  .editor-panel-area {
    border-left: none;
    border-top: 1px solid var(--td-border);
    max-height: 360px;
  }
}

@media (max-width: 600px) {
  .editor-tool-btn span {
    display: none;
  }

  .editor-tool-btn {
    padding: 8px 12px;
  }
}
