/* ── Music Jungle Chatbot Widget ──────────────────────────────────────────── */

:root {
  --mj-primary:    #1a1a1a;
  --mj-accent:     #e8c547;
  --mj-bg:         #ffffff;
  --mj-bg-user:    #1a1a1a;
  --mj-bg-bot:     #f4f4f4;
  --mj-text:       #1a1a1a;
  --mj-text-light: #666666;
  --mj-border:     #e0e0e0;
  --mj-radius:     16px;
  --mj-shadow:     0 8px 32px rgba(0,0,0,0.18);
  --mj-z:          99999;
}

#mj-chat-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--mj-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Toggle button ──────────────────────────────────────────────────────── */

#mj-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--mj-primary);
  color: var(--mj-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}

#mj-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#mj-chat-toggle:focus-visible {
  outline: 3px solid var(--mj-accent);
  outline-offset: 3px;
}

/* ── Panel ──────────────────────────────────────────────────────────────── */

#mj-chat-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--mj-bg);
  border-radius: var(--mj-radius);
  box-shadow: var(--mj-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mj-slide-up 0.22s ease;
}

@keyframes mj-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

#mj-chat-header {
  background: var(--mj-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#mj-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#mj-chat-avatar {
  width: 38px;
  height: 38px;
  background: var(--mj-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

#mj-chat-name {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}

#mj-chat-status {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}

/* ── Messages ───────────────────────────────────────────────────────────── */

#mj-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  min-height: 260px;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

#mj-chat-messages::-webkit-scrollbar {
  width: 4px;
}
#mj-chat-messages::-webkit-scrollbar-thumb {
  background: var(--mj-border);
  border-radius: 2px;
}

.mj-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.55;
}

.mj-msg a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.mj-msg-user {
  align-self: flex-end;
  background: var(--mj-bg-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.mj-msg-assistant {
  align-self: flex-start;
  background: var(--mj-bg-bot);
  color: var(--mj-text);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */

.mj-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.mj-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: mj-bounce 1.2s infinite ease-in-out;
}

.mj-typing span:nth-child(1) { animation-delay: 0s; }
.mj-typing span:nth-child(2) { animation-delay: 0.18s; }
.mj-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes mj-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1.1); opacity: 1; }
}

/* ── Input area ─────────────────────────────────────────────────────────── */

#mj-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--mj-border);
  background: #fff;
}

#mj-chat-input {
  flex: 1;
  border: 1px solid var(--mj-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s;
  color: var(--mj-text);
}

#mj-chat-input:focus {
  border-color: var(--mj-primary);
}

#mj-chat-input:disabled {
  background: #fafafa;
}

#mj-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--mj-primary);
  color: var(--mj-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

#mj-chat-send:hover:not(:disabled) {
  background: #333;
}

#mj-chat-send:focus-visible {
  outline: 3px solid var(--mj-accent);
  outline-offset: 2px;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */

#mj-chat-footer {
  text-align: center;
  font-size: 11px;
  color: var(--mj-text-light);
  padding: 6px 12px 8px;
  border-top: 1px solid var(--mj-border);
}

#mj-chat-footer a {
  color: var(--mj-text-light);
  text-decoration: none;
}

#mj-chat-footer a:hover {
  text-decoration: underline;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #mj-chat-wrapper {
    bottom: 16px;
    right: 16px;
  }

  #mj-chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--mj-radius) var(--mj-radius) 0 0;
    bottom: 80px;
  }

  #mj-chat-messages {
    max-height: 50vh;
  }
}
