/* === ReelsForge — Clean, Professional Video Editor === */

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface2: #f0efe9;
  --border: #e2e0d8;
  --text: #1a1a1a;
  --text2: #6b6b6b;
  --accent: #e85d3a;
  --accent-hover: #d04e2d;
  --success: #2d9c6f;
  --danger: #d94452;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
}

/* === Script Result === */

.script-result {
  margin-top: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.script-result.hidden { display: none; }

.script-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.script-header h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.script-desc {
  font-size: 12px;
  color: var(--text2);
  margin: 4px 0 10px;
}

.script-scenes {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.script-scene {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-left: 3px solid var(--accent);
}

.scene-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.scene-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.scene-duration {
  font-size: 11px;
  color: var(--text2);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.scene-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.scene-meta {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.scene-tag {
  font-size: 10px;
  color: var(--text2);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.scene-keywords {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.clip-trim {
  width: 48px;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.clip-trim:focus {
  border-color: var(--accent);
  outline: none;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.preview-timer {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes flash { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 1; } }

/* === Original styles below === */

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

.workspace-list { flex: 1; overflow-y: auto; }

.workspace-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
  font-size: 13px;
}

.workspace-item:hover { background: var(--surface2); }
.workspace-item.active { background: var(--accent); color: white; }
.workspace-item .ws-name { font-weight: 600; }
.workspace-item .ws-meta { font-size: 11px; opacity: 0.7; margin-top: 2px; }

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--surface2); }

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-small:hover { background: var(--surface2); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text2);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

.hidden { display: none !important; }

/* Editor */
.editor { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.toolbar-left { display: flex; gap: 12px; align-items: center; }
.toolbar-right { display: flex; gap: 8px; }

.project-name {
  font-size: 16px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: 6px;
  width: 200px;
}
.project-name:focus { background: var(--surface2); outline: none; }

select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}

.editor-body { flex: 1; display: flex; overflow: hidden; }

/* Resizer handles */
.resize-handle {
  flex-shrink: 0;
  background: var(--border);
  z-index: 10;
  transition: background 0.15s;
}
.resize-handle:hover, .resize-handle.active { background: var(--accent); }
.resize-handle.vertical {
  width: 5px;
  cursor: col-resize;
}
.resize-handle.horizontal {
  height: 5px;
  cursor: row-resize;
}

/* Search Panel */
.search-panel {
  width: 320px;
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  background: var(--surface);
}

.search-section { margin-bottom: 24px; }
.search-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); margin-bottom: 10px; }

.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
}
.search-row input:focus { outline: none; border-color: var(--accent); }

.keyword-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.chip .remove { font-size: 14px; opacity: 0.6; }
.chip .remove:hover { opacity: 1; }

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.video-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
  aspect-ratio: 9/16;
  background: var(--surface2);
}
.video-card:hover { transform: scale(1.02); border-color: var(--accent); }
.video-card.selected { border-color: var(--accent); }
.video-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-card .duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.video-card .add-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-card:hover .add-btn { opacity: 1; }

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  color: var(--text2);
  font-size: 13px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Preview Panel */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.preview-phone {
  width: 240px;
  height: 426px;
  border-radius: 20px;
  border: 3px solid var(--border);
  overflow: hidden;
  background: #111;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.preview-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.preview-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-viewport img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#preview-text-layers {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.text-layer {
  position: absolute;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  text-align: center;
  width: 80%;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.text-layer:hover { background: rgba(255,255,255,0.15); }
.text-layer.selected { background: rgba(232,93,58,0.4); }

.preview-info {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text2);
  text-align: center;
}

/* Timeline */
.timeline-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  min-height: 140px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.timeline-header h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); }
.total-duration { font-size: 13px; font-weight: 600; color: var(--accent); }

.timeline {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.timeline-clip {
  flex-shrink: 0;
  width: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: grab;
  position: relative;
  transition: border-color 0.15s;
}
.timeline-clip:hover { border-color: var(--accent); }
.timeline-clip.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(232,93,58,0.3); }

.timeline-clip img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  pointer-events: none;
}

.timeline-clip-info {
  padding: 6px 8px;
  background: var(--surface2);
  font-size: 11px;
}
.timeline-clip-info .clip-duration { font-weight: 600; }
.timeline-clip-info .clip-texts { color: var(--text2); margin-top: 2px; }

.timeline-clip-actions {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.timeline-clip .transition-label {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text2);
  background: var(--surface);
  padding: 2px 4px;
  border-radius: 4px;
  z-index: 1;
}

.timeline-clip .remove-clip {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.timeline-clip:hover .remove-clip { opacity: 1; }

.timeline-add {
  flex-shrink: 0;
  width: 80px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
}
.timeline-add:hover { border-color: var(--accent); color: var(--accent); }

/* Text Editor */
.text-editor {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}

.text-editor h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text2); margin-bottom: 12px; }

.text-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.text-editor-grid label {
  font-size: 11px;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.text-editor-grid input,
.text-editor-grid select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}

.text-editor-actions { margin-top: 10px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 60px; padding: 12px 8px; }
  .logo { font-size: 14px; }
  .workspace-item .ws-name { font-size: 11px; }
  .search-panel { width: 240px; }
}
/* === Filters === */
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-grid label { font-size: 11px; color: var(--text2); display: flex; flex-direction: column; gap: 4px; }
.filter-grid select, .filter-grid input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: var(--bg); }
.filter-grid select:focus, .filter-grid input:focus { outline: none; border-color: var(--accent); }

.color-palette { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.color-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
