/* =============================================
   Voice Viewer — Scoped styles (vv- prefix)
   Adapted from tau-voice visualization viewer.css
   ============================================= */

.voice-viewer {
  padding-bottom: 70px;
  --vv-user-color: #126CEB;
  --vv-user-bg: rgba(18, 108, 235, 0.10);
  --vv-user-bg-strong: rgba(18, 108, 235, 0.22);
  --vv-agent-color: #F96205;
  --vv-agent-bg: rgba(249, 98, 5, 0.10);
  --vv-agent-bg-strong: rgba(249, 98, 5, 0.22);
  --vv-accent: #006838;
  --vv-accent-light: #C1F1CB;
  --vv-surface: #ffffff;
  --vv-surface-alt: #F6F5F3;
  --vv-border: #D5D1CD;
  --vv-border-strong: #C1BCB7;
  --vv-text: #302E2D;
  --vv-text-secondary: #625E5B;
  --vv-text-muted: #898683;
  --vv-gray-dark: #898683;
  --vv-mono: 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  --vv-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --vv-radius: 8px;
  --vv-radius-sm: 5px;
  --vv-shadow-sm: 0 1px 3px rgba(5, 53, 29, 0.06);
  --vv-shadow: 0 2px 8px rgba(5, 53, 29, 0.08);

  font-family: var(--vv-sans);
  color: var(--vv-text);
  line-height: 1.5;
}

/* ── Loading / Error states ── */
.voice-viewer-loading,
.voice-viewer-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  padding: 2rem;
}

.voice-viewer-error p { color: #dc2626; }
.voice-viewer-error-hint {
  color: #94a3b8 !important;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.vv-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--vv-text-muted);
  font-size: 0.95rem;
}

/* ── Cards ── */
.vv-card {
  background: var(--vv-surface);
  border-radius: var(--vv-radius);
  box-shadow: var(--vv-shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--vv-border);
}

.vv-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--vv-surface-alt);
  border-bottom: 1px solid var(--vv-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--vv-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vv-card-header-icon { font-size: 14px; }

.vv-task-info-card {
  border-left: 4px solid var(--vv-accent);
}

/* ── Info Grid ── */
.vv-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--vv-border);
}

.vv-info-cell {
  background: var(--vv-surface);
  padding: 12px 16px;
}

.vv-info-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--vv-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.vv-info-value {
  font-size: 13px;
  color: var(--vv-text);
  word-break: break-word;
}

.vv-info-value pre {
  font-family: var(--vv-mono);
  font-size: 12px;
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Timeline Controls ── */
.vv-timeline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--vv-border);
  background: var(--vv-surface);
}

.vv-transport-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  border: 2px solid;
}

.vv-transport-icon {
  font-size: 16px;
  line-height: 1;
  display: block;
  padding-left: 2px;
}

.vv-transport-btn-play {
  border-color: var(--vv-accent);
  background: var(--vv-accent-light);
  color: var(--vv-accent);
}

.vv-transport-btn-play:hover:not(:disabled) {
  background: var(--vv-accent);
  color: #fff;
}

.vv-transport-btn-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.vv-time-display {
  font-size: 13px;
  font-family: var(--vv-mono);
  color: var(--vv-text-secondary);
  min-width: 100px;
}

.vv-speed-btn {
  margin-left: auto;
  background: var(--vv-surface-alt);
  border: 1px solid var(--vv-border);
  border-radius: var(--vv-radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--vv-text-secondary);
  cursor: pointer;
  font-family: var(--vv-mono);
  transition: all 0.15s;
}

.vv-speed-btn:hover:not(:disabled) { background: var(--vv-border); }
.vv-speed-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Timeline Card ── */
.vv-timeline-card .vv-track-label { width: 150px; }
.vv-timeline-card .vv-ruler-spacer { width: 150px; }

.vv-tl-tracks-area {
  position: relative;
  user-select: none;
}

.vv-tl-track-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.vv-tl-track-user {
  height: 64px;
  background: rgba(18, 108, 235, 0.03);
}

.vv-tl-track-agent {
  height: 56px;
  background: rgba(249, 98, 5, 0.03);
}

.vv-tl-track-wrap::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--vv-border);
}

.vv-tl-effects-lane {
  height: 28px;
}

/* Playhead line */
.vv-playhead-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--vv-accent);
  z-index: 20;
  pointer-events: none;
  left: 150px;
  opacity: 0;
  transition: opacity 0.2s;
}

.vv-playhead-line.active { opacity: 1; }

.vv-playhead-line::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--vv-accent);
}

/* Click overlay for seek */
.vv-tl-click-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 15;
  cursor: pointer;
}

/* Speech blocks */
.vv-tl-speech {
  position: absolute;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  transition: filter 0.15s;
  min-width: 3px;
}

.vv-tl-speech:hover { filter: brightness(0.92); }

.vv-tl-speech-user {
  top: 4px;
  bottom: 4px;
  background: var(--vv-user-bg-strong);
}

.vv-tl-speech-agent {
  top: 4px;
  bottom: 4px;
  background: var(--vv-agent-bg-strong);
}

.vv-tl-speech.active {
  box-shadow: inset 0 0 12px 2px rgba(255,255,255,0.3);
}

.vv-tl-speech-user.active { background: rgba(18, 108, 235, 0.38); }
.vv-tl-speech-agent.active { background: rgba(249, 98, 5, 0.38); }

/* Waveform bars */
.vv-tl-bar {
  position: absolute;
  width: 2px;
  border-radius: 1px;
}

.vv-tl-bar-user { background: rgba(18, 108, 235, 0.45); }
.vv-tl-bar-agent { background: rgba(249, 98, 5, 0.45); }

/* Background noise bars */
.vv-tl-noise-bar {
  position: absolute;
  width: 2px;
  border-radius: 1px;
  background: rgba(137, 134, 131, 0.2);
  top: 50%;
  transform: translateY(-50%);
}

/* Timeline legend */
.vv-tl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--vv-border);
  background: var(--vv-surface-alt);
  justify-content: center;
}

.vv-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--vv-text-secondary);
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: var(--vv-radius-sm);
}

.vv-legend-swatch {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.vv-legend-block {
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

.vv-legend-block-user { background: rgba(18, 108, 235, 0.5); }
.vv-legend-block-agent { background: rgba(249, 98, 5, 0.5); }

.vv-legend-effect-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  font-size: 9px;
  line-height: 1;
}

/* Track rows (shared layout) */
.vv-track-row {
  display: flex;
  border-bottom: 1px solid var(--vv-border);
}

.vv-track-label {
  width: 150px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--vv-surface-alt);
  border-right: 1px solid var(--vv-border);
}

.vv-track-accent {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.vv-track-info {
  flex: 1;
  min-width: 0;
}

.vv-track-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--vv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vv-track-desc {
  font-size: 10px;
  color: var(--vv-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ruler */
.vv-ruler-row {
  display: flex;
  background: var(--vv-surface-alt);
  border-bottom: 1px solid var(--vv-border);
}

.vv-ruler-spacer { flex-shrink: 0; }

.vv-ruler {
  flex: 1;
  position: relative;
  height: 22px;
}

.vv-ruler-mark {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--vv-border-strong);
  transform: translateX(-50%);
}

.vv-ruler-mark::after {
  content: attr(data-time);
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 9px;
  font-family: var(--vv-mono);
  color: var(--vv-text-muted);
  white-space: nowrap;
}

/* Annotation lanes */
.vv-annotation-lane {
  flex: 1;
  min-width: 0;
  height: 32px;
  position: relative;
  background: var(--vv-surface);
}

/* Effects */
.vv-effect {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 2px;
  opacity: 0.85;
  cursor: help;
  transition: opacity 0.15s;
  min-width: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vv-effect:hover { opacity: 1; z-index: 5; }

.vv-effect-icon {
  font-size: 10px;
  line-height: 1;
  filter: brightness(1.5);
}

.vv-effect-frame-drop {
  background: rgba(249, 98, 5, 0.5);
  border-left: 2px solid #F96205;
}

.vv-effect-burst-noise {
  background: rgba(105, 83, 160, 0.45);
  border-left: 2px solid #6953A0;
}

.vv-effect-out-of-turn-speech {
  background: rgba(236, 136, 27, 0.45);
  border-left: 2px solid #EC881B;
}

.vv-effect-background-noise {
  background: rgba(137, 134, 131, 0.25);
}

.vv-effect-telephony {
  background: rgba(30, 85, 194, 0.4);
  border-left: 2px solid #1E55C2;
}

/* Tooltip */
.vv-tooltip {
  position: fixed;
  background: #302E2D;
  color: #F6F5F3;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--vv-radius-sm);
  pointer-events: none;
  z-index: 200;
  white-space: pre-wrap;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(5, 53, 29, 0.2);
  opacity: 0;
  transition: opacity 0.12s;
  line-height: 1.4;
}

.vv-tooltip.show { opacity: 1; }

/* ── Conversation Table ── */
.vv-tick-table-wrapper {
  overflow-x: auto;
}

.vv-tick-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.vv-tick-table th {
  background: #05351D;
  color: #F6F5F3;
  padding: 10px 12px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vv-tick-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--vv-border);
  vertical-align: top;
  font-size: 13px;
}

.vv-tick-table tr:hover { background: var(--vv-surface-alt); }
.vv-tick-table tr.vv-playing { background: rgba(18, 108, 235, 0.08) !important; box-shadow: inset 3px 0 0 var(--vv-user-color); }

.vv-tick-col {
  width: 60px;
  font-family: var(--vv-mono);
  font-size: 12px;
  color: var(--vv-text-muted);
}

.vv-time-col {
  width: 90px;
  font-family: var(--vv-mono);
  font-size: 12px;
  color: var(--vv-text-muted);
  white-space: nowrap;
}

.vv-time-col-clickable {
  cursor: pointer;
}

.vv-time-col-clickable:hover {
  color: var(--vv-accent);
  text-decoration: underline;
}

.vv-agent-col {
  background: rgba(249, 98, 5, 0.04);
  word-break: break-word;
}

.vv-user-col {
  background: rgba(18, 108, 235, 0.04);
  word-break: break-word;
}

.vv-tool-col {
  background: rgba(236, 136, 27, 0.04);
  font-size: 12px;
}

.vv-tool-call-item {
  background: var(--vv-surface);
  border: 1px solid rgba(236, 136, 27, 0.4);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-family: var(--vv-mono);
  font-size: 11px;
  color: #0F3B90;
  word-break: break-word;
  white-space: pre-wrap;
}

.vv-tool-result-item { margin-bottom: 4px; }

.vv-tool-result-item summary {
  cursor: pointer;
  color: var(--vv-text-muted);
  font-size: 11px;
  padding: 4px 0;
}

.vv-tool-result-item pre {
  font-family: var(--vv-mono);
  font-size: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
  background: var(--vv-surface-alt);
  padding: 8px;
  border-radius: 4px;
  margin: 4px 0;
}

.vv-empty-cell {
  color: var(--vv-text-muted);
  font-style: italic;
}

/* Effects column in conversation table */
.vv-effects-col {
  background: rgba(105, 83, 160, 0.04);
  font-size: 12px;
  width: 160px;
}

.vv-effects-col-header { width: 160px; }

.vv-effect-item {
  padding: 2px 0;
  line-height: 1.4;
}

.vv-effect-label {
  font-weight: 600;
  text-transform: capitalize;
}

.vv-effect-time {
  color: var(--vv-text-muted);
  font-family: var(--vv-mono);
  font-size: 11px;
}

.vv-effect-item.vv-effect-frame-drop .vv-effect-label { color: #F96205; }
.vv-effect-item.vv-effect-burst-noise .vv-effect-label { color: #6953A0; }
.vv-effect-item.vv-effect-background-noise .vv-effect-label { color: #898683; }
.vv-effect-item.vv-effect-out-of-turn-speech .vv-effect-label { color: #EC881B; }
.vv-effect-item.vv-effect-telephony .vv-effect-label { color: #1E55C2; }

/* ── Sticky Audio Player ── */
.vv-sticky-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--vv-surface);
  color: var(--vv-text);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 1000;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  border-top: 1px solid var(--vv-border);
}

.vv-sticky-player audio {
  flex: 1;
  height: 36px;
  min-width: 0;
}

.vv-shortcut-hint {
  font-size: 11px;
  color: var(--vv-text-muted);
  white-space: nowrap;
}

.vv-audio-unavailable {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--vv-text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .vv-track-label { width: 100px !important; padding: 4px 8px; }
  .vv-track-desc { display: none; }
  .vv-timeline-card .vv-ruler-spacer { width: 100px !important; }
  .vv-timeline-card .vv-playhead-line { left: 100px; }
  .vv-info-grid { grid-template-columns: 1fr; }
  .vv-sticky-player { padding: 8px 12px; gap: 10px; }
  .vv-shortcut-hint { display: none; }
}
