/**
 * video-tools.css — "Polish your video" tray (Video Studio, WP2, 2026-07-09).
 * Component: src/public/js/video-tools.js (window.CBVideoTools).
 *
 * Design source of truth: css/outreach-dashboard.css (.mi-card/.mi-action/
 * .range-tabs idioms — Alex 2026-07-09: "that styling is spot on"). The tray
 * is appended to <body> and mounts from pages OUTSIDE the outreach dashboard's
 * `#page-outreach-dashboard` token scope (e.g. Settings → Media, which uses
 * the plain app-shell light theme). Exactly like the rel-editor modal further
 * down outreach-dashboard.css documents for its own overlay, this file uses
 * EXPLICIT colours copied from that same palette rather than `var(--...)`
 * tokens that would resolve to nothing here.
 */

.cbvt-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(13, 8, 25, 0.5);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.cbvt-modal {
  background: #ffffff; color: #15172b;
  width: 100%; max-width: 620px; max-height: calc(100vh - 40px);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(13, 8, 25, 0.35);
  font-family: inherit;
  display: flex; flex-direction: column;
}
.cbvt-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 12px; flex: none;
}
.cbvt-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: #15172b; }
.cbvt-close {
  flex: none; border: none; background: transparent; font-size: 22px; line-height: 1;
  color: #9ca3af; cursor: pointer; padding: 0 2px; min-width: 32px; min-height: 32px;
}
.cbvt-close:hover { color: #374151; }

.cbvt-body {
  display: flex; gap: 20px; padding: 6px 20px 20px;
  overflow-y: auto;
}

/* Left — the effective-thumbnail preview: what recipients actually see. */
.cbvt-preview {
  flex: 0 0 200px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cbvt-preview-frame {
  position: relative;
  width: 100%; aspect-ratio: 16 / 9;
  background: #15172b;
  border-radius: 12px;
  overflow: hidden;
}
.cbvt-preview-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cbvt-preview-empty {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #4b4e63;
}
.cbvt-play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; pointer-events: none;
}
.cbvt-preview-label {
  font-size: 11.5px; color: #6b7280; text-align: center;
}

/* Right — tool chips + the active tool's panel. */
.cbvt-tools { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.cbvt-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  background: #f6f4ee; border-radius: 10px; padding: 4px;
}
.cbvt-chip {
  border: none; background: transparent;
  font-size: 12.5px; font-weight: 600; color: #6b7280;
  padding: 7px 12px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  cursor: default;
}
.cbvt-chip:not(.soon) { cursor: pointer; }
.cbvt-chip:not(.soon):hover { color: #15172b; }
.cbvt-chip.active { background: #ffffff; color: #15172b; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.cbvt-chip.soon { color: #9ca3af; cursor: not-allowed; }
.cbvt-chip-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: #ece9f7; color: #6a4cf1; padding: 2px 6px; border-radius: 999px;
}

.cbvt-panel { display: flex; flex-direction: column; gap: 12px; }

/* Thumbnail action cards — the outreach dashboard's .mi-action idiom, sized
   up into full clickable cards (min-height 48px for touch). */
.cbvt-actions { display: flex; flex-direction: column; gap: 10px; }
.cbvt-action-card {
  display: flex; align-items: center; gap: 12px;
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 12px 14px; min-height: 48px;
  text-align: left; cursor: pointer;
  font-family: inherit;
  transition: border-color .12s, background .12s;
}
.cbvt-action-card:hover { border-color: #6a4cf1; background: #faf9ff; }
.cbvt-action-card:disabled { opacity: 0.55; cursor: not-allowed; }
.cbvt-action-ico { font-size: 20px; flex: none; }
.cbvt-action-text { display: flex; flex-direction: column; gap: 2px; }
.cbvt-action-text b { font-size: 13.5px; color: #15172b; font-weight: 600; }
.cbvt-action-text small { font-size: 11.5px; color: #6b7280; }

.cbvt-reset-row { display: flex; }
.cbvt-ghost-btn {
  border-radius: 9px; font-size: 13px; font-weight: 600; padding: 9px 14px;
  cursor: pointer; border: 1px solid #e5e7eb; min-height: 40px;
  background: #fff; color: #374151; font-family: inherit;
}
.cbvt-ghost-btn:hover { border-color: #c9ccd3; }
.cbvt-ghost-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.cbvt-primary-btn {
  border-radius: 9px; font-size: 13.5px; font-weight: 600; padding: 9px 16px;
  cursor: pointer; border: 1px solid transparent; min-height: 44px;
  background: #6a4cf1; color: #fff; font-family: inherit;
}
.cbvt-primary-btn:hover { background: #5a3fd8; }
.cbvt-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cbvt-status { font-size: 12px; color: #6b7280; min-height: 16px; }
.cbvt-status.error { color: #c0423a; }

/* Pick-a-frame scrubber */
.cbvt-scrub { display: flex; flex-direction: column; gap: 10px; }
.cbvt-back-btn {
  align-self: flex-start; border: none; background: transparent; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: #6a4cf1; padding: 4px 2px;
  min-height: 32px;
}
.cbvt-back-btn:hover { color: #5a3fd8; }
.cbvt-scrub-stage {
  width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: 10px; overflow: hidden;
}
.cbvt-scrub-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.cbvt-scrub-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 8px;
  border-radius: 6px; background: #ece9f7; outline: none; margin: 2px 0;
}
.cbvt-scrub-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px;
  border-radius: 50%; background: #6a4cf1; cursor: pointer; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(106, 76, 241, 0.5);
}
.cbvt-scrub-range::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%; background: #6a4cf1;
  cursor: pointer; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(106, 76, 241, 0.5);
}
.cbvt-scrub-range:disabled { opacity: 0.5; }
.cbvt-scrub-time { font-size: 11.5px; color: #6b7280; text-align: center; margin-top: -6px; }
.cbvt-scrub-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* AI: Suggest frames (Video Studio WP7, spec §2.5) — top-3 suggestion grid
   shown inside the Pick-a-frame panel (same scrub player, no second video). */
.cbvt-suggest-grid { display: flex; gap: 8px; }
.cbvt-suggest-card {
  position: relative; flex: 1 1 0; min-width: 0;
  aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
  border: 2px solid #e5e7eb; background: #15172b; padding: 0; cursor: pointer;
  font-family: inherit;
}
.cbvt-suggest-card:hover { border-color: #6a4cf1; }
.cbvt-suggest-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cbvt-suggest-score {
  position: absolute; top: 4px; right: 4px;
  background: rgba(10, 10, 20, 0.72); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 6px; border-radius: 999px;
}

/* Subtitles tab — explainer / progress / editable-transcript states. */
.cbvt-subs-empty, .cbvt-subs-processing {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 18px 8px;
}
.cbvt-subs-empty-ico { font-size: 30px; }
.cbvt-subs-empty p, .cbvt-subs-processing p { margin: 0; font-size: 13px; color: #4b5563; line-height: 1.5; max-width: 380px; }
.cbvt-subs-note { font-size: 11.5px !important; color: #9ca3af !important; }
.cbvt-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid #ece9f7; border-top-color: #6a4cf1;
  animation: cbvt-spin 0.8s linear infinite;
}
@keyframes cbvt-spin { to { transform: rotate(360deg); } }

.cbvt-subs-editor { display: flex; flex-direction: column; gap: 10px; }
.cbvt-subs-rows {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px;
}
.cbvt-subs-row { display: flex; align-items: center; gap: 8px; }
.cbvt-subs-time {
  flex: none; width: 76px; font-size: 11px; font-variant-numeric: tabular-nums;
  color: #6b7280; font-weight: 600;
}
.cbvt-subs-text {
  flex: 1; min-width: 0; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 7px 10px; font-size: 13px; font-family: inherit; min-height: 34px;
}
.cbvt-subs-text:focus { outline: none; border-color: #6a4cf1; }
.cbvt-subs-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cbvt-subs-secondary { display: flex; }
.cbvt-text-btn {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 600; color: #9ca3af; padding: 4px 2px; min-height: 28px;
}
.cbvt-text-btn:hover { color: #6b7280; }

/* Trim tab (Video Studio WP6, spec §2.4) — reuses .cbvt-scrub-stage/
   .cbvt-scrub-range/.cbvt-scrub-time/.cbvt-scrub-actions from the pick-a-frame
   scrubber above; adds two labeled range sliders (start/end) instead of one. */
.cbvt-trim { display: flex; flex-direction: column; gap: 10px; }
.cbvt-trim-labels {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: #6b7280; font-weight: 600;
}
.cbvt-trim-labels b { color: #15172b; font-variant-numeric: tabular-nums; }
.cbvt-trim-sliders { display: flex; flex-direction: column; gap: 6px; }

/* Remove-gaps tab — quiet-moment suggestion list (parity with the recorder's
   own silence-detect checkbox rows, recorder/recorder.js renderSilence()). */
.cbvt-gaps { display: flex; flex-direction: column; gap: 10px; }
.cbvt-gaps-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: 10px; padding: 6px 8px;
}
.cbvt-gap-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: #374151; padding: 6px 2px; cursor: pointer;
}
.cbvt-gap-row span { display: inline-flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.cbvt-gap-row small { color: #9ca3af; }
.cbvt-gap-check { flex: none; width: 16px; height: 16px; accent-color: #6a4cf1; cursor: pointer; }

/* Thumbnail maker (Fabric.js) — spec §2.3.3 + decision §9.2. Widens the
   modal on desktop and swaps the small "what people see" preview column for
   the live canvas itself (it IS the preview while editing — restored by
   teardownMaker() on Back/Cancel/Save/close). */
.cbvt-modal--maker { max-width: 900px; }

.cbvt-maker { display: flex; flex-direction: column; gap: 12px; }

.cbvt-maker-stage {
  width: 100%; max-width: 640px; margin: 0 auto;
  aspect-ratio: 16 / 9; background: #15172b;
  border-radius: 10px; overflow: hidden; position: relative;
}
.cbvt-maker-stage canvas,
.cbvt-maker-stage .canvas-container {
  width: 100% !important; height: 100% !important; max-width: 100%;
}

.cbvt-maker-templates { display: flex; flex-wrap: wrap; gap: 8px; }
.cbvt-tmpl-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 76px; border: 1.5px solid #e5e7eb; border-radius: 10px;
  background: #fff; padding: 6px; cursor: pointer; font-family: inherit;
}
.cbvt-tmpl-chip:hover { border-color: #c9ccd3; }
.cbvt-tmpl-chip.active { border-color: #6a4cf1; box-shadow: 0 0 0 1px #6a4cf1 inset; }
.cbvt-tmpl-swatch {
  display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px;
  background: #15172b; position: relative; overflow: hidden;
}
.cbvt-tmpl-label { font-size: 10px; font-weight: 600; color: #374151; text-align: center; line-height: 1.2; }

/* Per-template visual hint inside the swatch, pure CSS (no bitmap thumbnails
   — templates are data, per spec). Approximates each layout at a glance. */
.cbvt-tmpl-scrim-bold .cbvt-tmpl-swatch { background: linear-gradient(to bottom, #4b4e63 0%, #4b4e63 55%, rgba(10,10,20,0.75) 55%, rgba(10,10,20,0.75) 100%); }
.cbvt-tmpl-colour-block-left .cbvt-tmpl-swatch { background: linear-gradient(to right, #6a4cf1 0%, #6a4cf1 38%, #4b4e63 38%, #4b4e63 100%); }
.cbvt-tmpl-centred-title .cbvt-tmpl-swatch { background: #6a4cf1; }
.cbvt-tmpl-logo-corner .cbvt-tmpl-swatch { background: linear-gradient(to bottom, #4b4e63 0%, #4b4e63 65%, rgba(10,10,20,0.7) 65%, rgba(10,10,20,0.7) 100%); }
.cbvt-tmpl-lower-third .cbvt-tmpl-swatch { background: linear-gradient(to bottom, #4b4e63 0%, #4b4e63 82%, #6a4cf1 82%, #6a4cf1 100%); }

.cbvt-maker-field { display: flex; flex-direction: column; gap: 6px; }
.cbvt-maker-field > span { font-size: 12px; font-weight: 600; color: #374151; }
.cbvt-maker-field input[type="text"] {
  border: 1px solid #e5e7eb; border-radius: 9px; padding: 9px 12px;
  font-size: 13.5px; font-family: inherit; min-height: 40px;
}
.cbvt-maker-field input[type="text"]:focus { outline: none; border-color: #6a4cf1; }

/* AI: Draft headline (Video Studio WP7, spec §2.5) — button sits inline with
   the headline input; chips below set the input + the live Fabric Textbox. */
.cbvt-maker-headline-row { display: flex; gap: 8px; }
.cbvt-maker-headline-row input[type="text"] { flex: 1; min-width: 0; }
.cbvt-maker-headline-row .cbvt-ghost-btn { flex: none; white-space: nowrap; }
.cbvt-headline-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cbvt-headline-chip {
  border: 1px solid #e5e7eb; background: #faf9ff; color: #15172b;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
}
.cbvt-headline-chip:hover { border-color: #6a4cf1; background: #ece9f7; }

.cbvt-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cbvt-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; box-shadow: 0 0 0 1px #e5e7eb; flex: none;
}
.cbvt-swatch.active { box-shadow: 0 0 0 2px #6a4cf1; }
.cbvt-swatch-custom {
  position: relative; overflow: hidden;
  background: conic-gradient(from 0deg, #ff004d, #ffe100, #00ff6a, #00c8ff, #7a3bff, #ff004d);
}
.cbvt-swatch-custom input[type="color"] {
  position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px);
  border: none; padding: 0; cursor: pointer; opacity: 0;
}

.cbvt-maker-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cbvt-maker-save-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

@media (max-width: 480px) {
  .cbvt-overlay { padding: 0; align-items: flex-end; }
  .cbvt-modal { max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .cbvt-body { flex-direction: column; padding: 6px 16px 16px; }
  .cbvt-preview { flex: none; width: 100%; max-width: 220px; margin: 0 auto; }
  .cbvt-action-card { min-height: 52px; }
  .cbvt-scrub-actions { flex-direction: column-reverse; }
  .cbvt-scrub-actions .cbvt-ghost-btn,
  .cbvt-scrub-actions .cbvt-primary-btn { width: 100%; }
  .cbvt-gap-row { padding: 8px 2px; } /* touch target */
  .cbvt-subs-actions { flex-direction: column-reverse; }
  .cbvt-subs-actions .cbvt-ghost-btn,
  .cbvt-subs-actions .cbvt-primary-btn { width: 100%; }
  .cbvt-modal--maker { max-width: 100%; }
  .cbvt-maker-stage { max-width: 100%; }
  .cbvt-maker-save-row { flex-direction: column-reverse; }
  .cbvt-maker-save-row .cbvt-ghost-btn,
  .cbvt-maker-save-row .cbvt-primary-btn { width: 100%; }
  .cbvt-maker-actions-row .cbvt-ghost-btn { flex: 1 1 auto; }
  .cbvt-maker-headline-row { flex-direction: column; }
  .cbvt-maker-headline-row .cbvt-ghost-btn { width: 100%; }
}
