/* Ask the Docs — chat widget styles (redesign) */

:root {
  --atd-bg: #f7f7f6;
  --atd-border: #e0dedd;
  --atd-user-bg: #1a1a1a;
  --atd-user-color: #ffffff;
  --atd-bot-bg: #ffffff;
  --atd-bot-color: #222222;
  --atd-font: inherit;
  --atd-text-secondary: #6b6b68;
  --atd-text-tertiary: #9b9b97;
}

.atd-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;
}

.atd-widget {
  max-width: 640px;
  border: 0.5px solid var(--atd-border);
  background: var(--atd-bg);
  padding: 1.4rem 1.4rem 1.2rem;
  margin: 2rem 0;
  font-family: var(--atd-font);
  box-sizing: border-box;
}

/* Header */

.atd-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.3rem;
}

.atd-icon {
  width: 28px;
  height: 28px;
  background: var(--atd-user-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.atd-icon svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.atd-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.atd-explanation {
  margin: 0 0 1rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--atd-text-secondary);
  padding-left: 38px;
}

/* Messages */

.atd-messages {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.25rem 0 0.5rem;
  scroll-behavior: smooth;
}

.atd-bubble {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  font-size: 0.875rem;
}

.atd-bubble.user {
  background: var(--atd-user-bg);
  color: var(--atd-user-color);
  align-self: flex-end;
}

.atd-bubble.assistant {
  background: var(--atd-bot-bg);
  color: var(--atd-bot-color);
  align-self: flex-start;
  border: 0.5px solid var(--atd-border);
}

.atd-bubble.assistant p:first-child { margin-top: 0; }
.atd-bubble.assistant p:last-child  { margin-bottom: 0; }

.atd-bubble.assistant ul,
.atd-bubble.assistant ol {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.atd-bubble.assistant code {
  background: #f0efed;
  padding: 0.1rem 0.3rem;
  font-size: 0.85em;
  font-family: monospace;
  border: 0.5px solid var(--atd-border);
}

.atd-bubble.assistant pre {
  background: #f0efed;
  padding: 0.6rem 0.8rem;
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.85em;
  border: 0.5px solid var(--atd-border);
  margin: 0.5rem 0;
}

.atd-bubble.assistant pre code {
  background: none;
  padding: 0;
  border: none;
}

/* Thinking bubble */

.atd-bubble.thinking {
  background: var(--atd-bot-bg);
  color: var(--atd-text-tertiary);
  align-self: flex-start;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 0.5px solid var(--atd-border);
  padding: 0.5rem 0.9rem;
}

.atd-spinner {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.atd-spinner span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
  animation: atd-bounce 1.2s ease-in-out infinite both;
}

.atd-spinner span:nth-child(1) { animation-delay: -0.32s; }
.atd-spinner span:nth-child(2) { animation-delay: -0.16s; }

@keyframes atd-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40%           { transform: scale(1); opacity: 1;   }
}

/* Sources */

.atd-sources {
  font-size: 0.78rem;
  padding: 0.25rem 0.9rem 0.3rem;
  color: var(--atd-text-tertiary);
  align-self: flex-start;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.atd-sources-label {
  font-size: 0.75rem;
  color: var(--atd-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.atd-sources a {
  color: var(--atd-text-secondary);
  text-decoration: none;
  border-bottom: 0.5px solid var(--atd-border);
  transition: border-color 0.15s;
}

.atd-sources a:hover {
  border-bottom-color: var(--atd-text-secondary);
}

/* Separator */

.atd-separator {
  border: none;
  border-top: 0.5px solid var(--atd-border);
  margin: 0.9rem 0;
}

/* Input form */

.atd-form {
  display: flex;
  gap: 0;
  align-items: stretch;
  border: 0.5px solid #c8c7c4;
  background: var(--atd-bot-bg);
  transition: border-color 0.15s;
}

.atd-form:focus-within {
  border-color: #888784;
}

.atd-input-wrap {
  flex: 1;
  display: flex;
}

.atd-form textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  font-family: var(--atd-font);
  font-size: 0.875rem;
  resize: none;
  min-height: 46px;
  line-height: 1.5;
  box-sizing: border-box;
  color: inherit;
  outline: none;
  margin:0 0 0 0;
}

.atd-form textarea::placeholder {
  color: var(--atd-text-tertiary);
}

form.atd-form button {
  padding: 0 1.1rem;
  background: var(--atd-user-bg);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  min-height: 46px;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  width:auto;
  margin-top:0;
  gap: 6px;
  transition: opacity 0.15s;
}

.atd-form button:disabled {
  opacity: 0.4;
  cursor: default;
}

.atd-form button:not(:disabled):hover {
  opacity: 0.82;
}

/* Character counter */

.atd-char-count {
  font-size: 0.75rem;
  color: var(--atd-text-tertiary);
  text-align: right;
  margin-top: 0.4rem;
  padding-right: 2px;
}

/* Privacy */

.atd-privacy {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  background: var(--atd-bot-bg);
  border: 0.5px solid var(--atd-border);
  font-size: 0.82rem;
}

.atd-privacy-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--atd-text-secondary);
  line-height: 1.5;
}

.atd-privacy-label input[type="checkbox"] {
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--atd-user-bg);
}

.atd-privacy-label div {
  flex: 1;
}

.atd-privacy-text p{
  padding: 0;
  margin: 0;
}

.atd-privacy-text p a {
  color: inherit;
  text-decoration: underline;
}

.atd-privacy-error {
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #fee2e2;
  color: #991b1b;
  border: 0.5px solid #fca5a5;
  font-size: 0.8rem;
}