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

/* ── Launcher (floating button) ── */
.ca-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  z-index: 999998;
  animation: ca-fade-in 0.3s ease;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.ca-launcher:hover {
  transform: translateY(-2px);
}

.ca-launcher-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.ca-launcher-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  border: 3px solid #fff;
  transition: box-shadow 0.2s ease;
}

.ca-launcher:hover .ca-launcher-avatar {
  box-shadow: 0 6px 24px rgba(11, 107, 203, 0.35);
}

.ca-launcher-label {
  background: #fff;
  color: #1f2937;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

/* ── Chat window ── */
.ca-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 999999;
  background: #fff;
  display: flex;
  flex-direction: column;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ca-window.ca-visible {
  opacity: 1;
  transform: translateY(0);
}

.ca-window.ca-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

/* ── Header ── */
.ca-header {
  background: linear-gradient(135deg, #0b6bcb 0%, #0954a5 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.ca-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ca-header-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.ca-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ca-header-name {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
}

.ca-header-sub {
  font-size: 13px;
  opacity: 0.9;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ca-online-dot {
  width: 8px;
  height: 8px;
  background: #34d399;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ca-header-right {
  display: flex;
  align-items: center;
}

.ca-header-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.ca-header-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── Messages ── */
.ca-messages {
  flex: 1;
  min-height: 300px;
  max-height: 420px;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
}

.ca-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.ca-msg-row.ca-msg-user {
  justify-content: flex-end;
}

.ca-msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ca-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.ca-bubble.ca-bot {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.ca-bubble.ca-user {
  background: #0b6bcb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ca-sources {
  margin: -4px 0 12px 36px;
  font-size: 11.5px;
  color: #6b7280;
}

.ca-sources a {
  color: #0b6bcb;
  text-decoration: none;
}

.ca-sources a:hover {
  text-decoration: underline;
}

/* ── Typing indicator (bouncing dots) ── */
.ca-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ca-dot {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  display: inline-block;
  animation: ca-bounce 1.2s ease-in-out infinite;
}

.ca-dot:nth-child(2) { animation-delay: 0.15s; }
.ca-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ca-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input area ── */
.ca-input-area {
  padding: 14px 16px 18px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.ca-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ca-input:focus {
  border-color: #0b6bcb;
  box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.1);
}

.ca-send-btn {
  border: 0;
  background: #0b6bcb;
  color: #fff;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.ca-send-btn:hover {
  background: #0954a5;
}

.ca-send-btn:active {
  transform: scale(0.94);
}

.ca-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ── Animations ── */
@keyframes ca-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .ca-launcher {
    bottom: 16px;
    right: 16px;
  }

  .ca-launcher-label {
    display: none;
  }

  .ca-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .ca-messages {
    max-height: calc(100vh - 160px);
  }
}
