/* ============================================================
   JMR Labs — KI-Chatbot Widget
   ============================================================ */

/* Toggle Button */
#jmr-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(108, 99, 255, 0.5);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.25s ease;
  font-size: 1.5rem;
  color: #fff;
}

#jmr-chat-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(108, 99, 255, 0.7);
}

#jmr-chat-btn.is-open .jmr-chat-icon-open  { display: none; }
#jmr-chat-btn.is-open .jmr-chat-icon-close { display: block; }
#jmr-chat-btn:not(.is-open) .jmr-chat-icon-close { display: none; }

/* Notification dot */
#jmr-chat-btn::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #0a0a14;
  animation: jmr-pulse 2s infinite;
}

@keyframes jmr-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* Chat Window */
#jmr-chat-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9001;
  width: 370px;
  max-height: 560px;
  background: #0f0f1e;
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(108,99,255,0.1);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity  0.3s ease;
}

#jmr-chat-window.jmr-hidden {
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

/* Header */
.jmr-chat-header {
  background: linear-gradient(135deg, rgba(108,99,255,0.15), rgba(0,212,255,0.08));
  border-bottom: 1px solid rgba(108, 99, 255, 0.2);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.jmr-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.jmr-chat-header-info { flex: 1; min-width: 0; }

.jmr-chat-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.jmr-chat-subtitle {
  font-size: 0.72rem;
  color: #9898c0;
  margin-top: 1px;
}

.jmr-chat-ai-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(108, 99, 255, 0.18);
  border: 1px solid rgba(108, 99, 255, 0.3);
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* Messages */
.jmr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.jmr-chat-messages::-webkit-scrollbar { width: 4px; }
.jmr-chat-messages::-webkit-scrollbar-track { background: transparent; }
.jmr-chat-messages::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.3); border-radius: 2px; }

/* Message bubbles */
.jmr-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: jmr-msg-in 0.25s ease;
}

@keyframes jmr-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.jmr-msg--bot  { flex-direction: row; }
.jmr-msg--user { flex-direction: row-reverse; }

.jmr-msg-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #00d4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.jmr-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 78%;
  word-break: break-word;
}

.jmr-msg--bot  .jmr-bubble {
  background: #141428;
  border: 1px solid rgba(108, 99, 255, 0.18);
  color: #e8e8f4;
  border-bottom-left-radius: 4px;
}

.jmr-msg--user .jmr-bubble {
  background: linear-gradient(135deg, #6c63ff, #4f46e5);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.jmr-typing .jmr-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}

.jmr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9898c0;
  animation: jmr-dots 1.3s infinite ease-in-out;
}
.jmr-dot:nth-child(2) { animation-delay: 0.2s; }
.jmr-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes jmr-dots {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* Error message */
.jmr-msg--error .jmr-bubble {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* Input area */
.jmr-chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(108, 99, 255, 0.15);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #0f0f1e;
}

#jmr-chat-input {
  flex: 1;
  background: #141428;
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: #e8e8f4;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

#jmr-chat-input::placeholder { color: #6060a0; }
#jmr-chat-input:focus { border-color: rgba(108, 99, 255, 0.45); }

#jmr-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6c63ff, #4f46e5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
  color: #fff;
  font-size: 1rem;
}

#jmr-chat-send:hover:not(:disabled) { opacity: 0.85; transform: scale(1.05); }
#jmr-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Footer note */
.jmr-chat-footer {
  padding: 6px 16px 12px;
  text-align: center;
  font-size: 0.68rem;
  color: #6060a0;
  background: #0f0f1e;
}

.jmr-chat-footer a {
  color: #9898c0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Mobile */
@media (max-width: 480px) {
  #jmr-chat-window {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 96px;
  }
  #jmr-chat-btn { right: 16px; bottom: 20px; }
}
