@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

#ks-chat-root {
  --ks-chat-primary: #0b6cff;
  --ks-chat-primary-hover: #095edb;
  --ks-chat-primary-soft: rgba(11, 108, 255, 0.12);
  --ks-chat-text: #10213c;
  --ks-chat-muted: #7f8ba0;
  --ks-chat-border: rgba(148, 163, 184, 0.16);
  --ks-chat-border-strong: rgba(148, 163, 184, 0.24);
  --ks-chat-surface: rgba(255, 255, 255, 0.98);
  --ks-chat-surface-soft: #f6f8fc;
  --ks-chat-shadow: 0 28px 70px -34px rgba(15, 23, 42, 0.45), 0 16px 34px -28px rgba(11, 108, 255, 0.35);
  --ks-chat-radius-xl: 30px;
  --ks-chat-radius-lg: 22px;
  --ks-chat-radius-md: 16px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ks-chat-text);
}

#ks-chat-root *,
#ks-chat-root *::before,
#ks-chat-root *::after {
  box-sizing: border-box;
}

#ks-chat-root a {
  color: inherit;
}

#ks-chat-root[data-open="true"] .ks-chat-teaser,
#ks-chat-root[data-open="true"] #ks-chat-fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
}

#ks-chat-root[data-open="false"] #ks-chat-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.985);
}

#ks-chat-root[data-open="true"] #ks-chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ks-chat-teaser,
#ks-chat-fab,
#ks-chat-panel {
  transition: opacity 220ms ease, transform 260ms ease, box-shadow 220ms ease, background-color 180ms ease;
}

.ks-chat-teaser {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(280px, calc(100vw - 32px));
  padding: 13px 15px;
  border-radius: 20px;
  border: 1px solid var(--ks-chat-border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(16px);
}

.ks-chat-teaser-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--ks-chat-primary-soft);
  color: var(--ks-chat-primary);
}

.ks-chat-teaser-copy {
  min-width: 0;
}

.ks-chat-teaser-copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ks-chat-teaser-copy p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ks-chat-muted);
}

#ks-chat-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 12px 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #0b6cff, #105cf4);
  color: #fff;
  box-shadow: 0 22px 44px -24px rgba(11, 108, 255, 0.78);
  cursor: pointer;
}

#ks-chat-fab:hover {
  background: linear-gradient(135deg, #0a64ef, #0f57e8);
  transform: translateY(-1px);
}

#ks-chat-fab:focus-visible,
.ks-chat-icon-button:focus-visible,
.ks-chat-attach-button:focus-visible,
.ks-chat-send-button:focus-visible,
.ks-chat-close-button:focus-visible {
  outline: 3px solid rgba(11, 108, 255, 0.24);
  outline-offset: 3px;
}

.ks-chat-fab-icon {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.ks-chat-fab-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ks-chat-fab-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid rgba(11, 108, 255, 0.92);
  background: #93c5fd;
  box-shadow: 0 0 0 0 rgba(147, 197, 253, 0.6);
  animation: ks-chat-pulse 1.9s infinite;
}

@keyframes ks-chat-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(147, 197, 253, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(147, 197, 253, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(147, 197, 253, 0);
  }
}

#ks-chat-panel {
  width: min(392px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 104px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ks-chat-border);
  border-radius: var(--ks-chat-radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(247, 249, 252, 0.99));
  box-shadow: var(--ks-chat-shadow);
  backdrop-filter: blur(20px);
}

.ks-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.9);
}

.ks-chat-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ks-chat-agent-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: cover;
  background: linear-gradient(135deg, #e7f0ff, #d6e7ff);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 8px;
}

.ks-chat-message-avatar-logo {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 999px;
  background: linear-gradient(135deg, #eef4ff, #dbe8ff);
  border: 1px solid rgba(148, 163, 184, 0.16);
  padding: 4px;
}

.ks-chat-agent-meta {
  min-width: 0;
}

.ks-chat-agent-name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.ks-chat-agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ks-chat-muted);
}

.ks-chat-agent-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10b981;
}

.ks-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ks-chat-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(11, 108, 255, 0.08);
  color: var(--ks-chat-primary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ks-chat-icon-button,
.ks-chat-close-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #7a879c;
  cursor: pointer;
}

.ks-chat-icon-button:hover,
.ks-chat-close-button:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #4f5f79;
}

#ks-chat-messages {
  flex: 1 1 auto;
  padding: 22px 18px 18px;
  overflow-y: auto;
  background: radial-gradient(circle at top, rgba(11, 108, 255, 0.04), transparent 30%), #f7f9fc;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.42) transparent;
}

#ks-chat-messages::-webkit-scrollbar {
  width: 8px;
}

#ks-chat-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.38);
}

.ks-chat-message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.ks-chat-message:last-child {
  margin-bottom: 0;
}

.ks-chat-message.is-user {
  justify-content: flex-end;
}

.ks-chat-message-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f0f3f8;
  color: #90a0b6;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.ks-chat-message.is-user .ks-chat-message-avatar {
  order: 2;
  background: rgba(11, 108, 255, 0.12);
  color: var(--ks-chat-primary);
}

.ks-chat-message-stack {
  max-width: min(84%, 280px);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ks-chat-message.is-user .ks-chat-message-stack {
  align-items: flex-end;
}

.ks-chat-bubble {
  border-radius: 18px;
  padding: 14px 15px;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  box-shadow: 0 10px 22px -18px rgba(15, 23, 42, 0.18);
}

.ks-chat-message.is-agent .ks-chat-bubble {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ks-chat-text);
}

.ks-chat-message.is-user .ks-chat-bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, #0b6cff, #1d5ff5);
  color: #fff;
  box-shadow: 0 16px 34px -24px rgba(11, 108, 255, 0.75);
}

.ks-chat-bubble p {
  margin: 0;
}

.ks-chat-bubble img {
  display: block;
  width: 100%;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.ks-chat-timestamp {
  padding: 0 2px;
  font-size: 10px;
  color: #9aa6ba;
  letter-spacing: -0.01em;
}

#ks-chat-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 2px 36px;
  margin-top: 4px;
}

#ks-chat-typing.hidden {
  display: none;
}

.ks-chat-typing-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.6);
}

.ks-chat-typing-pill span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #94a3b8;
  animation: ks-chat-bounce 1.1s infinite ease-in-out;
}

.ks-chat-typing-pill span:nth-child(2) {
  animation-delay: 0.15s;
}

.ks-chat-typing-pill span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ks-chat-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.ks-chat-typing-label {
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  color: #94a3b8;
}

.ks-chat-composer {
  padding: 16px 16px 14px;
  border-top: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.96);
}

#ks-chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ks-chat-input-shell {
  position: relative;
  flex: 1 1 auto;
}

.ks-chat-attach-button {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: #8a96aa;
  cursor: pointer;
}

.ks-chat-attach-button:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--ks-chat-primary);
}

#ks-chat-input {
  width: 100%;
  min-height: 50px;
  padding: 0 112px 0 48px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--ks-chat-surface-soft);
  color: var(--ks-chat-text);
  font: inherit;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.9);
}

#ks-chat-input::placeholder {
  color: #9aa6ba;
}

#ks-chat-input:focus {
  outline: none;
  border-color: rgba(11, 108, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(11, 108, 255, 0.22), 0 0 0 4px rgba(11, 108, 255, 0.08);
}

.ks-chat-send-button {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 74px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #0b6cff, #165af4);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 12px 24px -18px rgba(11, 108, 255, 0.8);
}

.ks-chat-send-button:hover {
  background: linear-gradient(135deg, #0a64ef, #1353e0);
}

.ks-chat-send-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.ks-chat-legal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 0 4px;
}

.ks-chat-legal-copy {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: #94a3b8;
}

.ks-chat-legal-copy a {
  color: #7a8fb7;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ks-chat-legal-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #b0bccf;
}

.ks-chat-legal-icons svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 767px) {
  #ks-chat-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: stretch;
  }

  .ks-chat-teaser {
    width: min(100%, 320px);
    margin-left: auto;
  }

  #ks-chat-fab {
    align-self: flex-end;
  }

  #ks-chat-panel {
    width: 100%;
    height: min(76vh, 640px);
    margin-left: auto;
  }
}

@media (max-width: 540px) {
  #ks-chat-panel {
    border-radius: 24px;
    height: min(78vh, 620px);
  }

  .ks-chat-header {
    padding: 16px 14px 14px;
  }

  #ks-chat-messages {
    padding: 18px 14px 14px;
  }

  .ks-chat-message-stack {
    max-width: 88%;
  }

  .ks-chat-bubble {
    padding: 13px 14px;
  }

  .ks-chat-composer {
    padding: 14px 12px 12px;
  }

  #ks-chat-input {
    padding-right: 90px;
  }

  .ks-chat-send-button {
    min-width: 62px;
    padding: 0 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ks-chat-teaser,
  #ks-chat-fab,
  #ks-chat-panel,
  .ks-chat-typing-pill span,
  .ks-chat-fab-dot {
    animation: none !important;
    transition: none !important;
  }
}
