/* MOTHI Chat Bot — Public Widget Styles */

:root {
  --mothi-primary:   #1a6b3a;
  --mothi-secondary: #ffffff;
  --mothi-bubble-size: 58px;
  --mothi-radius: 16px;
  --mothi-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* ── Floating Bubble ─────────────────────────────────────────────────────── */
#mothi-cb-bubble {
  position: fixed !important;
  bottom: 24px !important;
  top: auto !important;
  z-index: 2147483647 !important;
  width: var(--mothi-bubble-size);
  height: var(--mothi-bubble-size);
  border-radius: 50%;
  background: var(--mothi-primary);
  color: var(--mothi-secondary);
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--mothi-shadow);
  transition: transform .2s ease, box-shadow .2s ease;
  border: 3px solid rgba(255,255,255,.3);
  margin: 0 !important;
  padding: 0 !important;
}
#mothi-cb-bubble:hover,
#mothi-cb-bubble:focus {
  transform: scale(1.08) !important;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  outline: 3px solid rgba(255,255,255,.6);
}
#mothi-cb-bubble.mothi-cb-position-right { right: 24px !important; left: auto !important; }
#mothi-cb-bubble.mothi-cb-position-left  { left:  24px !important; right: auto !important; }

/* ── Chat Container ──────────────────────────────────────────────────────── */
#mothi-cb-container {
  position: fixed !important;
  bottom: 96px !important;
  top: auto !important;
  z-index: 2147483646 !important;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  display: flex !important;
  flex-direction: column;
  background: #fff;
  border-radius: var(--mothi-radius);
  box-shadow: var(--mothi-shadow);
  overflow: hidden;
  transition: opacity .2s ease, transform .2s ease;
  margin: 0 !important;
}
#mothi-cb-container.mothi-cb-position-right { right: 24px !important; left: auto !important; }
#mothi-cb-container.mothi-cb-position-left  { left:  24px !important; right: auto !important; }
#mothi-cb-container.mothi-cb-hidden {
  opacity: 0 !important;
  pointer-events: none;
  transform: translateY(12px) scale(.97);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.mothi-cb-header {
  background: var(--mothi-primary);
  color: var(--mothi-secondary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mothi-cb-header-info { display: flex; align-items: center; gap: 10px; }
.mothi-cb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mothi-cb-bot-name { display: block; font-size: 14px; font-weight: 700; line-height: 1.2; }
.mothi-cb-bot-subtitle { display: block; font-size: 11px; opacity: .8; }
.mothi-cb-header-actions { display: flex; gap: 6px; }
.mothi-cb-icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--mothi-secondary); padding: 4px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  opacity: .8; transition: opacity .15s;
}
.mothi-cb-icon-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* ── Messages ────────────────────────────────────────────────────────────── */
.mothi-cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.mothi-cb-message { display: flex; max-width: 88%; }
.mothi-cb-message-user { align-self: flex-end; flex-direction: row-reverse; }
.mothi-cb-message-bot  { align-self: flex-start; }

.mothi-cb-message-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.mothi-cb-message-user .mothi-cb-message-content {
  background: var(--mothi-primary);
  color: var(--mothi-secondary);
  border-bottom-right-radius: 4px;
}
.mothi-cb-message-bot .mothi-cb-message-content {
  background: #f3f4f6;
  color: #1f2937;
  border-bottom-left-radius: 4px;
}
.mothi-cb-message-bot.mothi-cb-thinking .mothi-cb-message-content {
  color: #9ca3af;
  font-style: italic;
}

/* ── Sources ─────────────────────────────────────────────────────────────── */
.mothi-cb-sources {
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  padding-top: 5px;
}
.mothi-cb-sources strong { display: block; margin-bottom: 2px; }
.mothi-cb-source-item { display: block; margin-left: 8px; }
.mothi-cb-source-item::before { content: "📄 "; }

/* ── Input Area ──────────────────────────────────────────────────────────── */
.mothi-cb-input-area {
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}
.mothi-cb-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: #f9fafb;
}
.mothi-cb-input:focus { border-color: var(--mothi-primary); background: #fff; }
.mothi-cb-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--mothi-primary);
  color: var(--mothi-secondary);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.mothi-cb-send-btn:hover  { filter: brightness(1.1); transform: scale(1.05); }
.mothi-cb-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Inline widget (shortcode) ───────────────────────────────────────────── */
.mothi-cb-inline-widget {
  border: 1px solid #e5e7eb;
  border-radius: var(--mothi-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 480px;
  max-width: 600px;
  margin: 0 auto;
}
.mothi-cb-inline-header {
  background: var(--mothi-primary);
  color: var(--mothi-secondary);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 15px;
}
.mothi-cb-inline-widget .mothi-cb-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }

/* ── Typing indicator ────────────────────────────────────────────────────── */
.mothi-cb-typing-dots span {
  display: inline-block;
  width: 7px; height: 7px; margin: 0 2px;
  background: #9ca3af; border-radius: 50%;
  animation: mothiDots 1.2s infinite ease-in-out;
}
.mothi-cb-typing-dots span:nth-child(2) { animation-delay: .2s; }
.mothi-cb-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes mothiDots {
  0%, 80%, 100% { transform: scale(.7); opacity: .5; }
  40%            { transform: scale(1);  opacity: 1; }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #mothi-cb-container {
    width: calc(100vw - 16px);
    right: 8px !important;
    left: 8px !important;
    bottom: 80px;
    height: calc(100vh - 96px);
  }
  #mothi-cb-bubble.mothi-cb-position-right { right: 16px; }
  #mothi-cb-bubble.mothi-cb-position-left  { left: 16px; }
}

/* ── Accessibility: reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #mothi-cb-bubble,
  #mothi-cb-container,
  .mothi-cb-send-btn { transition: none; }
  .mothi-cb-typing-dots span { animation: none; }
}
