/* Chat widget */
#aadi-chat-container {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 440px;
  max-width: calc(100vw - 24px);
  height: 620px;
  max-height: calc(100dvh - 80px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: var(--aadi-deep);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  flex-direction: column;
  overflow: hidden;
}

#aadi-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 14px 20px;
  background: var(--aadi-security-blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 82, 163, 0.35);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  z-index: 9998;
}

#aadi-toggle:hover { background: #004080; }

.chat-header {
  background: var(--aadi-slate-ui);
  color: #f1f5f9;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.chat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

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

.voice-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: var(--aadi-deep);
  color: #94a3b8;
  cursor: pointer;
}

.voice-toggle:hover {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.4);
}

.voice-toggle.is-on {
  color: #86efac;
  border-color: rgba(5, 150, 105, 0.35);
}

.voice-toggle.is-speaking {
  color: #fde68a;
  border-color: rgba(234, 179, 8, 0.4);
}

.voice-toggle .voice-mic-icon {
  display: block;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-brand .brand-icon {
  width: 32px;
  height: 32px;
}

.chat-brand .brand-wordmark {
  font-size: 1.125rem;
}

.chat-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--aadi-deep);
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: var(--aadi-slate-ui);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.chat-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  outline: none;
  background: var(--aadi-deep);
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.875rem;
}

.chat-input-row input:focus {
  border-color: var(--aadi-security-blue);
}

.chat-input-row button {
  padding: 10px 16px;
  background: var(--aadi-security-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.875rem;
}

.chat-disclaimer {
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
  color: #cbd5e1;
}

.msg-intro-follow {
  color: #94a3b8;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.msg-user {
  align-self: flex-end;
  background: var(--aadi-slate-ui);
  color: #f1f5f9;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  max-width: 85%;
  font-size: 0.875rem;
}

.msg-ai {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.65);
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  max-width: 85%;
  font-size: 0.875rem;
}

.route-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 0.6875rem;
  color: #94a3b8;
}

.route-label {
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
}

.route-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.route-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--aadi-trust-green);
}

.route-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.625rem;
  color: #64748b;
  margin-top: 4px;
}

.msg-ai.msg-handoff {
  border: 1px solid rgba(147, 197, 253, 0.35);
  background: rgba(30, 58, 138, 0.22);
}

.handoff-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 6px;
}

.handoff-link {
  display: inline-block;
  margin-top: 10px;
  color: #bfdbfe;
  text-decoration: underline;
  font-size: 0.875rem;
}

.handoff-trigger-btn {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 8px;
  background: rgba(30, 58, 138, 0.18);
  color: #dbeafe;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.handoff-trigger-btn:hover {
  background: rgba(30, 58, 138, 0.32);
}

.handoff-panel {
  align-self: stretch;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.92);
}

.handoff-panel-title {
  margin: 0 0 4px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #f8fafc;
}

.handoff-panel-copy {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.handoff-panel input,
.handoff-panel textarea,
.handoff-panel select {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.875rem;
}

.handoff-panel textarea {
  resize: vertical;
  min-height: 56px;
}

.handoff-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

.handoff-panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.handoff-panel-actions button {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.handoff-submit-btn {
  border: none;
  background: var(--aadi-trust-green);
  color: #fff;
}

.handoff-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.handoff-cancel-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: #e2e8f0;
}

.handoff-error {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: #fecaca;
}
