/* Public site chat widget */
.ct-chat {
  --ct-chat-accent: #f77737;
  --ct-chat-accent-soft: rgba(247, 119, 55, 0.14);
  --ct-chat-accent-dark: #e56528;
  --ct-chat-bg: #ffffff;
  --ct-chat-surface: #f4f6f9;
  --ct-chat-text: #111827;
  --ct-chat-muted: #6b7280;
  --ct-chat-border: rgba(17, 24, 39, 0.08);
  --ct-chat-shadow: 0 22px 60px rgba(15, 23, 42, 0.18);
  --ct-chat-radius: 20px;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

.ct-chat__launcher {
  position: relative;
  width: 3.85rem;
  height: 3.85rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(145deg, #f77737 0%, #ff9a56 55%, #f77737 100%);
  color: #fff;
  box-shadow:
    0 14px 32px rgba(247, 119, 55, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.ct-chat__launcher-pulse {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(247, 119, 55, 0.45);
  animation: ct-chat-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes ct-chat-pulse {
  0% {
    transform: scale(1);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

.ct-chat__launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 18px 38px rgba(247, 119, 55, 0.45);
}

.ct-chat__launcher:focus-visible {
  outline: 2px solid var(--ct-chat-accent);
  outline-offset: 3px;
}

.ct-chat__launcher-icon {
  width: 1.55rem;
  height: 1.55rem;
}

.ct-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.85rem);
  width: min(25rem, calc(100vw - 2rem));
  height: min(34rem, calc(100vh - 5.5rem));
  background: var(--ct-chat-bg);
  border: 1px solid var(--ct-chat-border);
  border-radius: var(--ct-chat-radius);
  box-shadow: var(--ct-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.26s ease, transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.26s;
}

.ct-chat--open .ct-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ct-chat--open .ct-chat__launcher {
  transform: scale(0.94);
}

.ct-chat__header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1rem 0.95rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(247, 119, 55, 0.22), transparent 42%),
    linear-gradient(135deg, #0f1117 0%, #1c2230 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ct-chat__header-text {
  flex: 1;
  min-width: 0;
}

.ct-chat__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.ct-chat__subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.62);
}

.ct-chat__close {
  width: 2.1rem;
  height: 2.1rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}

.ct-chat__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ct-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background:
    radial-gradient(circle at 0% 0%, rgba(247, 119, 55, 0.05), transparent 38%),
    var(--ct-chat-surface);
  scroll-behavior: smooth;
}

.ct-chat__row {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  max-width: 100%;
  animation: ct-chat-fade-in 0.28s ease;
}

@keyframes ct-chat-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ct-chat__row--user {
  justify-content: flex-end;
}

.ct-chat__row--bot {
  justify-content: flex-start;
}

.ct-chat__avatar {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #f77737, #ea580c);
  box-shadow: 0 6px 14px rgba(247, 119, 55, 0.28);
}

.ct-chat__avatar svg {
  width: 1rem;
  height: 1rem;
}

.ct-chat__message {
  max-width: min(88%, 18.5rem);
  border-radius: 16px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
}

.ct-chat__message--bot {
  background: #fff;
  color: var(--ct-chat-text);
  border: 1px solid var(--ct-chat-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.ct-chat__message--user {
  background: linear-gradient(135deg, #f77737 0%, #ff8f4d 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 10px 22px rgba(247, 119, 55, 0.28);
}

.ct-chat__message-content {
  padding: 0.72rem 0.88rem;
}

.ct-chat__message--user .ct-chat__message-content {
  white-space: pre-wrap;
}

.ct-chat__message-content p.ct-chat__para {
  margin: 0;
}

.ct-chat__message-content p.ct-chat__para + p.ct-chat__para,
.ct-chat__message-content p.ct-chat__para + .ct-chat__list,
.ct-chat__message-content .ct-chat__list + p.ct-chat__para {
  margin-top: 0.55rem;
}

.ct-chat__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ct-chat__list li {
  position: relative;
  padding-left: 1rem;
  margin-top: 0.35rem;
}

.ct-chat__list li:first-child {
  margin-top: 0;
}

.ct-chat__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--ct-chat-accent);
}

.ct-chat__message-content strong {
  font-weight: 700;
  color: #0f172a;
}

.ct-chat__message-content a {
  color: var(--ct-chat-accent-dark);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(247, 119, 55, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ct-chat__message-content a:hover {
  color: #c2410c;
  border-bottom-color: #c2410c;
}

.ct-chat__message--user a {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.45);
}

.ct-chat__message--typing .ct-chat__message-content {
  padding: 0.85rem 1rem;
}

.ct-chat__typing {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1rem;
}

.ct-chat__typing span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #9ca3af;
  animation: ct-chat-bounce 1.1s ease-in-out infinite;
}

.ct-chat__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ct-chat__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ct-chat-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.ct-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0 0.9rem 0.75rem;
  background: var(--ct-chat-surface);
}

.ct-chat__quick-btn {
  border: 1px solid var(--ct-chat-border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ct-chat-text);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.ct-chat__quick-btn:hover {
  border-color: rgba(247, 119, 55, 0.45);
  color: var(--ct-chat-accent-dark);
  background: #fff;
  transform: translateY(-1px);
}

.ct-chat__composer {
  display: flex;
  gap: 0.55rem;
  padding: 0.9rem;
  border-top: 1px solid var(--ct-chat-border);
  background: #fff;
}

.ct-chat__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--ct-chat-border);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  resize: none;
  max-height: 5.5rem;
  background: #fafbfc;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ct-chat__input:focus {
  outline: none;
  border-color: rgba(247, 119, 55, 0.5);
  background: #fff;
  box-shadow: 0 0 0 4px var(--ct-chat-accent-soft);
}

.ct-chat__send {
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #f77737, #ea580c);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(247, 119, 55, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ct-chat__send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(247, 119, 55, 0.34);
}

.ct-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ct-chat__send-icon {
  width: 1.1rem;
  height: 1.1rem;
}

@media (max-width: 480px) {
  .ct-chat {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .ct-chat__panel {
    width: calc(100vw - 1.7rem);
    height: min(30rem, calc(100vh - 5rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ct-chat__launcher-pulse,
  .ct-chat__typing span,
  .ct-chat__row {
    animation: none;
  }
}
