/* CineFlow AI Studio - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-dark: #090a0f;
  --bg-surface: #11141e;
  --bg-card: #181d2b;
  --bg-card-hover: #212739;
  --bg-glass: rgba(18, 21, 30, 0.75);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(124, 58, 237, 0.4);
  --border-active: #7c3aed;
  
  --accent-primary: #7c3aed;
  --accent-primary-hover: #6d28d9;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #2c3449;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* TOP NAVBAR */
.top-navbar {
  height: 54px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  color: white;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.workspace-switcher {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.4);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #9333ea);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

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

.render-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

/* MAIN LAYOUT */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 54px);
  overflow: hidden;
}

.workspace-view {
  display: none;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.workspace-view.active {
  display: flex;
}

/* 1. CHARACTER VAULT VIEW */
.vault-container {
  display: flex;
  flex: 1;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
  background: radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.05) 0%, transparent 40%);
}

.vault-sidebar {
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vault-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.vault-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.character-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.character-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.character-card.selected {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.char-img-wrap {
  width: 100%;
  height: 280px;
  position: relative;
  overflow: hidden;
  background: #000;
}

.char-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.character-card:hover .char-img-wrap img {
  transform: scale(1.05);
}

.char-tag-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(9, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.char-info {
  padding: 16px;
}

.char-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.char-role {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.char-matrix-preview {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.matrix-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

/* 2. STORYBOARD WORKSPACE */
.storyboard-container {
  display: flex;
  flex: 1;
  padding: 20px;
  gap: 20px;
  height: 100%;
  overflow-y: auto;
}

.storyboard-flow {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.script-parser-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.script-input {
  width: 100%;
  height: 80px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  resize: none;
}

.script-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.shots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.shot-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.shot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shot-number {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-cyan);
}

.shot-preview {
  width: 100%;
  height: 180px;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

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

.shot-character-binding {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-subtle);
}

/* 3. GENERATOR WORKSPACE */
.generator-container {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.generator-controls {
  width: 420px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.generator-preview-panel {
  flex: 1;
  background: #050608;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.video-viewport {
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  border: 1px solid var(--border-subtle);
}

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

.prompt-box-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-textarea {
  width: 100%;
  height: 110px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  resize: none;
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.char-chips-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.char-chip {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s ease;
}

.char-chip:hover {
  background: var(--accent-cyan);
  color: #000;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.preset-btn:hover, .preset-btn.active {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: rgba(124, 58, 237, 0.15);
}

.range-slider {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* 4. PRECISION VIDEO EDITOR & MOTION SUITE (KLING/SEEDANCE STYLE) */
.editor-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.editor-main-area {
  display: flex;
  flex: 1;
  height: calc(100% - 240px);
  overflow: hidden;
}

.editor-tools-sidebar {
  width: 70px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 16px;
}

.tool-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
  position: relative;
}

.tool-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.tool-icon-btn.active {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.editor-viewport-center {
  flex: 1;
  background: #030406;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px;
}

.canvas-viewport-wrapper {
  position: relative;
  max-width: 860px;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
  border: 1px solid var(--border-subtle);
}

.main-video-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.motion-brush-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 10;
}

.motion-brush-toolbar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 21, 30, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glow);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}

.editor-inspector-sidebar {
  width: 300px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* TIMELINE BOTTOM PANEL */
.editor-timeline-panel {
  height: 240px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  user-select: none;
}

.timeline-controls-bar {
  height: 40px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.2);
}

.playhead-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
}

.timeline-tracks-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  background: var(--bg-dark);
}

.timeline-ruler {
  height: 24px;
  background: #0d1017;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.timeline-track {
  height: 46px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  position: relative;
}

.track-header {
  width: 140px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  gap: 6px;
  z-index: 5;
  position: sticky;
  left: 0;
}

.track-content {
  flex: 1;
  height: 100%;
  position: relative;
}

.clip-block {
  position: absolute;
  top: 4px;
  height: 38px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.6), rgba(147, 51, 234, 0.8));
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: grab;
}

.clip-block.character-track-clip {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.6), rgba(14, 165, 233, 0.8));
  border-color: var(--accent-cyan);
}

.clip-block.audio-track-clip {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.6), rgba(5, 150, 105, 0.8));
  border-color: var(--accent-emerald);
}

.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-pink);
  z-index: 30;
  pointer-events: none;
}

.timeline-playhead-head {
  position: absolute;
  top: 0;
  left: -5px;
  width: 12px;
  height: 12px;
  background: var(--accent-pink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* MODAL & DIALOGS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  width: 540px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
