/* =============================================================================
   VidPipe Studio — Professional Desktop Theme
   ============================================================================= */

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

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

/* --- Light Theme --- */
:root {
  --bg: #f5f5f7;
  --bg-blur: rgba(245,245,247,0.8);
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f0f1f4;
  --surface-hover: #fafbfc;
  --border: rgba(0,0,0,0.06);
  --border-2: rgba(0,0,0,0.10);
  --border-3: rgba(0,0,0,0.15);
  --accent: #10b981;
  --accent-light: #34d399;
  --accent-dark: #059669;
  --accent-bg: rgba(16,185,129,0.08);
  --accent-bg-2: rgba(16,185,129,0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.08);
  --success: #10b981;
  --success-bg: rgba(16,185,129,0.08);
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,0.08);
  --info: #3b82f6;
  --info-bg: rgba(59,130,246,0.08);
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --text-4: #d1d5db;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.10);
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --navbar-h: 56px;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --bg: #09090b;
  --bg-blur: rgba(9,9,11,0.85);
  --surface: #18181b;
  --surface-2: #1e1e23;
  --surface-3: #27272a;
  --surface-hover: #2a2a2e;
  --border: rgba(255,255,255,0.06);
  --border-2: rgba(255,255,255,0.09);
  --border-3: rgba(255,255,255,0.14);
  --accent: #34d399;
  --accent-light: #6ee7b7;
  --accent-dark: #10b981;
  --accent-bg: rgba(52,211,153,0.10);
  --accent-bg-2: rgba(52,211,153,0.18);
  --danger: #f87171;
  --danger-bg: rgba(248,113,113,0.10);
  --success: #34d399;
  --success-bg: rgba(52,211,153,0.10);
  --warn: #fbbf24;
  --warn-bg: rgba(251,191,36,0.10);
  --info: #60a5fa;
  --info-bg: rgba(96,165,250,0.10);
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --text-4: #3f3f46;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.3);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.4);
}

/* --- Base --- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

#root { min-height: 100vh; }
code, pre, .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

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

/* =============================================================================
   LAYOUT
   ============================================================================= */

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.sidebar-item {
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  text-align: left;
}
.sidebar-item:hover { background: var(--surface-3); color: var(--text); }
.sidebar-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar-item i { width: 18px; text-align: center; font-size: 13px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

/* --- TopBar --- */
.topbar {
  position: fixed;
  top: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--topbar-h);
  background: var(--bg-blur);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 90;
  gap: 12px;
}
.topbar.no-sidebar { left: 0; }

/* --- Stage --- */
.stage {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 32px;
  min-height: calc(100vh - var(--topbar-h) - var(--navbar-h));
  padding-bottom: calc(var(--navbar-h) + 20px);
  width: 100%;
  max-width: calc(100vw - var(--sidebar-w));
}
.stage.no-sidebar { margin-left: 0; padding: 28px 40px; max-width: 960px; margin-inline: auto; }
.stage.full-width { max-width: none; }

/* --- Bottom Nav --- */
.nav-bar {
  position: fixed;
  bottom: 0; right: 0;
  left: var(--sidebar-w);
  height: var(--navbar-h);
  background: var(--bg-blur);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 90;
}
.nav-bar.no-sidebar { left: 0; }

/* --- Step dots --- */
.step-dots { display: flex; align-items: center; gap: 4px; }
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: none; cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}
.step-dot.done { background: var(--accent); opacity: 0.5; }
.step-dot.active { background: var(--accent); width: 24px; border-radius: 4px; opacity: 1; }
.step-dot.pending { background: var(--text-4); }

/* =============================================================================
   COMPONENTS
   ============================================================================= */

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { box-shadow: var(--shadow); }
.card-dark {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-interactive { cursor: pointer; }
.card-interactive:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
.card-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16,185,129,0.3);
}
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 4px 14px rgba(16,185,129,0.3); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--border-3); background: var(--surface-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); border: none; box-shadow: none; }
.btn-ghost:hover { color: var(--text); background: var(--surface-3); box-shadow: none; transform: none; }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; gap: 6px; }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-sm); }
.btn-icon.sm { width: 30px; height: 30px; padding: 6px; }

/* --- Inputs --- */
.input, input[type="text"], input[type="url"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.input::placeholder, input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { min-height: 80px; resize: vertical; }
select { cursor: pointer; }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* --- Info Boxes --- */
.info-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  border-left: 3px solid var(--text-4);
  background: var(--surface-2);
  color: var(--text-2);
}
.info-box.success { border-left-color: var(--success); background: var(--success-bg); }
.info-box.error { border-left-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.info-box.warning { border-left-color: var(--warn); background: var(--warn-bg); }

/* --- Prompt/Code Boxes --- */
.prompt-box {
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.prompt-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.prompt-box-body {
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface-2);
  color: var(--text-2);
}

/* --- Scene Card --- */
.scene-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-xs);
}
.scene-card:hover { border-color: var(--border-3); box-shadow: var(--shadow); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.15s ease;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 600px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Stats --- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-card .stat-value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-card .stat-label { font-size: 11px; color: var(--text-3); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* --- Spinner --- */
.spin {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spin-lg { width: 36px; height: 36px; border-width: 3px; }

/* --- Avatar --- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* --- Divider --- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* --- Section header --- */
.section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding: 0 4px;
}

/* =============================================================================
   ANIMATIONS
   ============================================================================= */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse { 50% { opacity: 0.4; } }
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.fade-in { animation: fadeIn 0.2s ease; }
.slide-in { animation: slideInRight 0.25s ease; }
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* =============================================================================
   UTILITIES
   ============================================================================= */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 18px; }
.text-muted { color: var(--text-3); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }

/* --- Loading Screen --- */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 24px;
  background: var(--bg);
}
.loading-screen h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

/* --- Range Slider --- */
input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* --- Checkbox --- */
input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- Table --- */
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:hover td { background: var(--surface-2); }

/* --- Progress Bar --- */
.progress-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- Tooltip --- */
[title] { position: relative; }

/* =============================================================================
   RESPONSIVE GRID — collapses on small screens
   ============================================================================= */
.r-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.r-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.r-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.r-grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

/* =============================================================================
   RESPONSIVE — Full laptop support
   ============================================================================= */

/* Large laptop (1440px) */
@media (max-width: 1440px) {
  .stage { padding: 24px 28px; }
  .stage.no-sidebar { padding: 24px 32px; max-width: 960px; }
  .modal-box { max-width: 580px; }
}

/* Small laptop (1280px) */
@media (max-width: 1280px) {
  :root { --sidebar-w: 220px; }
  .stage { padding: 20px 24px; }
  .stage.no-sidebar { max-width: 860px; }
  .btn-lg { padding: 11px 24px; font-size: 14px; }
  .r-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Laptop (1024px) */
@media (max-width: 1024px) {
  :root { --sidebar-w: 56px; --topbar-h: 50px; --navbar-h: 50px; }
  .sidebar { width: var(--sidebar-w); }
  .sidebar-brand > div > div:last-child { display: none; }
  .sidebar-item span, .sidebar-item:not(i) { font-size: 0; }
  .sidebar-item { justify-content: center; padding: 12px; }
  .sidebar-item i { font-size: 16px; margin: 0; }
  .sidebar-footer { display: none; }
  .sidebar-nav .section-header { display: none; }
  .stage { padding: 18px 20px; }
  .stage.no-sidebar { max-width: 780px; }
  .modal-box { max-width: 520px; width: 94%; padding: 24px; }
  .card { padding: 16px; }
  .card-dark { padding: 16px; }
  .stat-grid, .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .r-grid-2 { grid-template-columns: 1fr; }
  .r-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .r-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .prompt-box-body { max-height: 200px; font-size: 11px; }
}

/* No mobile — laptop only app */
