/* ============================================
   Voice Widget — skynotes.ca
   Floating Vapi voice call + chat transcript
   ============================================ */

:root {
  --vw-primary: #0b2a50;
  --vw-accent: #30db00;
  --vw-accent-hover: #00e5f7;
  --vw-bg: #0d1f3c;
  --vw-bubble-user: #1a3a5c;
  --vw-bubble-assistant: #0b2a50;
  --vw-text: #e8edf3;
  --vw-text-muted: #8a9bb5;
  --vw-radius: 16px;
  --vw-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* ---- FAB avatar image ---- */
.vw-fab-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.7);
  flex-shrink: 0;
}

/* ---- Animated angle property for rotating border ---- */
@property --vw-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* ---- Floating Button ---- */
.vw-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 10001;
  height: 52px;
  padding: 0 22px;
  border-radius: 26px;
  border: none;
  background: linear-gradient(135deg, #002fdb, #052041);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(48,219,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
  overflow: visible;
}

/* Slide-in entrance: parked off-screen right until .vw-revealed is added.
   Uses a longer transition with bounce, then settles back to the standard
   short transform transition for hover. */
.vw-fab:not(.vw-revealed) {
  transform: translateX(calc(100% + 60px));
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
  .vw-fab:not(.vw-revealed) {
    transform: none;
    transition: none;
  }
}

/* Rotating border highlight — animates gradient angle, works on any shape */
.vw-fab::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border-radius: 30px;
  background: conic-gradient(
    from var(--vw-angle),
    transparent 0%,
    transparent 88%,
    rgba(48,219,0,0.15) 91%,
    rgba(48,219,0,0.4) 94%,
    #6bff8c 96%,
    #30db00 98%,
    #83fb8e 100%
  );
  /* Mask out the interior — only the 3px border ring is visible */
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  padding: 3px;
  border-radius: 30px;
  animation: vw-border-spin 2.5s linear infinite;
  pointer-events: none;
}

/* Active state — red sweep */
.vw-fab.active::after {
  background: conic-gradient(
    from var(--vw-angle),
    transparent 0%,
    transparent 88%,
    rgba(231,76,60,0.15) 91%,
    rgba(231,76,60,0.4) 94%,
    #ff6b6b 96%,
    #e74c3c 98%,
    #ff8c8c 100%
  );
}

@keyframes vw-border-spin {
  0%   { --vw-angle: 0deg; }
  100% { --vw-angle: 360deg; }
}

.vw-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(48,219,0,0.55);
}
.vw-fab:hover::after {
  animation-duration: 1.5s;
}
.vw-fab.active {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  box-shadow: 0 4px 20px rgba(231,76,60,0.4);
}
.vw-fab.active:hover {
  box-shadow: 0 6px 28px rgba(231,76,60,0.55);
}

/* Pulse ring when call is active */
.vw-fab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 26px;
  border: 2px solid rgba(231,76,60,0.6);
  animation: vw-pulse 1.8s ease-out infinite;
}

@keyframes vw-pulse {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.15, 1.4); opacity: 0; }
}

/* ---- Chat Panel ---- */
.vw-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 10000;
  width: 380px;
  max-height: 520px;
  border-radius: var(--vw-radius);
  background: var(--vw-bg);
  box-shadow: var(--vw-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.vw-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.vw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--vw-primary);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.vw-header-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
  transition: background 0.3s;
}
.vw-header-dot.listening { background: var(--vw-accent); }
.vw-header-dot.speaking  { background: var(--vw-accent-hover); animation: vw-dot-pulse 0.8s ease-in-out infinite alternate; }
.vw-header-dot.connecting { background: #f39c12; animation: vw-dot-pulse 0.5s ease-in-out infinite alternate; }

@keyframes vw-dot-pulse {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0.4; transform: scale(0.7); }
}

.vw-header-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex: 1;
}
.vw-header-status {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--vw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.vw-close-btn {
  background: none;
  border: none;
  color: var(--vw-text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 0 0 8px;
  transition: color 0.2s;
}
.vw-close-btn:hover { color: #fff; }

/* Messages area */
.vw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
  max-height: 360px;
}
.vw-messages::-webkit-scrollbar { width: 4px; }
.vw-messages::-webkit-scrollbar-track { background: transparent; }
.vw-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Welcome state */
.vw-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 12px;
  flex: 1;
}
.vw-welcome-icon {
  font-size: 40px;
  color: var(--vw-accent);
}
.vw-welcome h4 {
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.vw-welcome p {
  color: var(--vw-text-muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
}

/* Chat bubbles */
.vw-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--vw-text);
  word-wrap: break-word;
  animation: vw-fade-in 0.2s ease-out;
}
@keyframes vw-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vw-bubble.assistant {
  align-self: flex-start;
  background: var(--vw-bubble-assistant);
  border-bottom-left-radius: 4px;
}
.vw-bubble.user {
  align-self: flex-end;
  background: var(--vw-bubble-user);
  border-bottom-right-radius: 4px;
}
.vw-bubble .vw-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--vw-text-muted);
  margin-bottom: 2px;
}
.vw-bubble.assistant .vw-role { color: var(--vw-accent); }
.vw-bubble.user .vw-role { color: var(--vw-accent-hover); }

/* Typing indicator */
.vw-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.vw-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vw-text-muted);
  animation: vw-typing-bounce 1.2s ease-in-out infinite;
}
.vw-typing span:nth-child(2) { animation-delay: 0.15s; }
.vw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes vw-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Footer */
.vw-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.vw-footer-text {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--vw-text-muted);
}
.vw-volume-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}
.vw-volume-bars span {
  width: 3px;
  background: var(--vw-accent);
  border-radius: 2px;
  transition: height 0.1s;
}

/* ---- Responsive ---- */
@media (max-width: 440px) {
  .vw-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 96px;
    max-height: 65vh;
  }
  .vw-fab {
    bottom: 18px;
    right: 12px;
    left: 12px;
    width: auto;
    height: 48px;
    font-size: 14px;
    padding: 0 18px;
    justify-content: center;
  }
}
