/*
  theultimaterevenueshare.com — chat widget stylesheet.

  Loaded after styles.css and reuses its custom properties and a handful of
  its classes directly (.chip, .btn, .btn-primary, .btn-ghost, .headline-pill,
  .spinner) rather than redefining them. No new color literals — every color
  here is one of styles.css's existing custom properties.
*/

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- FAB ---------- */

.rvz-chat-fab {
  position: fixed;
  right: 20px;
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--gradient-brand-from), var(--gradient-brand-via), var(--gradient-brand-to));
  box-shadow:
    0 8px 24px -6px var(--landing-glow-1),
    0 4px 14px -2px var(--landing-glow-2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.rvz-chat-fab .icon {
  width: 26px;
  height: 26px;
}

@media (min-width: 1024px) {
  .rvz-chat-fab {
    right: 32px;
    bottom: 32px;
    width: 64px;
    height: 64px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .rvz-chat-fab {
    animation: rvzFabGlow 2.6s ease-in-out infinite;
  }

  .rvz-chat-fab::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    z-index: -1;
    background: linear-gradient(135deg, var(--gradient-brand-from), var(--gradient-brand-to));
    animation: rvzFabPulse 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  }

  @keyframes rvzFabGlow {
    0%, 100% {
      box-shadow: 0 8px 24px -6px var(--landing-glow-1), 0 4px 14px -2px var(--landing-glow-2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    }
    50% {
      box-shadow: 0 10px 34px -4px var(--landing-glow-1), 0 6px 22px -2px var(--landing-glow-2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.25);
    }
  }

  @keyframes rvzFabPulse {
    0%   { transform: scale(1);    opacity: 0.55; }
    100% { transform: scale(1.35); opacity: 0; }
  }
}

@media (hover: hover) {
  .rvz-chat-fab:hover {
    transform: translateY(-2px) scale(1.05);
    animation-play-state: paused;
  }
  .rvz-chat-fab:hover::after {
    animation-play-state: paused;
    opacity: 0;
  }
}

.rvz-chat-fab:active {
  transform: scale(0.94);
}

.rvz-chat-fab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

/* ---------- First-visit label ---------- */

.rvz-chat-fab-label {
  position: fixed;
  right: 88px;
  bottom: 26px;
  max-width: 220px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  background: var(--color-card-bg);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-light);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  z-index: 39;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .rvz-chat-fab-label {
    right: 96px;
    bottom: 44px;
  }
}

.rvz-chat-fab-label-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.rvz-chat-fab-label-close .icon {
  width: 12px;
  height: 12px;
}

/* Combined class+attribute selector beats the plain-class display:flex rule
   above on specificity, so this wins regardless of source order — same
   pattern as .rvz-chat-messages[hidden] below. */
.rvz-chat-fab-label[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .rvz-chat-fab-label {
    animation: rvzLabelIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) 1.2s both,
               rvzLabelOut 0.3s cubic-bezier(0.4, 0, 1, 1) 4.6s forwards;
  }
  @keyframes rvzLabelIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
  }
  @keyframes rvzLabelOut {
    from { opacity: 1; max-width: 220px; margin-right: 0; }
    to   { opacity: 0; max-width: 0; padding-left: 0; padding-right: 0; margin-right: -12px; }
  }
}

/* ---------- Panel — mobile (full-screen sheet) ---------- */

.rvz-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.rvz-chat-panel.is-open {
  transform: translateY(0);
}

.rvz-chat-panel[hidden] {
  display: none;
}

/* ---------- Panel — desktop (anchored card) ---------- */

@media (min-width: 1024px) {
  .rvz-chat-panel {
    inset: auto;
    right: 32px;
    bottom: 104px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 160px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    background: var(--color-card-bg);
    box-shadow: var(--shadow-lg), 0 0 0 8px var(--glass-bg);
    transform: translateY(16px) scale(0.96);
    transform-origin: bottom right;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    opacity: 0;
  }

  .rvz-chat-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  /* Below 1024px the panel is display:none while closed (via [hidden]) so it
     never traps focus behind the FAB; above 1024px it must stay laid out
     (off-screen via opacity/transform only) so the open transition can play. */
  .rvz-chat-panel[hidden] {
    display: flex;
  }
}

/* ---------- Header ---------- */

.rvz-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-card-bg);
}

.rvz-chat-back,
.rvz-chat-close,
.rvz-chat-fab-label-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rvz-chat-back,
.rvz-chat-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.rvz-chat-back .icon {
  width: 20px;
  height: 20px;
  transform: scaleX(-1);
}

.rvz-chat-close .icon {
  width: 18px;
  height: 18px;
}

.rvz-chat-back:hover,
.rvz-chat-close:hover {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.rvz-chat-back:focus-visible,
.rvz-chat-close:focus-visible,
.rvz-chat-fab-label-close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.rvz-chat-back[hidden] {
  display: none;
}

/* apple-icon.png is a square 180x180 asset (the gradient R already centered
   on a light background), so a circular frame crops only its blank corners
   — never the glyph — with no stretch. A plain purple disc would put a
   purple/indigo gradient mark on a purple/indigo gradient fill, which is
   why this is a light bordered circle instead. */
.rvz-chat-avatar,
.rvz-chat-avatar-sm {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border-light);
}

.rvz-chat-avatar {
  width: 32px;
  height: 32px;
}

.rvz-chat-avatar-sm {
  width: 24px;
  height: 24px;
}

.rvz-chat-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rvz-chat-header-text {
  flex: 1;
  min-width: 0;
}

.rvz-chat-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  color: var(--color-text-primary);
}

.rvz-chat-subtitle {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 2px 0 0;
}

/* ---------- Body / transcript ---------- */

.rvz-chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rvz-chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.rvz-chat-messages[hidden],
.rvz-chat-contact-form[hidden] {
  display: none;
}

.rvz-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.rvz-chat-msg--visitor {
  justify-content: flex-end;
}

.rvz-chat-bubble {
  max-width: 84%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  /* overflow-wrap is the standards-track property and does the real work —
     word-break:break-word is a widely-supported but non-standard fallback,
     kept alongside it. Both matter for a long unbroken token (a pasted URL)
     with no natural break point, which would otherwise push past the
     bubble's max-width and out of the panel. */
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rvz-chat-msg--assistant .rvz-chat-bubble {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
  color: var(--color-text-primary);
}

.rvz-chat-msg--visitor .rvz-chat-bubble {
  background: linear-gradient(135deg, var(--gradient-brand-from), var(--gradient-brand-via), var(--gradient-brand-to));
  color: #FFFFFF;
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}

/* ---------- Typing indicator ---------- */

.rvz-chat-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.rvz-chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gradient-brand-from);
}

@media (prefers-reduced-motion: no-preference) {
  .rvz-chat-typing-dots span {
    animation: rvzTypingBounce 1.2s ease-in-out infinite;
  }
  .rvz-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
  .rvz-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

  @keyframes rvzTypingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
  }
}

/* ---------- Starter chips ---------- */

.rvz-chat-starters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px 32px;
}

.rvz-chat-starter {
  display: block;
  width: auto;
  text-align: left;
  white-space: normal;
  line-height: 1.4;
}

/* ---------- CTA link row ---------- */

.rvz-chat-cta-row {
  margin: 0 0 16px 32px;
}

.rvz-chat-cta-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 8px;
}

.rvz-chat-cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rvz-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.rvz-cta-btn .icon {
  width: 14px;
  height: 14px;
}

.rvz-cta-btn--ghost {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text-primary);
}

.rvz-cta-btn--ghost:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.rvz-cta-btn--primary {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 12px 28px -10px rgba(52, 84, 207, 0.55);
}

.rvz-cta-btn--primary:hover {
  background: var(--color-primary-hover);
}

.rvz-cta-btn--block {
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 13px 16px;
}

.rvz-cta-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- System pills (rate-limit notice, success) ---------- */

.rvz-chat-system-pill {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 16px;
  border-radius: 999px;
  margin: 4px 0 16px;
}

.rvz-chat-system-pill--notice {
  background: var(--color-gold-wash);
  color: var(--color-warning-text);
}

.rvz-chat-system-pill--error {
  border: 1px solid var(--color-error);
  color: var(--color-error);
  background: var(--color-background);
}

.rvz-chat-retry {
  display: block;
  margin: -8px auto 16px;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Rate-limited replacement block ---------- */

.rvz-chat-ratelimited {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rvz-chat-ratelimited-copy {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 4px;
}

.rvz-chat-text-link {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 13px;
  text-decoration: underline;
  color: var(--color-text-secondary);
  cursor: pointer;
  align-self: center;
}

.rvz-chat-text-link:hover {
  color: var(--color-primary);
}

/* ---------- Footer / input row ---------- */

.rvz-chat-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--color-border-light);
  padding: 12px 16px;
  background: var(--color-card-bg);
}

.rvz-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Higher specificity than the plain-class rule above, so it wins over it
   regardless of source order when the widget toggles [hidden] via JS. */
.rvz-chat-input-row[hidden],
.rvz-chat-footer-link[hidden],
.rvz-chat-ratelimited[hidden] {
  display: none;
}

.rvz-chat-input {
  flex: 1;
  resize: none;
  /* 2 lines at this font-size/line-height (2 * 14px * 1.5 = 42px) + padding
     (20px) + border (2px) = 64px. rows="2" on the element gives the same
     floor natively, but min-height is the actual guarantee: autosizeInput()
     sets an inline height on every keystroke, and only min-height (not the
     rows attribute) still clamps that inline value on a short first line —
     without it, a placeholder or a typed line that wraps to 2 lines gets cut
     by the field's own bottom edge before any input event has fired to
     resize it. */
  min-height: 64px;
  max-height: 96px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-text-primary);
}

.rvz-chat-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-accent);
}

.rvz-chat-input:disabled {
  opacity: 0.6;
}

.rvz-chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

.rvz-chat-send .icon {
  width: 18px;
  height: 18px;
}

.rvz-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rvz-chat-send:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.rvz-chat-footer-link {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  margin-top: 10px;
  padding: 2px 0;
  font-size: 12px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.rvz-chat-footer-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ---------- Staff-message form ---------- */

.rvz-chat-contact-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.rvz-chat-contact-intro {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 20px;
}

.rvz-chat-field {
  margin-bottom: 18px;
}

.rvz-chat-field label {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--color-text-primary);
}

.rvz-chat-field textarea,
.rvz-chat-field input[type='email'] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-text-primary);
  resize: vertical;
}

.rvz-chat-field textarea:focus-visible,
.rvz-chat-field input[type='email']:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-accent);
}

.rvz-chat-field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.rvz-chat-counter {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.rvz-chat-field-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 6px 0 0;
}

.rvz-chat-field-error {
  font-size: 12px;
  color: var(--color-error);
  margin-top: 6px;
  display: block;
}

.rvz-chat-field-error[hidden] {
  display: none;
}

.rvz-chat-contact-banner {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-gold-wash);
  color: var(--color-warning-text);
  margin: 0 0 16px;
}

.rvz-chat-contact-banner[hidden] {
  display: none;
}

.rvz-chat-contact-submit-row .btn {
  width: 100%;
}
