/* ==========================================================================
   Floating chat assistant
   ========================================================================== */
.rvx-chat {
  --chat-ink: #0A1B4E; --chat-soft: #3A4670; --chat-muted: #5A6280; --chat-rule: #E3E5EC;
  --chat-green: #0E6B25; --chat-gold: #E3A21A; --chat-navy-deep: #071338; --chat-c: 12px;
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; font-family: var(--rvx-sans); color: var(--chat-ink);
}
body.rvx-menu-open .rvx-chat { display: none; }
.rvx-chat * { box-sizing: border-box; }

/* Launcher */
.rvx-chat__launcher {
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 18px; border: 0; cursor: pointer;
  background: var(--chat-ink); color: #fff; font: 500 .9375rem/1 var(--rvx-sans);
  box-shadow: 0 14px 30px -10px rgba(10,27,78,.55), 0 0 0 3px rgba(255,255,255,.9);
  clip-path: polygon(var(--chat-c) 0, calc(100% - var(--chat-c)) 0, 100% var(--chat-c), 100% calc(100% - var(--chat-c)), calc(100% - var(--chat-c)) 100%, var(--chat-c) 100%, 0 calc(100% - var(--chat-c)), 0 var(--chat-c));
  transition: background-color .25s var(--rvx-ease), transform .25s var(--rvx-ease);
  position: relative;
}
.rvx-chat__launcher:hover, .rvx-chat__launcher:focus { background: var(--chat-green); color: #fff; }
.rvx-chat__launcher:focus-visible { outline: 3px solid var(--chat-gold); outline-offset: 3px; }
.rvx-chat__launcher:active { transform: scale(.97); }
.rvx-chat__launcher::after { /* brand stripe along the bottom */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, #0A1B4E 0 33.33%, #1F8A33 33.33% 66.66%, #E3A21A 66.66%); opacity: .0;
}
.rvx-chat__launcher svg { width: 24px; height: 24px; flex: 0 0 auto; }
.rvx-chat__ic-close { display: none; }
.rvx-chat[data-state="open"] .rvx-chat__ic-open { display: none; }
.rvx-chat[data-state="open"] .rvx-chat__ic-close { display: block; }
.rvx-chat[data-state="open"] .rvx-chat__label { display: none; }
.rvx-chat[data-state="open"] .rvx-chat__launcher { width: 56px; padding: 0; justify-content: center; background: var(--chat-gold); color: var(--chat-navy-deep); }
.rvx-chat__launcher:not(:hover) .rvx-chat__ic-open { animation: rvx-chat-nudge 6s var(--rvx-ease) 3s 2; }
@keyframes rvx-chat-nudge { 0%, 88%, 100% { transform: none; } 92% { transform: rotate(-9deg) scale(1.08); } 96% { transform: rotate(7deg) scale(1.08); } }

/* Teaser bubble */
.rvx-chat__teaser {
  margin: 0; max-width: 240px; padding: 12px 16px; background: #fff; color: var(--chat-ink); font-size: .9063rem; line-height: 1.4; cursor: pointer;
  box-shadow: 0 16px 36px -14px rgba(10,27,78,.45); border-top: 3px solid var(--chat-gold);
  animation: rvx-chat-in .35s var(--rvx-ease);
}
.rvx-chat__teaser[hidden] { display: none; }

/* Panel */
.rvx-chat__panel {
  width: min(392px, calc(100vw - 32px)); max-height: min(640px, calc(100dvh - 120px)); display: flex; flex-direction: column;
  background: #fff; box-shadow: 0 30px 70px -20px rgba(10,27,78,.55), 0 0 0 1px rgba(10,27,78,.06);
  transform-origin: bottom right; opacity: 0; transform: translateY(12px) scale(.97); transition: opacity .22s var(--rvx-ease), transform .22s var(--rvx-ease);
  --chat-pc: 22px;
  clip-path: polygon(0 0, calc(100% - var(--chat-pc)) 0, 100% var(--chat-pc), 100% 100%, var(--chat-pc) 100%, 0 calc(100% - var(--chat-pc)));
}
.rvx-chat[data-state="open"] .rvx-chat__panel { opacity: 1; transform: none; }
.rvx-chat__panel[hidden] { display: none; }

.rvx-chat__head {
  display: grid; grid-template-columns: 44px 1fr 36px; gap: 12px; align-items: center; padding: 18px 16px 16px 18px; position: relative;
  background: linear-gradient(150deg, #13286B, #0A1B4E 70%); color: #fff;
}
.rvx-chat__head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, #0A1B4E 0 33.33%, #1F8A33 33.33% 66.66%, #E3A21A 66.66%); }
.rvx-chat__avatar { width: 44px; height: 44px; display: grid; place-items: center; background: #fff; color: var(--chat-ink); font: 400 1.35rem/1 var(--rvx-display);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px); }
.rvx-chat__head h2 { margin: 0; color: #fff; font: 500 1rem/1.25 var(--rvx-sans); letter-spacing: 0; }
.rvx-chat__head p { margin: 3px 0 0; color: rgba(255,255,255,.76); font-size: .75rem; line-height: 1.35; }
.rvx-chat__close { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; cursor: pointer; padding: 0; border-radius: 0; }
.rvx-chat__close:hover, .rvx-chat__close:focus { background: rgba(255,255,255,.14); color: #fff; }
.rvx-chat__close svg { width: 14px; height: 14px; }

.rvx-chat__log { flex: 1 1 auto; min-height: 150px; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; background: #F6F6F1; overscroll-behavior: contain; scroll-behavior: smooth; }
.rvx-chat__msg { max-width: 88%; font-size: .9375rem; line-height: 1.5; animation: rvx-chat-in .3s var(--rvx-ease); }
.rvx-chat__msg p { margin: 0; }
.rvx-chat__msg--bot { align-self: flex-start; background: #fff; color: var(--chat-ink); padding: 12px 14px; box-shadow: 0 6px 18px -14px rgba(10,27,78,.5); border-top: 2px solid var(--chat-green); }
.rvx-chat__msg--user { align-self: flex-end; background: var(--chat-ink); color: #fff; padding: 10px 14px; }
.rvx-chat__msg--form { max-width: 100%; width: 100%; }
@keyframes rvx-chat-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.rvx-chat__typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.rvx-chat__typing span { width: 6px; height: 6px; background: var(--chat-muted); border-radius: 50%; animation: rvx-chat-dot 1s infinite ease-in-out; }
.rvx-chat__typing span:nth-child(2) { animation-delay: .15s; } .rvx-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes rvx-chat-dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.rvx-chat__links { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.rvx-chat__links a { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 10px; background: #EDF0F8; color: var(--chat-ink); font-size: .875rem; font-weight: 500; text-decoration: none; line-height: 1.3; transition: background .2s; }
.rvx-chat__links a::after { content: "→"; color: var(--chat-green); flex: 0 0 auto; }
.rvx-chat__links a:hover, .rvx-chat__links a:focus-visible { background: var(--chat-gold); color: var(--chat-navy-deep); }
.rvx-chat__links a:hover::after, .rvx-chat__links a:focus-visible::after { color: var(--chat-navy-deep); }

.rvx-chat__actions { display: grid; gap: 8px; margin-top: 12px; }
.rvx-chat__act { display: block; width: 100%; text-align: left; padding: 11px 14px; border: 1.5px solid var(--chat-ink); background: #fff; color: var(--chat-ink); font: 500 .875rem/1.2 var(--rvx-sans); text-decoration: none; cursor: pointer; border-radius: 0; transition: background .2s, color .2s, border-color .2s; }
.rvx-chat__act:hover, .rvx-chat__act:focus-visible { background: var(--chat-ink); color: #fff; }
.rvx-chat__act--wa { background: #1F8A33; border-color: #1F8A33; color: #fff; }
.rvx-chat__act--wa:hover, .rvx-chat__act--wa:focus-visible { background: #0E6B25; border-color: #0E6B25; }
.rvx-chat__act--lead { background: var(--chat-gold); border-color: var(--chat-gold); color: var(--chat-navy-deep); }
.rvx-chat__act--lead:hover, .rvx-chat__act--lead:focus-visible { background: var(--chat-navy-deep); border-color: var(--chat-navy-deep); color: #fff; }

.rvx-chat__chips { flex: 0 0 auto; display: flex; gap: 8px; padding: 10px 16px 12px; overflow-x: auto; background: #F6F6F1; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.rvx-chat__chips:empty { display: none; }
.rvx-chat__chip { flex: 0 0 auto; padding: 8px 12px; border: 1.5px solid #C9CDD9; background: #fff; color: var(--chat-ink); font: 500 .8125rem/1.2 var(--rvx-sans); cursor: pointer; white-space: nowrap; border-radius: 0; transition: border-color .2s, background .2s; }
.rvx-chat__chip:hover, .rvx-chat__chip:focus-visible { border-color: var(--chat-green); background: #EAF4EC; color: var(--chat-ink); }

.rvx-chat__input { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 48px; border-top: 1px solid var(--chat-rule); background: #fff; margin: 0; }
.rvx-chat__input input { border: 0; padding: 15px 16px; font: 400 1rem/1.3 var(--rvx-sans); color: var(--chat-ink); background: transparent; min-width: 0; border-radius: 0; }
.rvx-chat__input input:focus { outline: none; box-shadow: inset 0 -3px 0 var(--chat-gold); }
.rvx-chat__input input::placeholder { color: #7A8199; }
.rvx-chat__input button { border: 0; background: var(--chat-ink); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; border-radius: 0; transition: background .2s; }
.rvx-chat__input button:hover, .rvx-chat__input button:focus-visible { background: var(--chat-green); color: #fff; }
.rvx-chat__input button svg { width: 18px; height: 18px; }
.rvx-chat__note { margin: 0; padding: 8px 16px 12px; font-size: .6875rem; line-height: 1.4; color: var(--chat-muted); background: #fff; }

/* Lead form */
.rvx-chat__lead { background: #fff; padding: 14px; display: grid; gap: 10px; border-top: 2px solid var(--chat-gold); box-shadow: 0 6px 18px -14px rgba(10,27,78,.5); }
.rvx-chat__lead label { display: grid; gap: 4px; font: 500 .75rem/1.2 var(--rvx-sans); letter-spacing: .03em; color: var(--chat-soft); text-transform: uppercase; }
.rvx-chat__lead input[type=text], .rvx-chat__lead input[type=email], .rvx-chat__lead textarea {
  width: 100%; font: 400 .9688rem/1.4 var(--rvx-sans); text-transform: none; letter-spacing: 0; color: var(--chat-ink);
  border: 1px solid #C9CDD9; background: #fff; padding: 9px 10px; border-radius: 0; resize: vertical;
}
.rvx-chat__lead input:focus, .rvx-chat__lead textarea:focus { outline: none; border-color: var(--chat-ink); box-shadow: 0 0 0 2px rgba(227,162,26,.55); }
.rvx-chat__lead .rvx-chat__consent { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .8125rem; line-height: 1.4; color: var(--chat-soft); }
.rvx-chat__consent input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--chat-ink); }
.rvx-chat__consent a { color: var(--chat-green); }
.rvx-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.rvx-chat__send { padding: 12px 14px; border: 0; background: var(--chat-ink); color: #fff; font: 500 .9375rem/1 var(--rvx-sans); cursor: pointer; border-radius: 0; transition: background .2s; }
.rvx-chat__send:hover:not(:disabled), .rvx-chat__send:focus-visible { background: var(--chat-green); color: #fff; }
.rvx-chat__send:disabled { opacity: .65; cursor: progress; }
.rvx-chat__err { margin: 0; padding: 8px 10px; background: #FDF0EF; color: #8E1B10; font-size: .8125rem; line-height: 1.4; }
.rvx-chat__err[hidden] { display: none; }

/* Mobile: bottom sheet */
@media (max-width: 520px) {
  .rvx-chat { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); left: 12px; align-items: flex-end; }
  .rvx-chat__panel { width: 100%; max-height: calc(100dvh - 92px); --chat-pc: 16px; }
  .rvx-chat__log { min-height: 120px; }
  .rvx-chat__launcher { height: 52px; padding: 0 18px 0 14px; }
  .rvx-chat[data-state="open"] .rvx-chat__launcher { width: 52px; height: 52px; }
  .rvx-chat__input input { font-size: 16px; } /* prevent iOS zoom */
}
@media (prefers-reduced-motion: reduce) {
  .rvx-chat *, .rvx-chat *::before, .rvx-chat *::after { animation: none !important; transition: none !important; scroll-behavior: auto; }
  .rvx-chat__panel { transform: none; }
}
@media print { .rvx-chat { display: none; } }
