/* =================================================================
   Studio Pro — professional video editor UI
   ================================================================= */

#studio.pro {
  display: none;
  flex-direction: column;
  height: 100%;
  background: #0a0e10;
  color: var(--text, #e8eaee);
  font-family: Heebo, "Segoe UI", sans-serif;
  user-select: none;
}
#studio.pro.active { display: flex; }

/* ---- Top bar ---- */
.sp-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #131820;
  border-bottom: 1px solid #1f2632;
}
.sp-topbar .sp-brand {
  font-weight: 700; color: var(--gold, #d4af37); font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
.sp-topbar select, .sp-topbar input {
  background: #1f232c; color: var(--text); border: 1px solid #2a2f3a;
  border-radius: 6px; padding: 6px 8px; font-size: 12px;
}
.sp-btn {
  background: #1f232c; color: var(--text); border: 1px solid #2a2f3a;
  border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer;
  transition: all 0.12s;
}
.sp-btn:hover { background: #2a3340; border-color: #3a4555; }
.sp-btn.primary {
  background: var(--gold, #d4af37); color: #1a1a1a; font-weight: 600; border-color: var(--gold);
}
.sp-btn.primary:hover { filter: brightness(1.1); }
.sp-btn.danger { color: #ef4444; }
.sp-btn.icon { padding: 6px 8px; font-size: 14px; }
.sp-spacer { flex: 1; }
.sp-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #1f232c; border-radius: 12px; padding: 4px 10px;
  font-size: 11px; color: var(--muted, #8a99ad);
}
.sp-chip.live { background: rgba(212,175,55,0.15); color: var(--gold); }

/* ---- Main layout (3 columns + timeline) ---- */
.sp-main {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  flex: 1; min-height: 0;
  border-bottom: 1px solid #1f2632;
}
.sp-col { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sp-col + .sp-col { border-left: 1px solid #1f2632; }
.sp-col-head {
  padding: 8px 12px; font-size: 11px; color: var(--muted);
  background: #0d1218; border-bottom: 1px solid #1f2632; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.sp-col-body { flex: 1; overflow-y: auto; padding: 8px; }

/* ---- Media Bin ---- */
.sp-bin-search {
  margin: 0 8px 8px; padding: 6px 10px;
  background: #1f232c; border: 1px solid #2a2f3a; border-radius: 6px;
  color: var(--text); font-size: 12px;
}
.sp-bin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 8px 8px; }
.sp-bin-card {
  background: #1a1f27; border: 1px solid #2a2f3a; border-radius: 6px;
  overflow: hidden; cursor: grab; transition: all 0.12s;
}
.sp-bin-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.sp-bin-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(212,175,55,0.3); }
.sp-bin-card:active { cursor: grabbing; }
.sp-bin-card .thumb {
  aspect-ratio: 16 / 9; background: #000; display: flex;
  align-items: center; justify-content: center; position: relative;
}
.sp-bin-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.sp-bin-card .thumb .icon { font-size: 24px; }
.sp-bin-card .thumb .dur {
  position: absolute; bottom: 2px; right: 4px;
  background: rgba(0,0,0,0.7); color: #fff; font-size: 9px;
  padding: 1px 4px; border-radius: 3px;
}
.sp-bin-card .meta {
  padding: 4px 6px; font-size: 10px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-bin-empty {
  grid-column: span 2; text-align: center; padding: 32px 12px;
  color: var(--muted); font-size: 12px; line-height: 1.6;
}
.sp-bin-empty button { margin-top: 12px; }

.sp-bin-add {
  margin: 0 8px 8px; padding: 12px;
  border: 2px dashed #2a3340; border-radius: 8px;
  text-align: center; color: var(--muted); font-size: 11px; cursor: pointer;
  transition: all 0.12s;
}
.sp-bin-add:hover { border-color: var(--gold); color: var(--gold); }
.sp-bin-add.drag-over { border-color: var(--gold); background: rgba(212,175,55,0.05); }

/* ---- Preview ---- */
.sp-preview-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #000; min-height: 0; position: relative;
}
.sp-preview-wrap video {
  max-width: 100%; max-height: 100%; background: #000;
}
.sp-preview-overlay {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 3px 8px; border-radius: 12px; font-size: 11px;
  font-family: ui-monospace, monospace;
}
.sp-transport {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #0d1218; border-top: 1px solid #1f2632;
}
.sp-transport .sp-time {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--gold); margin-inline-start: auto;
}

/* ---- Properties / Effects ---- */
.sp-tabs {
  display: flex; gap: 0; padding: 0 8px; background: #0d1218;
  border-bottom: 1px solid #1f2632;
}
.sp-tabs button {
  flex: 1; background: none; color: var(--muted); border: none;
  padding: 8px 4px; cursor: pointer; font-size: 11px;
  border-bottom: 2px solid transparent; transition: all 0.12s;
}
.sp-tabs button:hover { color: var(--text); }
.sp-tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

.sp-field { margin-bottom: 12px; }
.sp-field label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px;
}
.sp-field input[type="number"],
.sp-field input[type="text"],
.sp-field select {
  width: 100%; background: #1f232c; color: var(--text);
  border: 1px solid #2a2f3a; border-radius: 6px; padding: 6px 8px;
  font-size: 12px; box-sizing: border-box;
}
.sp-field input[type="range"] { width: 100%; }
.sp-row { display: flex; gap: 6px; }
.sp-row > * { flex: 1; }
.sp-empty-props {
  padding: 24px 12px; text-align: center; color: var(--muted); font-size: 12px;
}

/* AI buttons grid */
.sp-ai-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.sp-ai-grid button {
  background: #1a1f27; border: 1px solid #2a2f3a; color: var(--text);
  padding: 10px 6px; border-radius: 6px; cursor: pointer; font-size: 11px;
  transition: all 0.12s; text-align: center; line-height: 1.4;
}
.sp-ai-grid button:hover { border-color: var(--gold); background: #232a35; }
.sp-ai-grid button .icon { display: block; font-size: 16px; margin-bottom: 2px; }

/* ---- Timeline ---- */
.sp-timeline-wrap {
  display: flex; flex-direction: column;
  background: #0d1218; height: 280px; flex-shrink: 0;
}
.sp-timeline-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid #1f2632; background: #131820;
  flex-wrap: wrap;
}
.sp-timeline-toolbar .sp-zoom {
  display: flex; align-items: center; gap: 4px;
  margin-inline-start: auto; font-size: 11px; color: var(--muted);
}
.sp-timeline-toolbar input[type="range"] { width: 100px; }

.sp-timeline-body {
  flex: 1; display: grid;
  grid-template-columns: 64px 1fr;
  overflow: hidden; min-height: 0;
}
.sp-track-labels {
  background: #131820; border-right: 1px solid #1f2632;
  display: flex; flex-direction: column;
}
.sp-track-label {
  font-size: 10px; color: var(--muted); padding: 0 8px;
  display: flex; align-items: center; gap: 4px;
  border-bottom: 1px solid #1f2632;
}
.sp-track-label.ruler { height: 24px; background: #0d1218; }
.sp-track-label.V2 { height: 40px; }
.sp-track-label.V1 { height: 56px; }
.sp-track-label.A1 { height: 56px; }
.sp-track-label.A2 { height: 56px; }
.sp-track-label .mute { cursor: pointer; opacity: 0.6; }
.sp-track-label .mute.on { opacity: 1; color: #ef4444; }

.sp-canvas-scroll {
  overflow-x: auto; overflow-y: hidden;
  position: relative; cursor: default;
}
.sp-canvas-scroll.dragging { cursor: grabbing; }
.sp-canvas-scroll canvas {
  display: block; image-rendering: crisp-edges;
}
#spCanvasContainer {
  position: relative; height: 232px;
}
#spPlayhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #ef4444; pointer-events: none; z-index: 5;
}
#spPlayhead::before {
  content: ""; position: absolute; top: 0; left: -6px;
  border: 7px solid transparent; border-top-color: #ef4444;
}

/* Context menu */
.sp-ctxmenu {
  position: fixed; background: #1a1f27; border: 1px solid #2a2f3a;
  border-radius: 6px; padding: 4px 0; min-width: 160px; z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.sp-ctxmenu button {
  display: block; width: 100%; text-align: start;
  background: none; border: none; color: var(--text);
  padding: 6px 12px; cursor: pointer; font-size: 12px;
}
.sp-ctxmenu button:hover { background: #2a3340; }
.sp-ctxmenu hr { border: none; border-top: 1px solid #2a2f3a; margin: 4px 0; }

/* Toast */
.sp-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1a1f27; border: 1px solid #2a2f3a; color: var(--text);
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 2000;
  animation: spToastIn 0.18s ease-out;
}
.sp-toast.ok { border-color: rgba(16,185,129,0.5); }
.sp-toast.err { border-color: rgba(239,68,68,0.5); }
@keyframes spToastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Export modal */
.sp-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 1500;
}
.sp-modal-overlay.show { display: flex; }
.sp-modal {
  background: #131820; border: 1px solid #2a2f3a; border-radius: 12px;
  padding: 24px; width: 480px; max-width: 90vw;
}
.sp-modal h3 { margin: 0 0 16px; color: var(--gold); }
.sp-modal .sp-presets {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0;
}
.sp-modal .sp-presets button {
  background: #1a1f27; border: 2px solid #2a2f3a; color: var(--text);
  padding: 12px; border-radius: 8px; cursor: pointer; font-size: 12px;
  text-align: start; transition: all 0.12s;
}
.sp-modal .sp-presets button.sel { border-color: var(--gold); }
.sp-modal .sp-presets button .name { font-weight: 600; display: block; margin-bottom: 4px; }
.sp-modal .sp-presets button .meta { color: var(--muted); font-size: 10px; }
.sp-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Mobile */
@media (max-width: 768px) {
  .sp-main { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .sp-col + .sp-col { border-left: none; border-top: 1px solid #1f2632; }
  .sp-col.bin { max-height: 200px; }
  .sp-col.props { max-height: 240px; }
  .sp-timeline-wrap { height: 240px; }
  .sp-bin-grid { grid-template-columns: 1fr 1fr 1fr; }
  .sp-topbar { flex-wrap: wrap; }
}
