/* PlayPriime — Chat widget */

.chat-widget {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 4000;
  font-family: var(--font-body);
}

.chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-pink), #c800c8);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--glow-pink);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-toggle:hover,
.chat-toggle:focus-visible {
  transform: scale(1.06);
  box-shadow: 0 0 30px rgba(255, 0, 255, 0.8);
}

.chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.25rem;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(520px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), var(--glow-cyan);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
  overflow: hidden;
  /* @mike: without visibility the invisible panel still eats clicks over footer. Fixed 12.07 */
}

.chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* [hidden] would lose to display:flex otherwise — keep closed panels out of hit-testing */
.chat-panel[hidden]:not(.is-open) {
  display: none !important;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header h2 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin: 0;
  color: var(--neon-cyan);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 200px;
  max-height: 320px;
}

.chat-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-msg p {
  margin: 0;
}

.chat-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 255, 255, 0.2);
  color: var(--text-primary);
}

.chat-msg-user {
  align-self: flex-end;
  background: rgba(255, 0, 255, 0.18);
  border: 1px solid rgba(255, 0, 255, 0.35);
  color: var(--text-primary);
}

.chat-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.chat-link {
  display: block;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 255, 255, 0.08);
  border-radius: 8px;
  color: var(--neon-cyan);
  font-size: 0.8rem;
}

.chat-link:hover,
.chat-link:focus-visible {
  background: rgba(255, 0, 255, 0.12);
  color: var(--neon-pink);
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 0 1rem 0.5rem;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-cyan);
  animation: chat-typing 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .chat-widget {
    bottom: 5rem;
    right: 1rem;
  }

  .cookie-banner:not(.is-hidden) ~ .chat-widget,
  body:has(.cookie-banner:not(.is-hidden)) .chat-widget {
    bottom: 6.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .chat-toggle {
    transition: none;
  }
}
