/* =========================
CHAT TRIGGER
========================= */

.chat-trigger {
position: fixed;
right: 20px;
bottom: 90px;
left: auto;
top: auto;

width: 56px;
height: 56px;

display: flex;
align-items: center;
justify-content: center;

border: none;
border-radius: 50%;

background: #ff4fa3;
color: #fff;

font-size: 22px;

cursor: pointer;

z-index: 99999;

box-shadow:
0 8px 24px rgba(255,79,163,0.35);

transition:
transform 0.2s ease,
box-shadow 0.2s ease;
animation: bounce-in 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) both 0.5s,
           glow-cycle 4s ease-in-out infinite 1.3s,
           attention-wiggle 6s ease-in-out infinite;

user-select: none;
touch-action: none;
}

@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  60% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* Sonar pulse effect */
.chat-trigger::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #ff4fa3;
  border-radius: 50%;
  z-index: -1;
  animation: sonar-ping 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  opacity: 0;
}

@keyframes sonar-ping {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  50%, 100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

@keyframes glow-cycle {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(255, 79, 163, 0.35);
  }
  50% {
    box-shadow: 0 0 40px rgba(255, 79, 163, 0.55);
  }
}

@keyframes attention-wiggle {
  0%, 90%, 100% { transform: rotate(0); }
  92% { transform: rotate(-12deg); }
  94% { transform: rotate(12deg); }
  96% { transform: rotate(-12deg); }
  98% { transform: rotate(12deg); }
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ff3b30; /* High-contrast red for CTA */
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 1;
  pointer-events: none; /* Ensures clicking the badge still clicks the trigger */
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(255, 59, 48, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
  }
}

.chat-trigger:hover {
transform: scale(1.08);
box-shadow:
0 12px 30px rgba(255,79,163,0.45);
}

/* =========================
OVERLAY
========================= */

.chat-overlay {
position: fixed;
inset: 0;

display: none;

background: rgba(0,0,0,0.35);

backdrop-filter: blur(6px);

z-index: 1999;
}

.chat-overlay.active {
display: block;
}

/* =========================
CHAT WINDOW
========================= */

.chat-window {
position: fixed;

top: auto;
bottom: 20px;
left: 50%;

width: min(520px, 95vw);
height: min(760px, 90dvh);

display: flex;
flex-direction: column;

opacity: 0;
visibility: hidden;
pointer-events: none;

transform: translate(-50%, 40px) scale(0.92);

transition:
opacity 0.3s ease-out,
transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
visibility 0.3s;

background: rgba(255,255,255,0.97);

backdrop-filter: blur(24px);

border-radius: 24px;

overflow: hidden;

box-shadow:
0 30px 80px rgba(0,0,0,0.18);

z-index: 2000;
}

.chat-window.active {
opacity: 1;
visibility: visible;

pointer-events: auto;

transform: translate(-50%, 0) scale(1);
}

/* =========================
HEADER
========================= */

.chat-header {
display: flex;
align-items: center;

gap: 10px;

padding: 16px 18px;

border-bottom:
1px solid rgba(0,0,0,0.06);

flex-shrink: 0;
}

.chat-header > div:first-child {
flex: 1;
min-width: 0;
}

.chat-title {
margin: 0;

font-family: var(--font-heading);

font-size: 1.35rem;

line-height: 1.2;
}

.chat-subtitle {
margin: 4px 0 0;

font-size: 0.85rem;

opacity: 0.65;
}

.chat-clear,
.chat-close {
min-width: 44px;
min-height: 44px;

display: flex;
align-items: center;
justify-content: center;

border: none;

cursor: pointer;

border-radius: 12px;

transition: 0.2s ease;
}

.chat-clear {
padding: 0 14px;

background:
rgba(255,79,163,0.08);

color: #333;

font-size: 14px;

font-weight: 600;
}

.chat-close {
background: transparent;

font-size: 28px;

line-height: 1;
}

.chat-clear:hover,
.chat-close:hover {
background:
rgba(255,79,163,0.12);
}

/* =========================
BODY
========================= */

.chat-body {
flex: 1;

display: flex;
flex-direction: column;

gap: 10px;

padding: 22px;

overflow-y: auto;

scroll-behavior: smooth;
}

.chat-message {
line-height: 1.7;
}

.chat-msg {
max-width: 85%;

padding: 12px 14px;

border-radius: 18px;

background:
rgba(255,79,163,0.08);

line-height: 1.6;

word-wrap: break-word;

animation:
fadeIn 0.25s ease;
}

.chat-msg.bot {
align-self: flex-start;
}

.chat-typing {
font-size: 14px;

opacity: 0.6;
}

@keyframes fadeIn {
from {
opacity: 0;
transform:
translateY(10px);
}

to {
opacity: 1;
transform:
translateY(0);
}
}

/* =========================
ACTIONS
========================= */

.chat-actions {
display: flex;
flex-direction: column;

gap: 12px;

padding: 18px;

border-top:
1px solid rgba(0,0,0,0.06);

flex-shrink: 0;
}

.chat-option {
display: block;

width: 100%;

border: none;

cursor: pointer;

padding: 14px 16px;

border-radius: 14px;

text-align: center;

text-decoration: none;

font-weight: 600;

color: #333;

background:
rgba(255,79,163,0.08);

transition: 0.25s ease;
}

.chat-option:hover {
background:
rgba(255,79,163,0.18);

transform:
translateY(-2px);
}

/* =========================
MOBILE
========================= */

@media (max-width: 768px) {

.chat-trigger {
width: 52px;
height: 52px;
right: 12px;
bottom: 150px;
}

.chat-window {
width: 100vw;
height: 100dvh;
bottom: 0;
max-width: 100vw;
max-height: 100dvh;
border-radius: 0;
}

.chat-header {
padding: 14px;
}

.chat-body {
padding: 16px;
}

.chat-actions {
padding: 16px;
}
}

@media (max-width: 480px) {

.chat-trigger {
width: 48px;
height: 48px;
right: 10px;
bottom: 80px;

font-size: 18px;
}

.chat-title {
font-size: 1.15rem;
}

.chat-subtitle {
font-size: 0.75rem;
}

.chat-clear {
padding: 0 10px;
font-size: 12px;
}

.chat-option {
font-size: 14px;
padding: 12px;
}
}
