/* ═══════════════════════════════════════════
   Sensei AI Chat Widget Styles
   ═══════════════════════════════════════════ */

/* Chat Trigger Button */
.sensei-chat-trigger {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d61818 0%, #7a0101 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 6px 25px rgba(214, 24, 24, 0.4);
  z-index: 9998;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  overflow: hidden;
}

.sensei-chat-trigger:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 10px 35px rgba(214, 24, 24, 0.5);
}

.sensei-chat-trigger .chat-icon-open,
.sensei-chat-trigger .chat-icon-close {
  position: absolute;
  transition: all 0.3s ease;
}

.sensei-chat-trigger .chat-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.sensei-chat-trigger.active .chat-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.sensei-chat-trigger.active .chat-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Unread Badge */
.sensei-chat-trigger .chat-unread {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #25D366;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

/* Chat Panel */
.sensei-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 15px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0,0,0,0.05);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;
}

.sensei-chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.sensei-chat-header {
  background: linear-gradient(135deg, #0d0d0d 0%, #1a1a2e 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sensei-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.sensei-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

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

.sensei-chat-header-info h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.sensei-chat-header-info p {
  margin: 0;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}

.sensei-chat-header-info .online-dot {
  width: 7px;
  height: 7px;
  background: #25D366;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sensei-chat-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sensei-chat-close:hover {
  background: rgba(255,255,255,0.2);
}

/* Chat Messages Area */
.sensei-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fb;
  min-height: 250px;
  max-height: 320px;
}

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

.sensei-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.sensei-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 10px;
}

/* Message Bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgFadeIn 0.3s ease-out;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.assistant {
  align-self: flex-start;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.chat-msg.assistant .chat-msg-avatar {
  overflow: hidden;
}

.chat-msg.assistant .chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-msg.user .chat-msg-avatar {
  background: #e2e8f0;
  color: #64748b;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.assistant .chat-msg-bubble {
  background: #fff;
  color: #1e1e2f;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, #d61818, #b01313);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Markdown-light in messages */
.chat-msg-bubble strong, .chat-msg-bubble b {
  font-weight: 600;
}

.chat-msg-bubble a {
  color: inherit;
  text-decoration: underline;
}

.chat-msg-bubble p {
  margin: 0 0 6px 0;
}

.chat-msg-bubble p:last-child {
  margin-bottom: 0;
}

.chat-msg-bubble ul, .chat-msg-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}

.chat-msg-bubble li {
  margin-bottom: 2px;
}

.chat-msg-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 85%;
}

.chat-typing .chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-typing .chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.typing-dots {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #b0b0b0;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Welcome Message */
.chat-welcome {
  text-align: center;
  padding: 20px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.chat-welcome-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d61818, #ff4444);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  margin-bottom: 5px;
}

.chat-welcome h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e1e2f;
}

.chat-welcome p {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  max-width: 260px;
}

/* Chat Input Area */
.sensei-chat-input {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}

.sensei-chat-input textarea {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: "Poppins", sans-serif;
  resize: none;
  max-height: 80px;
  min-height: 40px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s ease;
  background: #f8f9fb;
  color: #1e1e2f;
}

.sensei-chat-input textarea:focus {
  border-color: #d61818;
  background: #fff;
}

.sensei-chat-input textarea::placeholder {
  color: #9ca3af;
}

.sensei-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d61818, #b01313);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sensei-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(214, 24, 24, 0.3);
}

.sensei-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Powered By */
.sensei-chat-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #9ca3af;
  background: #fff;
  border-top: 1px solid #f3f4f6;
}

.sensei-chat-powered a {
  color: #d61818;
  text-decoration: none;
  font-weight: 500;
}

/* Greeting Bubble */
.sensei-chat-greeting {
  position: fixed;
  bottom: 50px;
  right: 100px;
  background: #fff;
  color: #1e1e2f;
  padding: 14px 20px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0,0,0,0.04);
  font-size: 13px;
  font-family: "Poppins", sans-serif;
  font-weight: 500;
  line-height: 1.4;
  max-width: 260px;
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.9);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.sensei-chat-greeting.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.sensei-chat-greeting::after {
  content: '';
  position: absolute;
  bottom: 8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

.sensei-chat-greeting .greeting-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: #e5e7eb;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #6b7280;
  transition: all 0.2s ease;
  line-height: 1;
}

.sensei-chat-greeting .greeting-close:hover {
  background: #d61818;
  color: #fff;
}

.sensei-chat-greeting .greeting-wave {
  margin-right: 4px;
}

/* ─── Responsive ─── */
@media (max-width: 576px) {
  .sensei-chat-trigger {
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    font-size: 24px;
  }

  .sensei-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }

  .sensei-chat-messages {
    max-height: calc(85vh - 180px);
  }
}

@media (max-width: 420px) {
  .sensei-chat-panel {
    max-height: 90vh;
  }
}
