/* ─── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #060b1a;
  --bg-card:     #0c1428cc;
  --border:      #1e3a5f;
  --border-glow: #2a5298;
  --accent-blue: #4a9eff;
  --accent-cyan: #00d4ff;
  --accent-pink: #ff6b9d;
  --accent-gold: #f5a623;
  --text-primary:   #e8f4fd;
  --text-secondary: #7ab3d4;
  --text-muted:     #3d6b8a;
  --red-dot:  #ff4444;
  --btn-bg:   #0f1f3d;
  --btn-hover:#162847;
  --radius:   16px;
  --radius-sm: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  overflow-x: hidden;
}

/* ─── Starfield background ─────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, #0d1f4a22 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, #1a0d4a22 0%, transparent 60%),
    radial-gradient(ellipse at 50% 80%, #0a1a3a33 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Layout ────────────────────────────────────────────────────────── */
.app-wrapper {
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 24px;
  gap: 24px;
}

.app-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panels {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

/* ─── Card / Panel ──────────────────────────────────────────────────── */
.panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .25s;
}
.panel:hover { border-color: var(--border-glow); }

/* ─── Panel Header ──────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border-glow);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: #0a142a;
}

.panel-icon.text  { border-color: var(--accent-blue); color: var(--accent-blue); }
.panel-icon.voice { border-color: #a855f7; color: #a855f7; }
.panel-icon.vv    { border-color: var(--accent-gold); color: var(--accent-gold); }

.panel-title-wrap { flex: 1; }
.panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-primary);
}
.panel-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.panel-badge {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-blue);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.panel-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: color .2s;
}
.panel-menu:hover { color: var(--text-secondary); }

/* ─── Panel Body ────────────────────────────────────────────────────── */
.panel-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  justify-content: space-between;
}

/* ─── Waveform ──────────────────────────────────────────────────────── */
.waveform-container {
  position: relative;
  flex-shrink: 0;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.waveform-container.playing canvas,
.waveform-container.recording canvas { opacity: 1; }

canvas.waveform {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.6;
  transition: opacity .3s;
}

.waveform-label {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Textarea ──────────────────────────────────────────────────────── */
.chat-input {
  width: 100%;
  height: 72px;
  background: #07101f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 14px;
  resize: none;
  outline: none;
  transition: border-color .2s;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus { border-color: var(--accent-blue); }

/* ─── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-glow);
}
.btn-primary:hover { background: var(--btn-hover); }

.btn-record {
  background: #1a0a0a;
  color: var(--text-primary);
  border: 1px solid #5a1a1a;
}
.btn-record:hover { background: #220d0d; }
.btn-record.recording {
  background: #2a0808;
  border-color: var(--red-dot);
  animation: pulse-border 1.5s ease-in-out infinite;
}

.btn-send {
  background: #0a1830;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}
.btn-send:hover { background: #0f2040; }

.red-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red-dot);
  flex-shrink: 0;
}
.btn-record.recording .red-dot {
  animation: blink 1s step-start infinite;
}

/* ─── Audio Player ──────────────────────────────────────────────────── */
.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #07101f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.player-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 16px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s;
  flex-shrink: 0;
}
.player-btn:hover { color: var(--accent-blue); }

.player-progress {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
}

/* ─── Chat Bubbles ──────────────────────────────────────────────────── */
.chat-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.chat-history::-webkit-scrollbar { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
}
.bubble.user {
  align-self: flex-end;
  background: #1a2a4a;
  border: 1px solid var(--border-glow);
  color: var(--text-primary);
}
.bubble.agent {
  align-self: flex-start;
  background: #0c1a30;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* bolhas dentro do Voice-to-Chat ocupam largura total */
#vtc-history .bubble {
  max-width: 100%;
  align-self: stretch;
}
.bubble-agent-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bubble-agent-label .agent-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: white;
}

/* ─── Status labels ─────────────────────────────────────────────────── */
.status-label {
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}
.status-label.active { color: var(--accent-gold); }

/* ─── AI Avatar (Voice-to-Voice) ────────────────────────────────────── */
.ai-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a3a8a, #6b21a8);
  border: 2px solid #4a2a8a;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: white;
  margin: 0 auto;
  box-shadow: 0 0 20px #4a2a8a66;
}
.ai-avatar.pulsing {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

/* ─── Transport controls ────────────────────────────────────────────── */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.transport .player-btn { font-size: 18px; }
.transport .player-btn.play-main {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}

/* ─── Bubble group (Voice-to-Chat exchange pair) ────────────────────── */
.bubble-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Dot nav ───────────────────────────────────────────────────────── */
.dot-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 4px;
}
.dot-nav .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background .2s;
}
.dot-nav .dot.active { background: var(--text-secondary); }

/* ─── Loading spinner ───────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.loading .spinner { display: block; }
.loading .btn-label { display: none; }

/* ─── Disabled state ────────────────────────────────────────────────── */
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ─── Animations ────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 #ff444422; }
  50%       { box-shadow: 0 0 0 6px #ff444411; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px #4a2a8a66; }
  50%       { box-shadow: 0 0 35px #4a2a8aaa; }
}

/* ─── Hint text (inside chat-to-voice right side) ───────────────────── */
.panel-hint {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
}

/* ─── Waveform do Chat-to-Voice cresce para preencher espaço ────────── */
.ctv-wave-wrap { flex: 1; min-height: 80px; }

/* wrapper absorve o stretch do flexbox, input fica na altura natural */
.vtv-progress-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  flex-shrink: 0;
}
.vtv-progress-wrap #vtv-progress {
  width: 100%;
}

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .panels { flex-direction: column; }
  .panel-body.two-col { grid-template-columns: 1fr; }
}
