/* ============================================================
   Maiaa AI Assistant Chatbot Widget
   ============================================================ */

/* --- Floating trigger button --- */
.chatbot-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C47FF, #a78bfa);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(108,71,255,0.35), 0 2px 8px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
}
.chatbot-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(108,71,255,0.45), 0 4px 12px rgba(0,0,0,0.15);
}
.chatbot-trigger svg { width: 26px; height: 26px; }
.chatbot-trigger .ct-open  { display: flex; }
.chatbot-trigger .ct-close { display: none; }
.chatbot-trigger.is-open .ct-open  { display: none; }
.chatbot-trigger.is-open .ct-close { display: flex; }

/* --- Panel --- */
.chatbot-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.16), 0 4px 16px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  transform-origin: bottom right;
}
.chatbot-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* --- Header --- */
.cb-header {
  background: linear-gradient(135deg, #6C47FF 0%, #a78bfa 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cb-header-text { flex: 1; }
.cb-header-text h4 {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.cb-header-text p {
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  margin: 0;
}
.cb-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
}

/* --- Messages --- */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 99px; }

/* Bubbles */
.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
}
.cb-msg.bot { align-self: flex-start; }
.cb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.cb-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--dark, #111);
}
.cb-msg.bot .cb-bubble {
  background: #f3f4f6;
  border-bottom-left-radius: 4px;
}
.cb-msg.user .cb-bubble {
  background: linear-gradient(135deg, #6C47FF, #a78bfa);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Tool result card inside a bot bubble */
.cb-result {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
  font-size: 13px;
}
.cb-result-header {
  padding: 10px 14px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb-score-badge {
  margin-left: auto;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
}
.score-great { color: #16a34a; }
.score-ok    { color: #d97706; }
.score-poor  { color: #dc2626; }

.cb-result-rows { padding: 0 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.cb-result-row { display: flex; flex-direction: column; gap: 2px; }
.cb-result-row-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
}
.cb-result-row-val {
  font-size: 13px;
  color: #111;
  line-height: 1.4;
}
.cb-bar-wrap {
  height: 6px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 3px;
}
.cb-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.22,1,0.36,1);
}
.cb-divider { height: 1px; background: #f3f4f6; margin: 4px 0; }

/* Quick-reply chips */
.cb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.cb-chip {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1.5px solid #6C47FF;
  color: #6C47FF;
  font-size: 12.5px;
  font-weight: 700;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.cb-chip:hover { background: #6C47FF; color: #fff; }

/* Typing indicator */
.cb-typing .cb-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}
.cb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: cb-bounce 1.2s ease-in-out infinite;
}
.cb-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* --- Input area --- */
.cb-input-wrap {
  padding: 12px 16px;
  border-top: 1px solid #f3f4f6;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.cb-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 96px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color 0.15s;
  color: #111;
}
.cb-input:focus { border-color: #6C47FF; }
.cb-input::placeholder { color: #9ca3af; }

.cb-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6C47FF, #a78bfa);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.cb-send:hover { opacity: 0.88; transform: scale(1.05); }
.cb-send svg { width: 17px; height: 17px; }

/* --- Mobile tweaks --- */
@media (max-width: 480px) {
  .chatbot-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 70vh;
    border-radius: 20px 20px 0 0;
  }
  .chatbot-trigger { bottom: 20px; right: 20px; }
}
