/* ============================================
   VOICE AGENT WIDGET — Custom ABB-style
   ElevenLabs Conversational AI integration
   ============================================ */

/* ---------- FAB (Floating Action Button) ---------- */

.va-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 16px;
  height: 48px;
  background: rgba(10, 22, 40, 0.95);
  border: 1px solid rgba(212, 146, 10, 0.4);
  border-radius: 999px;
  color: var(--color-accent);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 24px rgba(10, 22, 40, 0.4), 0 0 0 1px rgba(212, 146, 10, 0.08);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-body);
  outline: none;
}

.va-fab:hover {
  transform: translateY(-2px);
  border-color: var(--color-accent);
  background: rgba(10, 22, 40, 0.98);
  box-shadow: 0 8px 32px rgba(10, 22, 40, 0.5), 0 0 16px rgba(212, 146, 10, 0.15);
}

.va-fab:active {
  transform: translateY(0);
}

.va-fab.va-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.va-fab-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.va-fab-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.va-fab-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  flex-shrink: 0;
  animation: va-pulse-glow 2s ease-in-out infinite;
}

.va-fab-pulse.va-connected {
  background: #34D399;
  animation: va-pulse-glow-green 2s ease-in-out infinite;
}

@keyframes va-pulse-glow {
  0%, 100% { opacity: 0.4; box-shadow: 0 0 0 0 rgba(212, 146, 10, 0.3); }
  50% { opacity: 1; box-shadow: 0 0 0 4px rgba(212, 146, 10, 0); }
}

@keyframes va-pulse-glow-green {
  0%, 100% { opacity: 0.4; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.3); }
  50% { opacity: 1; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}

/* Mobile: icon-only circle */
@media (max-width: 600px) {
  .va-fab {
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
    right: 16px;
    bottom: 16px;
  }
  .va-fab-label,
  .va-fab-pulse {
    display: none;
  }
}

/* ---------- OVERLAY ---------- */

.va-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(10, 15, 26, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.va-overlay.va-open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- PANEL ---------- */

.va-panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1002;
  width: 380px;
  max-height: calc(100vh - 56px);
  background: rgba(10, 15, 26, 0.97);
  border: 1px solid rgba(212, 146, 10, 0.3);
  border-radius: 6px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Closed state */
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.va-panel.va-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- PANEL HEADER ---------- */

.va-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(212, 146, 10, 0.15);
}

.va-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.va-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(212, 146, 10, 0.4);
  flex-shrink: 0;
  transition: background 0.3s ease;
}

.va-header-dot.va-status-connected {
  background: #34D399;
}

.va-header-dot.va-status-speaking {
  background: #C75B2E;
  animation: va-speaking-pulse 0.8s ease-in-out infinite;
}

@keyframes va-speaking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.va-header-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #F5F3ED;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.va-header-status {
  font-size: 11px;
  color: rgba(245, 243, 239, 0.45);
  letter-spacing: 0.04em;
}

.va-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.va-btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(245, 243, 239, 0.45);
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.2s ease;
}

.va-btn-icon:hover {
  color: #F5F3ED;
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- ORB VISUALIZER ---------- */

.va-orb-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 8px;
}

.va-orb {
  position: relative;
  width: 120px;
  height: 120px;
}

.va-orb canvas {
  width: 100%;
  height: 100%;
}

.va-orb-label {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(245, 243, 239, 0.35);
  white-space: nowrap;
}

/* ---------- CTA BUTTON ---------- */

.va-cta-area {
  padding: 12px 16px;
}

.va-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: var(--font-body);

  /* Default: start */
  background: var(--color-accent);
  color: #0A0F1A;
}

.va-cta:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.va-cta.va-cta-active {
  background: #C75B2E;
  color: #F5F3ED;
}

.va-cta.va-cta-connecting {
  background: rgba(212, 146, 10, 0.3);
  color: var(--color-accent);
  cursor: wait;
}

.va-cta-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: va-spin 0.6s linear infinite;
}

@keyframes va-spin {
  to { transform: rotate(360deg); }
}

/* ---------- TRANSCRIPT ---------- */

.va-transcript {
  flex: 1;
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 146, 10, 0.2) transparent;
}

.va-transcript::-webkit-scrollbar {
  width: 4px;
}

.va-transcript::-webkit-scrollbar-track {
  background: transparent;
}

.va-transcript::-webkit-scrollbar-thumb {
  background: rgba(212, 146, 10, 0.2);
  border-radius: 4px;
}

.va-transcript-placeholder {
  font-size: 13px;
  color: rgba(245, 243, 239, 0.25);
  text-align: center;
  padding: 16px;
  line-height: 1.6;
}

.va-msg {
  animation: va-msg-in 0.3s ease;
}

@keyframes va-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.va-msg-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}

.va-msg[data-role="agent"] .va-msg-role {
  color: var(--color-accent);
}

.va-msg[data-role="user"] .va-msg-role {
  color: rgba(245, 243, 239, 0.35);
}

.va-msg-text {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(245, 243, 239, 0.8);
}

.va-msg-text.va-tentative {
  font-style: italic;
  opacity: 0.6;
}

/* ---------- FOOTER ---------- */

.va-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(212, 146, 10, 0.1);
  text-align: center;
}

.va-footer-text {
  font-size: 10px;
  color: rgba(245, 243, 239, 0.2);
  letter-spacing: 0.06em;
}

/* ---------- MOBILE ---------- */

@media (max-width: 600px) {
  .va-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 16px;
    max-height: 85vh;
  }
}
