/* =========================================================
   VOICE VIRTUAL REPRESENTATIVE — floating widget
   Fixed to the viewport, present on every page/section (not
   tied to the About layout). Two states: a collapsed pill
   (avatar + "Get Instant Answers" + Book) and an expanded
   voice/chat panel (wave, blurred backdrop, Book a Meeting,
   transcript, mic/speaker controls).
   ========================================================= */
.vr-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1035;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}

.vr-widget.vr-expanded .vr-pill,
.vr-widget.vr-expanded .vr-pill-form {
  display: none;
}

/* ---------------- Collapsed pill ---------------- */
.vr-pill {
  display: flex;
  align-items: stretch;
  background: #12151c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 15px 40px -10px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.vr-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
}

.vr-pill-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: transparent;
  border: none;
  color: #fff;
  padding: 0.5rem 0.9rem 0.5rem 0.5rem;
  cursor: pointer;
}

.vr-pill-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.vr-pill-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.vr-pill-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #12151c;
  animation: vr-dot-pulse 2s ease-out infinite;
}

@keyframes vr-dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.vr-pill-text {
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.vr-pill-book {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.vr-pill-book:hover {
  background: var(--cx-accent);
  color: #fff;
}

.vr-pill-book span {
  display: none;
}

@media (min-width: 480px) {
  .vr-pill-book span {
    display: inline;
  }
}

.vr-pill-form {
  width: 260px;
  max-width: calc(100vw - 40px);
}

.vr-pill-input {
  width: 100%;
  background: #12151c;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: #fff;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  outline: none;
  box-shadow: 0 15px 40px -10px rgba(0, 0, 0, 0.5);
}

.vr-pill-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.vr-pill-input:focus {
  border-color: var(--cx-accent);
}

/* ---------------- Expanded panel ---------------- */
.vr-panel {
  width: 360px;
  max-width: calc(100vw - 40px);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.65);
  transition: max-height 0.45s ease, opacity 0.35s ease;
  display: flex;
  flex-direction: column;
}

.vr-panel.vr-open {
  /* Never taller than the actual viewport - on a phone with the
     on-screen keyboard open, a fixed 720px could push the header
     (and its close button) off the top of the screen with no way to
     scroll back to it. */
  max-height: min(720px, calc(100vh - 24px));
  max-height: min(720px, calc(100dvh - 24px));
  opacity: 1;
  overflow-y: auto;
}

.vr-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #0d1117;
}

.vr-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}

.vr-wave span {
  width: 3px;
  background: var(--cx-accent);
  border-radius: 2px;
  height: 6px;
  opacity: 0.6;
  animation: vr-wave-idle 1.6s ease-in-out infinite;
}

.vr-wave span:nth-child(2) {
  animation-delay: 0.15s;
}
.vr-wave span:nth-child(3) {
  animation-delay: 0.3s;
}
.vr-wave span:nth-child(4) {
  animation-delay: 0.45s;
}
.vr-wave span:nth-child(5) {
  animation-delay: 0.6s;
}

@keyframes vr-wave-idle {
  0%,
  100% {
    height: 5px;
  }
  50% {
    height: 12px;
  }
}

@keyframes vr-wave-active {
  0%,
  100% {
    height: 6px;
  }
  50% {
    height: 22px;
  }
}

.vr-panel.vr-speaking .vr-wave span {
  animation-name: vr-wave-active;
  opacity: 1;
}

.vr-panel.vr-listening .vr-wave span {
  background: #22c55e;
  animation-name: vr-wave-active;
  opacity: 1;
}

.vr-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.1rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.vr-close:hover,
.vr-close:active {
  background: var(--cx-accent);
  color: #fff;
}

/* Tap-anywhere-outside-the-panel-to-close backdrop. Also gives mobile
   users an obvious, large dismiss target when the close button itself
   is hard to reach (e.g. behind the on-screen keyboard). */
.vr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 7, 0.45);
  z-index: 1034;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* .vr-overlay is a sibling placed right AFTER .vr-widget in the markup
   (both direct children of <body>) so this general-sibling selector
   picks it up, and its z-index (1034) stays safely below the widget's
   own stacking context (1035) - it can never cover the pill/panel. */
.vr-widget.vr-expanded ~ .vr-overlay {
  opacity: 1;
  pointer-events: auto;
}

.vr-stage {
  position: relative;
  padding: 1.1rem 1rem 1.3rem;
  overflow: hidden;
}

.vr-backdrop {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center 20%;
  filter: blur(28px) brightness(0.45) saturate(1.1);
  transform: scale(1.15);
}

.vr-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.2), rgba(13, 17, 23, 0.92));
}

.vr-stage-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.vr-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #fff;
  font-size: 0.78rem;
}

.vr-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: vr-dot-pulse 2s ease-out infinite;
}

.vr-book-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 12px 30px -10px rgba(34, 197, 94, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vr-book-btn:hover {
  transform: translateY(-2px);
  color: #fff;
  box-shadow: 0 16px 36px -8px rgba(34, 197, 94, 0.7);
}

.vr-body {
  flex: 1;
  height: 260px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.vr-msg {
  max-width: 85%;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.vr-msg--user {
  align-self: flex-end;
  background: var(--cx-accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.vr-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  color: #e6e6e6;
  border-bottom-left-radius: 3px;
}

.vr-msg--error {
  align-self: flex-start;
  background: rgba(212, 71, 41, 0.15);
  color: #ffb4a3;
  border: 1px solid rgba(212, 71, 41, 0.4);
}

.vr-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.6rem;
}

.vr-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.72rem;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.vr-chip:hover {
  background: var(--cx-accent);
  color: #fff;
  border-color: var(--cx-accent);
}

.vr-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.vr-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.vr-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.vr-input:focus {
  border-color: var(--cx-accent);
}

.vr-mic,
.vr-speaker,
.vr-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.vr-mic:hover,
.vr-speaker:hover {
  background: rgba(212, 71, 41, 0.2);
  color: #fff;
}

.vr-mic--listening {
  background: var(--cx-accent);
  color: #fff;
  border-color: var(--cx-accent);
  animation: vr-mic-pulse 1.4s ease-out infinite;
}

@keyframes vr-mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 71, 41, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(212, 71, 41, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(212, 71, 41, 0);
  }
}

.vr-mic--unsupported {
  opacity: 0.35;
  cursor: not-allowed;
}

.vr-speaker--muted {
  color: rgba(255, 255, 255, 0.35);
}

.vr-send {
  background: var(--cx-accent);
  border: none;
  color: #fff;
}

.vr-send:hover {
  transform: scale(1.08);
}

.vr-send:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

@media (max-width: 480px) {
  .vr-widget {
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: stretch;
  }

  .vr-panel,
  .vr-pill-form {
    width: 100%;
    max-width: none;
  }

  .vr-panel.vr-open {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .vr-stage {
    padding: 0.8rem 1rem 1rem;
  }

  .vr-body {
    height: 38vh;
  }
}
