/* Floating Chat Widget Styles */
:root { --chat-primary: #06b6d4; --chat-secondary: #8b5cf6; --chat-bg: #0b1224; --chat-text: #e2e8f0; --chat-muted: #94a3b8; }

.chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  cursor: pointer;
  z-index: 2147483000;
  transition: transform .2s ease, box-shadow .25s ease, filter .25s ease;
  /* enable pseudo-element layering */
  isolation: isolate;
}

/* Always-on heartbeat outline using pseudo elements */
.chat-launcher::before,
.chat-launcher::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  transform: scale(1);
  opacity: .55;
}

/* Teal outer ring */
.chat-launcher::before {
  border: 2px solid rgba(6,182,212,.55);
  box-shadow: 0 0 10px rgba(6,182,212,.35);
  animation: heartbeat 1.8s ease-in-out infinite;
}

/* Purple secondary ring with slight delay */
.chat-launcher::after {
  border: 2px solid rgba(139,92,246,.45);
  box-shadow: 0 0 14px rgba(139,92,246,.35);
  animation: heartbeat 1.8s ease-in-out .12s infinite;
}

@keyframes heartbeat {
  0%   { transform: scale(1);    opacity: .55; }
  15%  { transform: scale(1.08); opacity: .9;  }
  30%  { transform: scale(1);    opacity: .5;  }
  45%  { transform: scale(1.12); opacity: .85; }
  70%  { transform: scale(1);    opacity: .45; }
  100% { transform: scale(1);    opacity: .55; }
}

/* Hover glow intensifies without adding a second animation */
.chat-launcher:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow:
    0 14px 36px rgba(0,0,0,.4),
    0 0 14px rgba(6,182,212,.45),
    0 0 26px rgba(139,92,246,.35);
}

.chat-launcher:active { transform: translateY(0) scale(0.98); }
.chat-launcher:focus-visible { outline: 3px solid rgba(6,182,212,.5); outline-offset: 3px; }

@keyframes pulse-glow {
  0%, 100% {
    box-shadow:
      0 14px 36px rgba(0,0,0,.4),
      0 0 10px rgba(6,182,212,.35),
      0 0 18px rgba(139,92,246,.25);
  }
  50% {
    box-shadow:
      0 16px 40px rgba(0,0,0,.45),
      0 0 18px rgba(6,182,212,.55),
      0 0 30px rgba(139,92,246,.4);
  }
}

.chat-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 360px;
  max-height: 65vh;
  background: var(--chat-bg);
  color: var(--chat-text);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
  /* enable pseudo-element layering */
  isolation: isolate;
}

/* Dark theme: animated drop-shadow heartbeat so glow is not clipped by overflow */
[data-theme="dark"] .chat-panel {
  will-change: filter;
  animation: panel-heartbeat 2.1s ease-in-out infinite;
}

@keyframes panel-heartbeat {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(6,182,212,.25)) drop-shadow(0 0 14px rgba(139,92,246,.18));
  }
  15% {
    filter: drop-shadow(0 0 16px rgba(6,182,212,.45)) drop-shadow(0 0 24px rgba(139,92,246,.32));
  }
  45% {
    filter: drop-shadow(0 0 20px rgba(6,182,212,.55)) drop-shadow(0 0 30px rgba(139,92,246,.40));
  }
  70% {
    filter: drop-shadow(0 0 10px rgba(6,182,212,.30)) drop-shadow(0 0 18px rgba(139,92,246,.24));
  }
}

/* Light theme: softer heartbeat glow suited for light backgrounds */
[data-theme="light"] .chat-panel {
  will-change: filter;
  animation: panel-heartbeat-light 2.1s ease-in-out infinite;
}

@keyframes panel-heartbeat-light {
  0%, 100% {
    filter: drop-shadow(0 0 6px rgba(6,182,212,.22)) drop-shadow(0 0 10px rgba(139,92,246,.16));
  }
  15% {
    filter: drop-shadow(0 0 12px rgba(6,182,212,.34)) drop-shadow(0 0 18px rgba(139,92,246,.26));
  }
  45% {
    filter: drop-shadow(0 0 16px rgba(6,182,212,.40)) drop-shadow(0 0 24px rgba(139,92,246,.32));
  }
  70% {
    filter: drop-shadow(0 0 8px rgba(6,182,212,.24)) drop-shadow(0 0 12px rgba(139,92,246,.18));
  }
}

/* Dark theme: heartbeat glow outline around the panel */
[data-theme="dark"] .chat-panel::before,
[data-theme="dark"] .chat-panel::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 16px;
  pointer-events: none;
  z-index: -1;
  opacity: .5;
  transform: scale(1);
}

[data-theme="dark"] .chat-panel::before {
  border: 2px solid rgba(6,182,212,.45);
  box-shadow: 0 0 14px rgba(6,182,212,.35);
  animation: heartbeat 2.1s ease-in-out infinite;
}

[data-theme="dark"] .chat-panel::after {
  border: 2px solid rgba(139,92,246,.4);
  box-shadow: 0 0 18px rgba(139,92,246,.35);
  animation: heartbeat 2.1s ease-in-out .12s infinite;
}

.chat-header {
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.chat-title { font-weight: 700; font-size: 14px; }
.chat-subtitle { font-size: 12px; color: var(--chat-muted); }

.chat-close {
  background: transparent;
  color: var(--chat-text);
  border: none;
  font-size: 18px;
  cursor: pointer;
}

.chat-messages {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message { font-size: 14px; line-height: 1.5; max-width: 85%; padding: 10px 12px; border-radius: 12px; }
.message.user { align-self: flex-end; background: rgba(6,182,212,0.18); border: 1px solid rgba(6,182,212,0.35); }
.message.assistant { align-self: flex-start; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); }

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}

.chat-input textarea {
  flex: 1;
  resize: none;
  height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--chat-text);
}

.chat-send {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
  color: white;
  font-weight: 600;
}

@media (max-width: 480px) {
  .chat-panel { right: 10px; left: 10px; width: auto; }
}
