/* ==========================================================================
   AI Chatbot — Ask Reefonomics
   ========================================================================== */

.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--color-teal), var(--color-cyan));
  color: #fff;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: 0.01em;
  box-shadow: 0 8px 24px rgba(4, 196, 217, 0.35),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-out-expo),
              box-shadow var(--duration-base) ease;
}

.chatbot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(4, 196, 217, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.chatbot-toggle__icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
}

.chatbot-toggle.is-hidden {
  transform: translateY(100px) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

/* ---------- Chat Panel ---------- */
.chatbot-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 48px));
  background: rgba(18, 19, 44, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity var(--duration-base) var(--ease-out-expo),
              transform var(--duration-base) var(--ease-out-expo),
              visibility 0s var(--duration-base);
}

.chatbot-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

@media (max-width: 640px) {
  .chatbot-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
  }
}

.chatbot-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chatbot-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-teal), var(--color-cyan));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
}

.chatbot-header__name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--color-text-primary);
}

.chatbot-header__status {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}

.chatbot-header__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
}

.chatbot-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-text-secondary);
  transition: background var(--duration-fast) ease,
              color var(--duration-fast) ease;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
}

/* ---------- Messages ---------- */
.chatbot-messages {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-hover) transparent;
}

.chatbot-messages::-webkit-scrollbar { width: 6px; }
.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--color-border-hover);
  border-radius: 3px;
}

.chat-msg {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.55;
  word-wrap: break-word;
}

.chat-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--color-teal), var(--color-cyan));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg p + p { margin-top: var(--space-2); }
.chat-msg a { color: var(--color-coral); text-decoration: underline; }
.chat-msg ul, .chat-msg ol { padding-left: 1.2em; margin: var(--space-2) 0; }

/* Typing dots */
.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: typingDot 1.2s infinite ease-in-out;
}

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

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Quick replies ---------- */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-3);
}

.chat-suggestion {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}

.chat-suggestion:hover {
  border-color: var(--color-cyan);
  color: var(--color-cyan);
  background: rgba(4, 196, 217, 0.08);
}

/* ---------- Input ---------- */
.chatbot-input {
  padding: var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  background: rgba(10, 11, 26, 0.4);
}

.chatbot-input__field {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  outline: none;
  transition: border-color var(--duration-fast) ease;
  resize: none;
  font-family: inherit;
  max-height: 100px;
  line-height: 1.4;
}

.chatbot-input__field:focus {
  border-color: var(--color-cyan);
}

.chatbot-input__field::placeholder { color: var(--color-text-tertiary); }

.chatbot-input__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-teal), var(--color-cyan));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.chatbot-input__send:hover { transform: scale(1.08); }
.chatbot-input__send:disabled { opacity: 0.4; cursor: not-allowed; }

.chatbot-footer-note {
  padding: 0 var(--space-4) var(--space-3);
  font-size: 11px;
  color: var(--color-text-tertiary);
  text-align: center;
}
