/* Website voice assistant (resources/views/components/voice-assistant.blade.php).
   Self-contained: every rule is scoped under .rva so page styles are untouched. */

#rva.rva {
  --rva-bg: #0b0b14;
  --rva-surface: #14141f;
  --rva-surface-2: #1c1c2b;
  --rva-border: rgba(255, 255, 255, .09);
  --rva-text: #f4f4f8;
  --rva-muted: #a3a3b8;
  --rva-accent: #a855f7;
  --rva-accent-2: #7e22ce;
  --rva-accent-3: #3b82f6;
  --rva-grad: linear-gradient(135deg, #a855f7 0%, #7e22ce 55%, #4338ca 100%);
  --rva-danger: #f87171;
  --rva-radius: 22px;
  --rva-shadow: 0 24px 60px -12px rgba(10, 4, 30, .55), 0 0 0 1px rgba(255, 255, 255, .06);
  --rva-tamil: 'Noto Sans Tamil', 'Nirmala UI', 'Latha', 'Tamil Sangam MN';
  --rva-font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, var(--rva-tamil), sans-serif;
  --rva-font-display: 'Sora', 'Outfit', var(--rva-tamil), sans-serif;
  visibility: visible;
  font-family: var(--rva-font);
  color: var(--rva-text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.rva *, .rva *::before, .rva *::after { box-sizing: border-box; }
.rva [hidden] { display: none !important; }
.rva button { font: inherit; color: inherit; cursor: pointer; }
.rva :focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
.rva-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Launcher: stacked above the site's WhatsApp (bottom 28px) and back-to-top
   (bottom 100px) buttons in the same right-hand column. ------------------- */
.rva-launcher {
  position: fixed; right: 28px; bottom: 172px; z-index: 10000;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 18px 7px 7px;
  border: 0; border-radius: 999px;
  background: rgba(11, 11, 20, .92);
  box-shadow: var(--rva-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .2s ease, box-shadow .2s ease;
}
.rva-launcher:hover { transform: translateY(-2px); }
.rva-launcher__orb {
  position: relative; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--rva-grad); color: #fff;
}
.rva-launcher__orb::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, .55);
  animation: rva-pulse 2.6s ease-out infinite;
}
.rva-launcher__label { font-family: var(--rva-font-display); font-weight: 600; font-size: 14px; letter-spacing: .01em; }
.rva-launcher[aria-expanded="true"] { display: none; }

/* Panel ------------------------------------------------------------------- */
.rva-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 10001;
  display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 40px));
  height: min(640px, calc(100dvh - 40px));
  overflow: hidden;
  border-radius: var(--rva-radius);
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(126, 34, 206, .28), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(59, 130, 246, .14), transparent 60%),
    var(--rva-bg);
  box-shadow: var(--rva-shadow);
  transform-origin: bottom right;
  animation: rva-open .22s cubic-bezier(.2, .9, .3, 1.2);
}

.rva-head { display: flex; align-items: center; gap: 12px; padding: 16px 14px 14px 16px; border-bottom: 1px solid var(--rva-border); }
.rva-head__orb { position: relative; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--rva-grad); box-shadow: 0 0 22px rgba(168, 85, 247, .45); }
.rva-head__orb i { position: absolute; inset: 11px; border-radius: 50%; background: rgba(255, 255, 255, .9); transition: transform .3s ease; }
.rva-panel[data-state="listening"] .rva-head__orb i { animation: rva-breathe 1s ease-in-out infinite; }
.rva-panel[data-state="speaking"] .rva-head__orb i { animation: rva-breathe .6s ease-in-out infinite; }
.rva-panel[data-state="processing"] .rva-head__orb { animation: rva-spin 1.4s linear infinite; background: conic-gradient(from 0deg, #a855f7, #3b82f6, #7e22ce, #a855f7); }
/* In a conversation the orb gives way to the chosen persona's photo, ringed by the same state colours. */
.rva-head__avatar { position: relative; flex: none; display: none; width: 40px; height: 40px; border-radius: 50%; padding: 2px; background: var(--rva-grad); }
.rva-head__avatar img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--rva-surface-2); }
.rva-head__avatar::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(168, 85, 247, .6); opacity: 0; }
.rva-panel[data-view="chat"] .rva-head__orb { display: none; }
.rva-panel[data-view="chat"] .rva-head__avatar { display: block; }
.rva-panel[data-state="listening"] .rva-head__avatar::after { border-color: rgba(239, 68, 68, .7); animation: rva-pulse 1.2s ease-out infinite; }
.rva-panel[data-state="speaking"] .rva-head__avatar::after { animation: rva-pulse .9s ease-out infinite; }
.rva-panel[data-state="processing"] .rva-head__avatar { background: conic-gradient(from 0deg, #a855f7, #3b82f6, #7e22ce, #a855f7); animation: rva-spin 1.4s linear infinite; }
.rva-panel[data-state="processing"] .rva-head__avatar img { animation: rva-spin 1.4s linear infinite reverse; }
.rva-panel[data-view="intro"] [data-rva="team"] { display: none; }
.rva-head__text { min-width: 0; flex: 1; }
.rva-head__title { margin: 0; font-family: var(--rva-font-display); font-size: 15px; font-weight: 700; color: #fff; }
.rva-head__status { margin: 2px 0 0; font-size: 12.5px; color: var(--rva-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rva-panel[data-state="error"] .rva-head__status { color: var(--rva-danger); }
.rva-head__actions { display: flex; align-items: center; gap: 4px; }

.rva-lang { display: flex; padding: 3px; margin-right: 4px; border-radius: 999px; background: var(--rva-surface-2); border: 1px solid var(--rva-border); }
.rva-lang__btn { padding: 4px 9px; border: 0; border-radius: 999px; background: transparent; font-size: 12px; font-weight: 600; color: var(--rva-muted); }
.rva-lang__btn[aria-pressed="true"] { background: var(--rva-grad); color: #fff; }

.rva-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--rva-muted); }
.rva-icon:hover { background: var(--rva-surface-2); color: #fff; }
.rva-icon .rva-ico-off, .rva-icon[aria-pressed="true"] .rva-ico-on { display: none; }
.rva-icon[aria-pressed="true"] .rva-ico-off { display: block; color: var(--rva-danger); }

/* Body -------------------------------------------------------------------- */
.rva-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; overscroll-behavior: contain; }
.rva-body::-webkit-scrollbar { width: 6px; }
.rva-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 6px; }

.rva-intro__title { margin: 0 0 6px; font-family: var(--rva-font-display); font-size: 19px; font-weight: 700; color: #fff; }
.rva-intro__text { margin: 0 0 14px; font-size: 14px; color: #d4d4e0; }
.rva-notice { padding: 10px 12px; margin-bottom: 8px; border-radius: 14px; background: rgba(168, 85, 247, .08); border: 1px solid rgba(168, 85, 247, .22); font-size: 12.5px; color: #d9d2f5; }
.rva-notice p { margin: 0; }
.rva-notice details { margin-top: 8px; }
.rva-notice summary { cursor: pointer; font-weight: 600; color: #e9d5ff; }
.rva-notice ul { margin: 8px 0 0; padding-left: 18px; }
.rva-notice li { margin: 4px 0; }

/* AI team: pick a persona, then "Let's Talk" -------------------------------- */
.rva-team { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.rva-member {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 10px; border-radius: 18px;
  border: 1.5px solid var(--rva-border);
  background: linear-gradient(180deg, rgba(168, 85, 247, .10), rgba(255, 255, 255, .02));
  text-align: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.rva-member:hover { transform: translateY(-2px); border-color: rgba(168, 85, 247, .45); }
.rva-member[aria-pressed="true"] { border-color: #a855f7; box-shadow: 0 0 0 3px rgba(168, 85, 247, .25), 0 14px 30px -14px rgba(168, 85, 247, .9); }
.rva-member[aria-pressed="true"]::after {
  content: ''; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat, var(--rva-grad);
  box-shadow: 0 0 0 2px var(--rva-bg);
}
.rva-member__photo { display: block; width: 100%; max-width: 104px; aspect-ratio: 1; margin-bottom: 8px; overflow: hidden; border-radius: 14px; background: var(--rva-surface-2); }
.rva-member__photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rva-member__name { font-family: var(--rva-font-display); font-size: 14.5px; font-weight: 700; color: #fff; }
.rva-member__role { font-size: 12.5px; color: var(--rva-muted); line-height: 1.3; }

.rva-talk {
  position: sticky; bottom: 0; z-index: 1;
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; margin-bottom: 4px;
  padding: 6px 18px 6px 6px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #8b3cf7, #7e22ce); color: #fff;
  font-family: var(--rva-font-display); font-size: 16px; font-weight: 600;
  box-shadow: 0 12px 28px -10px rgba(168, 85, 247, .9);
  transition: filter .15s ease, transform .15s ease;
}
.rva-talk:hover { filter: brightness(1.1); transform: translateY(-1px); }
.rva-talk__logo { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #7e22ce; font-weight: 800; font-size: 17px; }
.rva-panel[data-view="intro"] .rva-stage,
.rva-panel[data-view="intro"] .rva-foot { display: none; }

.rva-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: 14px; transition: filter .15s ease, background .15s ease; }
.rva-btn--primary { background: var(--rva-grad); color: #fff; box-shadow: 0 8px 22px -8px rgba(168, 85, 247, .7); }
.rva-btn--primary:hover { filter: brightness(1.1); }
.rva-btn--ghost { background: var(--rva-surface-2); border-color: var(--rva-border); color: #e5e5ef; }
.rva-btn--ghost:hover { background: #26263a; }
.rva-btn--sm { min-height: 34px; padding: 0 14px; font-size: 13px; }


/* Conversation ------------------------------------------------------------ */
.rva-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rva-msg { max-width: 88%; animation: rva-rise .2s ease-out; }
.rva-msg__bubble { padding: 10px 14px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.rva-msg--user { align-self: flex-end; }
.rva-msg--user .rva-msg__bubble { background: var(--rva-grad); color: #fff; border-bottom-right-radius: 5px; }
.rva-msg--bot { align-self: flex-start; }
.rva-msg--bot .rva-msg__bubble { background: var(--rva-surface-2); border: 1px solid var(--rva-border); color: #ececf3; border-bottom-left-radius: 5px; }
.rva-msg--error .rva-msg__bubble { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); color: #fecaca; }
.rva-msg--note .rva-msg__bubble { background: transparent; border: 1px dashed var(--rva-border); color: var(--rva-muted); font-size: 12.5px; }
.rva-msg__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; padding-left: 4px; }
.rva-msg__action { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border: 0; border-radius: 8px; background: transparent; font-size: 12px; color: var(--rva-muted); }
.rva-msg__action:hover { background: var(--rva-surface-2); color: #fff; }
.rva-msg__source { font-size: 12px; color: #c4b5fd; text-decoration: none; }
.rva-msg__source:hover { text-decoration: underline; }
.rva-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.rva-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--rva-muted); animation: rva-dot 1.2s infinite ease-in-out; }
.rva-typing i:nth-child(2) { animation-delay: .15s; }
.rva-typing i:nth-child(3) { animation-delay: .3s; }

/* Stage: waveform + live transcript --------------------------------------- */
.rva-stage { padding: 0 16px; }
.rva-wave { display: none; align-items: center; justify-content: center; gap: 4px; height: 44px; }
.rva-wave span { width: 4px; height: 8px; border-radius: 4px; background: var(--rva-grad); opacity: .85; }
.rva-panel[data-state="listening"] .rva-wave,
.rva-panel[data-state="speaking"] .rva-wave { display: flex; }
.rva-panel[data-state="listening"] .rva-wave span { animation: rva-wave 1s ease-in-out infinite; animation-delay: calc(var(--i) * -0.09s); }
.rva-panel[data-state="speaking"] .rva-wave span { animation: rva-wave .7s ease-in-out infinite; animation-delay: calc(var(--i) * -0.05s); background: linear-gradient(180deg, #60a5fa, #a855f7); }
.rva-transcript { margin: 0; min-height: 0; font-size: 14px; text-align: center; color: #e9d5ff; font-style: italic; }
.rva-transcript:empty { display: none; }
.rva-confirm { margin: 8px 0; padding: 12px; border-radius: 14px; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .3); font-size: 13px; color: #fde68a; }
.rva-confirm p { margin: 0 0 8px; }
.rva-confirm div { display: flex; gap: 8px; }

/* Footer: mic ------------------------------------------------ */
.rva-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px 14px; border-top: 1px solid var(--rva-border); background: rgba(11, 11, 20, .6); }
.rva-mic { position: relative; flex: none; display: grid; place-items: center; width: 50px; height: 50px; border: 0; border-radius: 50%; background: var(--rva-grad); color: #fff; box-shadow: 0 10px 26px -8px rgba(168, 85, 247, .8); transition: transform .15s ease; }
.rva-mic:hover { transform: scale(1.05); }
.rva-mic:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.rva-mic__ring { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid rgba(168, 85, 247, .6); opacity: 0; }
.rva-mic__stop { display: none; }
.rva-panel[data-state="listening"] .rva-mic { background: #ef4444; box-shadow: 0 10px 26px -8px rgba(239, 68, 68, .8); }
.rva-panel[data-state="listening"] .rva-mic__ring { border-color: rgba(239, 68, 68, .6); animation: rva-pulse 1.4s ease-out infinite; }
.rva-panel[data-state="listening"] .rva-mic__ico { display: none; }
.rva-panel[data-state="listening"] .rva-mic__stop { display: block; }
/* Hands-free voice chat: the mic shows a stop square for the whole conversation, not just while listening. */
.rva-panel[data-conversation="on"] .rva-mic { background: #ef4444; box-shadow: 0 10px 26px -8px rgba(239, 68, 68, .8); }
.rva-panel[data-conversation="on"] .rva-mic__ico { display: none; }
.rva-panel[data-conversation="on"] .rva-mic__stop { display: block; }

.rva-stop { width: 100%; min-height: 36px; border: 1px solid rgba(248, 113, 113, .4); border-radius: 12px; background: rgba(248, 113, 113, .08); color: #fecaca; font-size: 13px; font-weight: 600; }
.rva-stop:hover { background: rgba(248, 113, 113, .16); }
.rva-panel[data-voice="unsupported"] .rva-mic { display: none; }
/* Voice only: the mic sits alone in the footer. */
.rva-foot { justify-content: center; }
.rva-mic { width: 64px; height: 64px; }

/* Voice call: team stays on screen, timer in the header, mic mute + End Call --- */
.rva-timer, .rva-call, .rva-call-note { display: none; }
.rva-panel[data-view="call"] .rva-timer {
  display: inline-block; flex: none; padding: 3px 10px; border-radius: 999px;
  background: rgba(168, 85, 247, .16); border: 1px solid rgba(168, 85, 247, .35);
  font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: #e9d5ff;
}
.rva-panel[data-view="call"] .rva-intro__title,
.rva-panel[data-view="call"] .rva-intro__text,
.rva-panel[data-view="call"] .rva-talk,
.rva-panel[data-view="call"] .rva-notice,
.rva-panel[data-view="call"] .rva-foot,
.rva-panel[data-view="call"] [data-rva="team"] { display: none; }
.rva-panel[data-view="call"] .rva-team { margin-bottom: 0; }
.rva-panel[data-view="call"] .rva-member:not([aria-pressed="true"]) { opacity: .6; }
.rva-panel[data-view="call"] .rva-member:not([aria-pressed="true"]):hover { opacity: 1; }
.rva-panel[data-view="call"] .rva-member[aria-pressed="true"]::after { display: none; }
.rva-panel[data-view="call"][data-state="speaking"] .rva-member[aria-pressed="true"] { animation: rva-glow 1.1s ease-in-out infinite; }
.rva-panel[data-view="call"] .rva-call-note:not(:empty) { display: block; margin: 0 0 6px; font-size: 13px; text-align: center; color: #fecaca; }
.rva-panel[data-view="call"] .rva-call { display: flex; align-items: center; gap: 12px; padding: 12px 14px 14px; border-top: 1px solid var(--rva-border); background: rgba(11, 11, 20, .6); }
.rva-call__mic {
  position: relative; flex: none; display: grid; place-items: center; width: 56px; height: 56px;
  border: 0; border-radius: 50%; background: #fff; color: #1c1c2b;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .6); transition: transform .15s ease;
}
.rva-call__mic:hover { transform: scale(1.05); }
.rva-call__mic::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid rgba(168, 85, 247, .7); opacity: 0; }
.rva-panel[data-state="listening"] .rva-call__mic::after { animation: rva-pulse 1.4s ease-out infinite; }
.rva-call__mic-off, .rva-call__mic[aria-pressed="true"] .rva-call__mic-on { display: none; }
.rva-call__mic[aria-pressed="true"] { background: var(--rva-surface-2); color: var(--rva-danger); }
.rva-call__mic[aria-pressed="true"] .rva-call__mic-off { display: block; }
.rva-call__end {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px;
  border: 0; border-radius: 999px; background: #ef4444; color: #fff;
  font-family: var(--rva-font-display); font-size: 16px; font-weight: 600;
  box-shadow: 0 12px 28px -10px rgba(239, 68, 68, .9); transition: filter .15s ease;
}
.rva-call__end:hover { filter: brightness(1.08); }

/* Animations -------------------------------------------------------------- */
@keyframes rva-open { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rva-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rva-pulse { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes rva-breathe { 0%, 100% { transform: scale(.75); } 50% { transform: scale(1.1); } }
@keyframes rva-spin { to { transform: rotate(360deg); } }
@keyframes rva-dot { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes rva-glow { 0%, 100% { box-shadow: 0 0 0 3px rgba(168, 85, 247, .25), 0 14px 30px -14px rgba(168, 85, 247, .9); } 50% { box-shadow: 0 0 0 7px rgba(168, 85, 247, .35), 0 14px 34px -10px rgba(168, 85, 247, 1); } }
@keyframes rva-wave { 0%, 100% { height: 6px; } 50% { height: 34px; } }

/* Mobile: full-screen sheet ------------------------------------------------ */
@media (max-width: 560px) {
  .rva-launcher__label { display: none; }
  .rva-launcher { padding: 6px; bottom: 168px; }
  .rva-panel {
    position: fixed; inset: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .rva-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .rva-lang__btn { padding: 4px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .rva *, .rva *::before, .rva *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .rva-panel[data-state="listening"] .rva-wave span, .rva-panel[data-state="speaking"] .rva-wave span { height: 18px; }
}
