/* ── Coaching Tools — Telestrator, Speed, Screenshot, Clip ── */

/* ── Telestrator canvas ──────────────────────────────────── */
#tele-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}
#tele-canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
}

/* ── Crop overlay ────────────────────────────────────────── */
#crop-overlay {
  position: absolute; inset: 0; z-index: 8;
  pointer-events: none;
}
#crop-overlay.crop-active { pointer-events: auto; cursor: crosshair; touch-action: none; }
.crop-rect {
  position: absolute; display: none;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
  box-sizing: border-box; cursor: move;
  pointer-events: auto; /* works even when overlay has pointer-events:none */
}
.crop-handle {
  position: absolute; width: 10px; height: 10px;
  background: #fff; border: 1px solid rgba(0,0,0,.35);
  border-radius: 2px; pointer-events: auto;
}
/* corners */
.crop-handle-nw { top:-5px;    left:-5px;              cursor: nw-resize; }
.crop-handle-ne { top:-5px;    right:-5px;             cursor: ne-resize; }
.crop-handle-sw { bottom:-5px; left:-5px;              cursor: sw-resize; }
.crop-handle-se { bottom:-5px; right:-5px;             cursor: se-resize; }
/* edges */
.crop-handle-n  { top:-5px;    left:50%; transform:translateX(-50%); cursor: n-resize; }
.crop-handle-s  { bottom:-5px; left:50%; transform:translateX(-50%); cursor: s-resize; }
.crop-handle-e  { right:-5px;  top:50%;  transform:translateY(-50%); cursor: e-resize; }
.crop-handle-w  { left:-5px;   top:50%;  transform:translateY(-50%); cursor: w-resize; }
/* track dot */
.track-dot {
  position: absolute; width: 14px; height: 14px;
  border: 2px solid #facc15; border-radius: 50%;
  background: rgba(250,204,21,.25);
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 9;
  box-shadow: 0 0 0 3px rgba(250,204,21,.2);
}
.ct-btn.ct-crop-active  { background: rgba(234,179,8,.18); border-color: rgba(234,179,8,.5); color: #eab308; }
.ct-btn.ct-track-active { background: rgba(250,204,21,.18); border-color: rgba(250,204,21,.5); color: #facc15; }

/* ── Coach puck (collapsed trigger) ─────────────────────── */
#coach-puck {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 11;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, transform .1s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#coach-puck:hover {
  background: rgba(239,68,68,.35);
  border-color: rgba(239,68,68,.5);
  transform: scale(1.08);
}

/* ── Coach toolbar ───────────────────────────────────────── */
#coach-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: rgba(10,12,20,.88);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 6px 8px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: calc(100% - 20px);
}
#coach-toolbar[hidden] { display: none !important; }

.ct-btn {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: var(--text, #e2e8f0);
  font-size: 14px;
  padding: 5px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
  line-height: 1;
}
.ct-btn:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.22);
}
.ct-btn.ct-active {
  background: rgba(239,68,68,.25);
  border-color: rgba(239,68,68,.55);
  color: #ef4444;
}
.ct-btn:disabled {
  opacity: .35;
  cursor: default;
}
.ct-close-btn:hover {
  background: rgba(239,68,68,.25);
  border-color: rgba(239,68,68,.5);
}
.ct-export-btn:not(:disabled) {
  background: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.4);
  color: #ef4444;
}
.ct-export-btn:not(:disabled):hover {
  background: rgba(239,68,68,.28);
  border-color: rgba(239,68,68,.7);
}

.ct-sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,.12);
  flex-shrink: 0;
  margin: 0 2px;
}

.ct-color {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.ct-color::-webkit-color-swatch-wrapper { padding: 0; }
.ct-color::-webkit-color-swatch { border-radius: 4px; border: none; }

/* ── Clip status bar ─────────────────────────────────────── */
.clip-status {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  background: rgba(10,12,20,.82);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text, #e2e8f0);
  letter-spacing: .03em;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Seek-bar clip markers ────────────────────────────────── */
.sb-clip-mark {
  position: absolute;
  top: -5px;
  width: 3px;
  height: calc(100% + 10px);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 4;
}
.sb-clip-in  { background: #22c55e; }
.sb-clip-out { background: #ef4444; }
.sb-clip-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(239,68,68,.18);
  pointer-events: none;
  z-index: 3;
}

/* ── Speed select in controls bar ────────────────────────── */
.ctrl-speed {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: var(--text, #e2e8f0);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 6px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.ctrl-speed:hover { border-color: rgba(255,255,255,.22); }
.ctrl-speed:focus { border-color: rgba(239,68,68,.5); }
.ctrl-speed option { background: #1a1d27; color: #e2e8f0; }

.speed-pill {
  background: rgba(239,68,68,.2);
  border: 1px solid rgba(239,68,68,.4);
  border-radius: 4px;
  color: #ef4444;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  letter-spacing: .03em;
}

/* ── Clip export modal ───────────────────────────────────── */
#clip-modal {
  background: rgba(13,17,28,.96);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  color: var(--text, #e2e8f0);
  padding: 0;
  max-width: 360px;
  width: 100%;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#clip-modal::backdrop {
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(2px);
}
.cm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.cm-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.cm-close {
  background: none;
  border: none;
  color: var(--text-dim, #64748b);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
.cm-close:hover { color: var(--text, #e2e8f0); background: rgba(255,255,255,.06); }
.cm-meta {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-dim, #64748b);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.cm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
}
.cm-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim, #64748b);
  width: 52px;
  flex-shrink: 0;
}
.cm-btns { display: flex; gap: 6px; }
.cm-fmt, .cm-sz {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: var(--text, #e2e8f0);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  transition: all .15s;
}
.cm-fmt:hover, .cm-sz:hover { border-color: rgba(255,255,255,.22); }
.cm-fmt.active, .cm-sz.active {
  background: rgba(239,68,68,.2);
  border-color: rgba(239,68,68,.5);
  color: #ef4444;
}
.cm-progress {
  padding: 10px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.cm-bar-track {
  height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.cm-bar-fill {
  height: 100%;
  background: #ef4444;
  border-radius: 2px;
  transition: width .3s;
  width: 0%;
}
.cm-prog-label {
  font-size: 11px;
  color: var(--text-dim, #64748b);
}
.cm-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.cm-gen {
  flex: 1;
  background: rgba(239,68,68,.18);
  border: 1px solid rgba(239,68,68,.45);
  border-radius: 8px;
  color: #ef4444;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.cm-gen:hover:not(:disabled) {
  background: rgba(239,68,68,.3);
  border-color: rgba(239,68,68,.7);
}
.cm-gen:disabled { opacity: .4; cursor: default; }
.cm-cancel-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: var(--text-dim, #64748b);
  font-size: 13px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .15s;
}
.cm-cancel-btn:hover { background: rgba(255,255,255,.1); }

/* ── Quick color swatches ────────────────────────────────── */
.ct-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: border-color .12s, transform .1s;
}
#ct-sw-red   { background: #ef4444; }
#ct-sw-green { background: #22c55e; }
#ct-sw-blue  { background: #3b82f6; }
.ct-swatch:hover { transform: scale(1.18); border-color: rgba(255,255,255,.5); }
.ct-swatch.ct-sw-active {
  border-color: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}

/* ── Opacity slider ──────────────────────────────────────── */
.ct-opacity {
  width: 64px;
  height: 4px;
  accent-color: #ef4444;
  cursor: pointer;
  vertical-align: middle;
}

/* ── Dim overlay (behind canvas, above video) ────────────── */
#tele-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(0,0,0,.25);
  pointer-events: none;
}

/* ── Mobile adjustments ──────────────────────────────────── */
@media (max-width: 600px) {
  #coach-toolbar {
    top: auto;
    bottom: 52px;
    right: 6px;
    max-width: calc(100vw - 12px);
  }
  #coach-puck {
    top: auto;
    bottom: 52px;
    right: 6px;
  }
  .clip-status { font-size: 10px; padding: 3px 8px; }
  #clip-modal { max-width: 100vw; border-radius: 14px 14px 0 0; }
}
