/* clips.css — Clip builder modal + clip card styles */

/* ── MODAL OVERLAY ───────────────────────────────────────────────────────── */
#clip-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 4000;
  align-items: center;
  justify-content: center;
}
#clip-modal-inner {
  width: 92%;
  max-width: 1100px;
  height: 88%;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── MODAL HEADER ────────────────────────────────────────────────────────── */
#clip-modal-header {
  height: 48px;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
  flex-shrink: 0;
}
#clip-modal-scene-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.clip-modal-title-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4aafc5;
  background: rgba(74,175,197,0.1);
  border: 0.5px solid rgba(74,175,197,0.25);
  border-radius: 4px;
  padding: 3px 9px;
}
.clip-modal-close-btn {
  width: 28px;
  height: 28px;
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
}
.clip-modal-close-btn:hover { color: var(--text); border-color: var(--text3); }
.clip-save-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  background: none;
  border: 0.5px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.clip-save-btn:hover { color: var(--text); border-color: var(--text3); }
.clip-save-btn:disabled { opacity: 0.5; cursor: default; }

/* ── MODAL BODY (2 columns) ──────────────────────────────────────────────── */
#clip-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── LEFT COLUMN — config ────────────────────────────────────────────────── */
#clip-config {
  width: 360px;
  flex-shrink: 0;
  border-right: 0.5px solid var(--border-strong);
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.clip-field-group { display: flex; flex-direction: column; gap: 6px; }
.clip-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}
.clip-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 0.5px solid var(--border-strong);
  border-radius: 7px;
  padding: 8px 10px;
  width: 100%;
  cursor: pointer;
}
.clip-select:focus { outline: none; border-color: #4aafc5; }

.clip-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── REF STRIP ───────────────────────────────────────────────────────────── */
#clip-refs-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 80px;
  align-items: flex-start;
}
.clip-ref-slot {
  width: 72px;
  height: 72px;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  border: 0.5px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  transition: border-color 0.12s;
}
.clip-ref-slot.empty { border-style: dashed; opacity: 0.6; }
.clip-ref-slot.empty:hover { opacity: 1; border-color: #4aafc5; }
.clip-ref-slot.filled { border-style: solid; }
.clip-ref-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-ref-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(0,0,0,0.6);
  text-align: center;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip-ref-add-icon { font-size: 22px; color: var(--text3); line-height: 1; }
.clip-ref-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s;
  line-height: 1;
  padding: 0;
}
.clip-ref-slot.filled:hover .clip-ref-remove { opacity: 1; }

/* ── ELEMENTS (named @ElementN references) ───────────────────────────────── */
.clip-element-block {
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface2);
}
.clip-element-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.clip-element-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  color: #4aafc5; white-space: nowrap;
}
.clip-el-name {
  flex: 1; font-family: 'DM Sans', sans-serif; font-size: 12px;
  padding: 5px 8px; border: 0.5px solid var(--border-strong);
  border-radius: 5px; background: var(--surface); color: var(--text);
}
.clip-element-remove {
  background: none; border: none; color: var(--text3); font-size: 18px;
  cursor: pointer; line-height: 1; padding: 0 2px;
}
.clip-element-remove:hover { color: var(--error); }
.clip-element-imgs { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.clip-el-frontal, .clip-el-ref {
  width: 56px; height: 56px; border-radius: 6px; overflow: hidden;
  position: relative; flex-shrink: 0; cursor: pointer;
  border: 0.5px solid var(--border-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); transition: border-color 0.12s;
}
.clip-el-frontal.empty, .clip-el-ref.empty { border-style: dashed; opacity: 0.6; }
.clip-el-frontal.empty:hover, .clip-el-ref.empty:hover { opacity: 1; border-color: #4aafc5; }
.clip-el-frontal img, .clip-el-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-el-frontal.filled:hover .clip-ref-remove, .clip-el-ref.filled:hover .clip-ref-remove { opacity: 1; }
.clip-add-element-btn {
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
  color: #4aafc5; background: rgba(74,175,197,0.10);
  border: 0.5px dashed rgba(74,175,197,0.5); border-radius: 7px;
  padding: 7px 14px; cursor: pointer; transition: background 0.12s;
}
.clip-add-element-btn:hover { background: rgba(74,175,197,0.18); }

/* ── TEXTAREA FIELDS ─────────────────────────────────────────────────────── */
.clip-textarea {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--text);
  background: var(--surface2);
  border: 0.5px solid var(--border-strong);
  border-radius: 7px;
  padding: 10px 12px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  line-height: 1.5;
}
.clip-textarea:focus { outline: none; border-color: #4aafc5; }
#clip-motion-notes { min-height: 72px; }
#clip-prompt { min-height: 100px; }
@keyframes clip-prompt-pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 0.8; } }
#clip-prompt.loading { animation: clip-prompt-pulse 1.2s ease-in-out infinite; pointer-events: none; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.clip-gen-prompt-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #4aafc5;
  background: rgba(74,175,197,0.08);
  border: 0.5px solid rgba(74,175,197,0.35);
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  width: 100%;
  justify-content: center;
}
.clip-gen-prompt-btn:hover { background: rgba(74,175,197,0.15); border-color: #4aafc5; }
.clip-gen-prompt-btn:disabled { opacity: 0.5; cursor: default; }

.clip-generate-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #15161a;
  background: #4aafc5;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.12s;
}
.clip-generate-btn:hover { background: #5dc0d6; }
.clip-generate-btn:disabled { opacity: 0.5; cursor: default; }

#clip-status-msg {
  font-size: 11px;
  color: var(--text3);
  min-height: 16px;
}

/* ── CLIP NAME INPUT ─────────────────────────────────────────────────────── */
.clip-text-input {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--border-strong);
  border-radius: 0;
  padding: 6px 2px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}
.clip-text-input::placeholder { color: var(--text3); font-weight: 400; }
.clip-text-input:focus { border-bottom-color: #4aafc5; }

/* ── AUDIO TOGGLE ────────────────────────────────────────────────────────── */
.clip-toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}
.clip-toggle-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #4aafc5;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── AUDIO ON/OFF SWITCH ─────────────────────────────────────────────────── */
.clip-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
}
.clip-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.clip-switch-track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--text3);
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.clip-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.clip-switch input:checked + .clip-switch-track { background: #4aafc5; }
.clip-switch input:checked + .clip-switch-track .clip-switch-thumb { transform: translateX(14px); }
.clip-switch input:focus-visible + .clip-switch-track { box-shadow: 0 0 0 2px rgba(74,175,197,0.4); }

/* ── COST ESTIMATE ───────────────────────────────────────────────────────── */
.clip-cost-estimate {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 8px;
  min-height: 14px;
}
.clip-cost-estimate:empty { margin-bottom: 0; }

/* ── GENERATING PREVIEW STATE ────────────────────────────────────────────── */
.clip-preview-generating {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 14px;
  padding: 20px;
  box-sizing: border-box;
}
.clip-preview-generating-pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,175,197,0.5) 0%, rgba(74,175,197,0.05) 70%);
  animation: clip-gen-pulse 1.8s ease-in-out infinite;
}
@keyframes clip-gen-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
}
.clip-preview-generating-label {
  font-size: 11px;
  font-weight: 600;
  color: #4aafc5;
  text-align: center;
  letter-spacing: 0.04em;
}
.clip-preview-generating-elapsed {
  font-size: 10px;
  color: var(--text2);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.clip-preview-generating-elapsed span { font-weight: 600; color: var(--text); }
.clip-preview-generating-log {
  font-size: 10px;
  color: var(--text3);
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
  font-style: italic;
}

/* ── RIGHT COLUMN — preview ──────────────────────────────────────────────── */
#clip-preview-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 20px;
  background: var(--bg);
  gap: 14px;
  overflow-y: auto;
}
#clip-preview-area {
  width: 100%;
  aspect-ratio: 16/9;
  background: #0a0c0f;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.clip-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text);
}
#clip-preview-area video { border-radius: 10px; }
#clip-preview-meta { font-size: 11px; color: var(--text3); line-height: 1.6; }

/* ── REF PICKER SUB-MODAL ────────────────────────────────────────────────── */
#clip-picker-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 5000;
  align-items: center;
  justify-content: center;
}
#clip-picker-modal {
  width: 600px;
  max-height: 70vh;
  background: var(--bg);
  border: 0.5px solid var(--border-strong);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.clip-picker-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--border-strong);
  background: var(--surface);
  gap: 10px;
}
.clip-picker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.clip-picker-close {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  font-family: 'DM Sans', sans-serif;
}
.clip-picker-close:hover { color: var(--text); }
.clip-picker-tabs {
  display: flex;
  border-bottom: 0.5px solid var(--border-strong);
  background: var(--surface);
}
.clip-picker-tab {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: color 0.12s;
}
.clip-picker-tab:hover { color: var(--text2); }
.clip-picker-tab.active { color: #4aafc5; border-bottom-color: #4aafc5; }
.clip-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.clip-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.clip-picker-item {
  cursor: pointer;
  border-radius: 7px;
  overflow: hidden;
  border: 0.5px solid var(--border);
  transition: border-color 0.12s;
}
.clip-picker-item:hover { border-color: #4aafc5; }
.clip-picker-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.clip-picker-item-label {
  font-size: 9px;
  color: var(--text3);
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip-picker-empty {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
  padding: 20px;
  text-align: center;
}
.clip-picker-upload-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px;
}
.clip-upload-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  background: rgba(74,175,197,0.1);
  border: 0.5px solid rgba(74,175,197,0.35);
  color: #4aafc5;
  border-radius: 7px;
  padding: 9px 18px;
  cursor: pointer;
}
.clip-upload-btn:hover { background: rgba(74,175,197,0.18); }

/* Completed-clip action row (Save to Scene / Download) — mirrors image gen actions */
.clip-preview-actions { display: flex; gap: 8px; margin-top: 10px; }
.clip-preview-actions .action-btn { transition: color 0.12s, background 0.12s; }

/* Clip Library strip — saved clips for the scene; mirrors the image Scene Library */
.clip-library-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.clip-lib-tile {
  width: 80px; height: 56px; border-radius: 6px; overflow: hidden;
  position: relative; flex-shrink: 0; cursor: pointer;
  border: 0.5px solid var(--border-strong); background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.12s, transform 0.08s;
}
.clip-lib-tile:hover { border-color: #4aafc5; }
.clip-lib-tile.active { border-color: #4aafc5; box-shadow: 0 0 0 1px #4aafc5; }
.clip-lib-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-lib-ph { color: var(--text3); display: flex; align-items: center; justify-content: center; }
.clip-lib-tile.new { border-style: dashed; opacity: 0.7; }
.clip-lib-tile.new:hover { opacity: 1; }
.clip-lib-badge {
  position: absolute; bottom: 3px; right: 3px;
  font-size: 9px; line-height: 1; padding: 2px 4px; border-radius: 4px;
  background: rgba(0,0,0,0.65); color: #fff;
}
.clip-lib-badge.gen  { color: #f0c040; }
.clip-lib-badge.fail { color: var(--error); background: rgba(0,0,0,0.75); }
