/* ==============================================
   MORPHING CHATBOT - FIXED BORDER RADIUS APPROACH
   ============================================== */

#chatbot-wrapper {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-family: 'Poppins', sans-serif;
  z-index: 99999;
}

/* Chat Header - Morphing Element */
#chatbot-header {
  width: 60px;
  height: 60px;
  background: #ed1b24;
  color: white;
  cursor: pointer;
  clip-path: circle(50%);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border: none;
  position: relative;
  overflow: hidden;
  
  /* Morphing transition properties */
  transition: 
    width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    clip-path 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Keep it anchored to bottom-right */
  transform-origin: bottom right;
}

/* Morphed state - when chat is open */
#chatbot-header.morphed {
  width: 320px;
  height: 400px;
  clip-path: inset(0 round 16px);
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  cursor: default;
  background: #ed1b24;
  overflow: hidden;
}

/* Message icon - fades out during morph and stays centered */
.message-icon {
  width: 24px;
  height: 24px;
  fill: white;
  transition: opacity 0.2s ease;
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#chatbot-header.morphed .message-icon {
  opacity: 0;
}

/* Notification badge */
#new-msg-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ffd700;
  color: #ed1b24;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  border: none;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
  z-index: 3;
}

/* Chat content - initially hidden, appears during morph */
.chat-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
  display: flex;
  flex-direction: column;
  z-index: 1;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  /* Add a thin red border to prevent any gaps */
  border: 2px solid #ed1b24;
  box-sizing: border-box;
}

#chatbot-header.morphed .chat-content {
  opacity: 1;
}

/* Chat Header Bar - extends beyond container to hide border */
.chat-header-bar {
  background: #ed1b24;
  color: white;
  padding: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 0;
  margin: -2px -2px 0 -2px; /* Negative margins to cover border */
  position: relative;
  z-index: 2;
  border: none;
  outline: none;
  min-height: 64px; /* Increased to account for negative margin */
}

/* Profile section in header */
.chat-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #ed1b24;
  font-size: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.profile-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: #4CAF50;
  border-radius: 50%;
  display: inline-block;
}

.chat-title {
  font-weight: 600;
  font-size: 15px;
  color: white;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.2s ease;
  z-index: 10;
}

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

/* Chat Area - No Scrollbar */
#chatArea {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: white;
  border: none;
  color: #333;
  border-radius: 0;
  
  /* Hide scrollbar for Webkit browsers (Chrome, Safari, Edge) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* Internet Explorer 10+ */
}

/* Hide scrollbar for Webkit browsers */
#chatArea::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Base message styling */
#chatArea p {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
  border: none;
  display: inline-block;
  clear: both;
  position: relative;
}

/* User messages - Dynamic width, no icon, right-aligned */
#chatArea p:has(b:contains("You:")) {
  background: #ed1b24;
  color: white !important;
  float: right;
  text-align: left;
  border: none;
  max-width: 75%; /* Maximum width to prevent overly long bubbles */
  min-width: fit-content; /* Shrink to content size */
  width: auto; /* Let it size naturally */
  margin-bottom: 12px;
  border-bottom-right-radius: 6px; /* Tail effect */
}

/* Bot messages - Keep existing styling with icon */
#chatArea p:has(b:contains("Bot:")) {
  background: #f5f5f5;
  color: #333 !important;
  border: none;
  float: left;
  max-width: 80%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  border-bottom-left-radius: 6px; /* Tail effect */
  padding-left: 8px; /* Adjust for avatar */
}

/* Message avatars - Only for bot messages */
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  margin-top: 2px;
}

.msg-avatar.bot {
  background: #ed1b24;
  color: white;
  border: 1px solid #ed1b24;
}

/* Hide user avatars completely */
.msg-avatar.user {
  display: none !important;
}

.msg-content {
  flex: 1;
}

/* Hide the "You:" and "Bot:" labels */
#chatArea p b {
  display: none;
}

/* Clear floats after messages */
#chatArea::after {
  content: "";
  display: table;
  clear: both;
}

/* Input Area - extends beyond container to hide border */
.input-area {
  padding: 12px 16px;
  background: white;
  border: none;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  border-radius: 0;
  margin: 0 -2px -2px -2px; /* Negative margins to cover border */
  position: relative;
  z-index: 2;
  min-height: 48px; /* Increased to account for negative margin */
}

#userInput {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#userInput:focus {
  border-color: #ed1b24;
  box-shadow: none;
}

.send-btn {
  background: #ed1b24;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.send-btn:hover {
  background: #d41622;
}

.send-icon {
  width: 16px;
  height: 16px;
  fill: white;
}

#chatbot-wrapper * {
  font-family: 'Poppins', sans-serif;
}

/* Additional fix for mobile devices */
@media (max-width: 768px) {
  #chatbot-wrapper {
    bottom: 15px;
    right: 15px;
  }
  
  #chatbot-header.morphed {
    width: 280px;
    height: 350px;
  }
  
  /* Adjust message max-width for mobile */
  #chatArea p:has(b:contains("You:")) {
    max-width: 85%;
  }
  
  #chatArea p:has(b:contains("Bot:")) {
    max-width: 90%;
  }
}

