/* =====================================================
   JeSuspended AI Chatbot - Frontend Widget Styles
   ===================================================== */

/* -- Chat Bubble -- */
.jes-chat-bubble {
  position: fixed;
  bottom: 24px;
  z-index: 999999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--jes-color, #6C63FF);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25), 0 0 0 0 var(--jes-color);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.jes-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.jes-chat-bubble:active {
  transform: scale(0.95);
}

.jes-pos-right { right: 24px; }
.jes-pos-left { left: 24px; }

.jes-bubble-icon,
.jes-bubble-close {
  display: flex;
  align-items: center;
  justify-content: center;
}

.jes-bubble-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--jes-color, #6C63FF);
  opacity: 0;
  animation: jesPulse 2s ease-out infinite;
  pointer-events: none;
}

@keyframes jesPulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* -- Chat Window -- */
.jes-chat-window {
  position: fixed;
  bottom: 96px;
  z-index: 999998;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.jes-chat-window.jes-pos-right { right: 24px; }
.jes-chat-window.jes-pos-left { left: 24px; }

.jes-animate-in {
  animation: jesSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.jes-animate-out {
  animation: jesSlideOut 0.2s ease-in forwards;
}

@keyframes jesSlideIn {
  0% { opacity: 0; transform: translateY(20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes jesSlideOut {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(20px) scale(0.95); }
}

/* -- Header -- */
.jes-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--jes-color, #6C63FF);
  color: #fff;
}

.jes-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.jes-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
}

.jes-header-title {
  font-weight: 700;
  font-size: 1.05em;
  letter-spacing: -0.01em;
}

.jes-header-status {
  font-size: 0.8em;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}

.jes-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4AE68A;
  display: inline-block;
  animation: jesDotPulse 2s infinite;
}

@keyframes jesDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.jes-header-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.jes-header-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* -- Messages -- */
.jes-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f8fa;
  scroll-behavior: smooth;
}

.jes-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.jes-chat-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

.jes-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.jes-user {
  align-self: flex-end;
  align-items: flex-end;
}

.jes-bot {
  align-self: flex-start;
  align-items: flex-start;
}

.jes-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.jes-user .jes-msg-bubble {
  background: var(--jes-color, #6C63FF);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.jes-bot .jes-msg-bubble {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.jes-msg-bubble code {
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.jes-msg-time {
  font-size: 0.7em;
  color: #999;
  margin-top: 4px;
  padding: 0 4px;
}

.jes-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0 2px;
}

.jes-source-link {
  font-size: 0.75em;
  background: rgba(108, 99, 255, 0.08);
  color: var(--jes-color, #6C63FF);
  padding: 3px 8px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.2s;
}

.jes-source-link:hover {
  background: rgba(108, 99, 255, 0.16);
}

/* -- Typing Indicator -- */
.jes-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
}

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

.jes-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.jes-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes jesTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* -- Input Area -- */
.jes-chat-input-area {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
}

.jes-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jes-chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid #e8e8ef;
  border-radius: 24px;
  font-size: 1em;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  background: #f7f8fa;
}

.jes-chat-input:focus {
  border-color: var(--jes-color, #6C63FF);
  background: #fff;
}

.jes-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.jes-send-btn:hover {
  transform: scale(1.08);
}

.jes-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.jes-powered {
  text-align: center;
  font-size: 0.65em;
  color: #bbb;
  margin-top: 8px;
}

/* -- Mobile Responsive -- */
@media (max-width: 480px) {
  .jes-chat-window {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
    max-height: 100%;
  }

  .jes-chat-bubble {
    bottom: 16px;
  }

  .jes-pos-right.jes-chat-bubble { right: 16px; }
  .jes-pos-left.jes-chat-bubble { left: 16px; }
}

@media (max-width: 768px) and (min-width: 481px) {
  .jes-chat-window {
    width: 340px !important;
    height: 480px !important;
  }
}
