/* ============================================================
   Mojo Manor — AI Concierge Chat Widget
   ============================================================ */

:root {
  --chat-bg:       #0f1117;
  --chat-surface:  #1a1f2e;
  --chat-border:   #2a3040;
  --chat-text:     #e2e8f0;
  --chat-muted:    #64748b;
  --chat-accent:   #8b6f47;
  --chat-accent-l: #c4a882;
  --chat-user-bg:  #1e3a2f;
  --chat-user-bdr: #2d5a42;
  --chat-bot-bg:   #1a2033;
  --chat-bot-bdr:  #2a3550;
  --chat-radius:   1rem;
  --chat-w:        380px;
  --chat-h:        520px;
  --shadow:        0 24px 60px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.35);
}

/* ── Floating Trigger Button ── */
.mojo-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b6f47 0%, #6b4f2e 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139,111,71,.5), 0 2px 8px rgba(0,0,0,.4);
  transition: transform .2s ease, box-shadow .2s ease;
  outline: none;
}
.mojo-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(139,111,71,.65), 0 2px 8px rgba(0,0,0,.4);
}
.mojo-chat-trigger:active { transform: scale(.96); }

.mojo-chat-trigger svg { transition: opacity .2s, transform .2s; }
.mojo-chat-trigger .icon-open  { position: absolute; }
.mojo-chat-trigger .icon-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
.mojo-chat-trigger.open .icon-open  { opacity: 0; transform: rotate(90deg); }
.mojo-chat-trigger.open .icon-close { opacity: 1; transform: rotate(0deg); }

/* Pulse ring when closed */
.mojo-chat-trigger:not(.open)::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(139,111,71,.4);
  animation: chat-pulse 2.4s ease-out infinite;
}
@keyframes chat-pulse {
  0%   { transform: scale(1);   opacity: .8; }
  70%  { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* Unread badge */
.mojo-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e53e3e;
  border: 2px solid var(--chat-bg, #0f1117);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transform: scale(0);
  transition: opacity .2s, transform .2s;
}
.mojo-chat-badge.show { opacity: 1; transform: scale(1); }

/* ── Chat Panel ── */
.mojo-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 8999;
  width: var(--chat-w);
  max-height: var(--chat-h);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.mojo-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Panel Header ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chat-border);
  background: var(--chat-surface);
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b6f47, #6b4f2e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139,111,71,.4);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--chat-text);
  letter-spacing: .01em;
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--chat-muted);
  margin-top: 1px;
}
.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48bb78;
  box-shadow: 0 0 5px rgba(72,187,120,.6);
  flex-shrink: 0;
}
.chat-header-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--chat-muted);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.chat-header-close:hover { color: var(--chat-text); background: rgba(255,255,255,.06); }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 2px; }

.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msg-in .18s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.bot  { align-self: flex-start; }

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b6f47, #6b4f2e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--chat-text);
  max-width: 100%;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: var(--chat-bot-bg);
  border: 1px solid var(--chat-bot-bdr);
  border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: var(--chat-user-bg);
  border: 1px solid var(--chat-user-bdr);
  border-bottom-right-radius: 4px;
  color: #d1fae5;
}

/* Typing dots */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: typing-dot .9s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0);   opacity: .4; }
  30%           { transform: translateY(-5px); opacity: 1;  }
}

/* Suggested prompts */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 8px;
}
.chat-suggestion {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--chat-accent-l);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.chat-suggestion:hover {
  background: rgba(139,111,71,.12);
  border-color: var(--chat-accent);
}

/* ── Input Area ── */
.chat-input-area {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-surface);
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  transition: border-color .2s;
}
.chat-input-row:focus-within { border-color: var(--chat-accent); }

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--chat-text);
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  min-height: 20px;
  font-family: inherit;
}
.chat-input::placeholder { color: var(--chat-muted); }

.chat-send {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b6f47, #6b4f2e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
  color: #fff;
}
.chat-send:hover { opacity: .85; }
.chat-send:active { transform: scale(.93); }
.chat-send:disabled { opacity: .35; cursor: default; }

.chat-input-footer {
  text-align: center;
  font-size: 10px;
  color: var(--chat-muted);
  margin-top: 8px;
  opacity: .6;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  :root {
    --chat-w: calc(100vw - 24px);
  }
  .mojo-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 90px;
    width: auto;
  }
  .mojo-chat-trigger {
    right: 16px;
    bottom: 20px;
  }
}
