:root {
  --ajw-primary: #0f5b9c;
  --ajw-primary-dark: #0b4677;
  --ajw-bg: #ffffff;
  --ajw-bg-muted: #f3f6f9;
  --ajw-text: #1c2b36;
  --ajw-text-muted: #5b6b76;
  --ajw-border: #dfe6ec;
  --ajw-error-bg: #fdecea;
  --ajw-error-text: #8a1f11;
  --ajw-radius: 14px;
  --ajw-z: 1045;
}

#agent-chat-widget-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--ajw-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.ajw-toggle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--ajw-primary);
  color: #fff;
  box-shadow: 0 6px 20px rgba(15, 91, 156, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.ajw-toggle-btn:hover {
  background: var(--ajw-primary-dark);
  transform: translateY(-2px);
}

.ajw-toggle-btn svg {
  width: 26px;
  height: 26px;
}

.ajw-icon-close {
  display: none;
}

.ajw-toggle-btn--open .ajw-icon-chat {
  display: none;
}

.ajw-toggle-btn--open .ajw-icon-close {
  display: block;
}

.ajw-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--ajw-bg);
  border-radius: var(--ajw-radius);
  box-shadow: 0 12px 40px rgba(20, 30, 40, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ajw-border);
}

.ajw-header {
  background: var(--ajw-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ajw-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ajw-header-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ajw-header-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.ajw-header-sub {
  font-size: 11px;
  opacity: 0.85;
  line-height: 1.2;
}

.ajw-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  opacity: 0.9;
}

.ajw-close-btn:hover {
  opacity: 1;
}

.ajw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ajw-bg-muted);
}

.ajw-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: normal;
}

.ajw-msg--user {
  align-self: flex-end;
  background: var(--ajw-primary);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.ajw-msg--assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ajw-text);
  border: 1px solid var(--ajw-border);
  border-bottom-left-radius: 3px;
}

.ajw-msg--error {
  align-self: flex-start;
  background: var(--ajw-error-bg);
  color: var(--ajw-error-text);
  border: 1px solid rgba(138, 31, 17, 0.15);
}

.ajw-msg-text {
  margin: 0;
}

.ajw-sources {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ajw-source-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ajw-bg-muted);
  border: 1px solid var(--ajw-border);
  text-decoration: none;
  color: inherit;
}

.ajw-source-item:hover {
  border-color: var(--ajw-primary);
  background: #eaf2fa;
}

.ajw-source-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ajw-primary-dark);
}

.ajw-source-meta {
  font-size: 11.5px;
  color: var(--ajw-text-muted);
}

.ajw-msg--loading {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.ajw-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ajw-text-muted);
  animation: ajw-blink 1.2s infinite ease-in-out;
}

.ajw-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ajw-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ajw-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.ajw-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--ajw-border);
  background: var(--ajw-bg);
  flex-shrink: 0;
}

.ajw-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--ajw-border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  max-height: 120px;
  min-height: 38px;
  outline: none;
}

.ajw-input:focus {
  border-color: var(--ajw-primary);
}

.ajw-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--ajw-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ajw-send-btn:hover {
  background: var(--ajw-primary-dark);
}

.ajw-send-btn:disabled,
.ajw-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ajw-send-btn svg {
  width: 17px;
  height: 17px;
}

.ajw-disclaimer {
  font-size: 10.5px;
  color: var(--ajw-text-muted);
  text-align: center;
  padding: 6px 10px 10px;
  background: var(--ajw-bg);
  flex-shrink: 0;
}

.ajw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  #agent-chat-widget-root {
    right: 12px;
    bottom: 12px;
  }

  .ajw-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    bottom: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ajw-dot {
    animation: none;
  }
}
