/* Modal overlay */
.chatbot-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1); /* Increased opacity by 25% from 0.1 */
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(4px); /* Reduced blur by 50% from 8px */
  -webkit-backdrop-filter: blur(4px); /* Reduced blur by 50% from 8px */
}

/* Disclaimer text */
.bf-chatbot-disclaimer {
  color: #bbb;
  font-size: 11px;
  text-align: center;
  line-height: 1.4;
  padding: 5px 20px;
  user-select: none;
  pointer-events: none;
  z-index: 6;
  width: 100%;
  box-sizing: border-box;
}

.hidden.chatbot-modal {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Chatbot card */
.chatbot-modal-inner {
  background: rgba(0, 0, 0, 0.625); /* Increased opacity by 25% from 0.5 */
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  padding: 0;
  width: 520px;
  max-width: 95vw;
  height: 650px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

/* Fullscreen mode styles */
.fullscreen .chatbot-modal-inner {
  width: 90vw !important;
  height: 90vh !important;
  max-width: none !important;
  margin: 0 auto;
}

.fullscreen.chatbot-modal {
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Update font for entire chatbot */
#bf-chatbot {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  color: white;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: all 0.3s ease-in-out;
}

/* Footer container to hold input and footer elements */
.footer-container {
  position: relative;
  width: 100%;
  margin-top: auto;
  background: transparent; /* Use modal's background */
  border-top: none; /* Removed border */
  border-radius: 0 0 20px 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Profile container */
.chat-header {
  padding: 10px 20px 0;
  margin-bottom: 0;
}

.bf-profile-container {
  text-align: center;
  padding: 15px 0 0;
  transition: all 0.3s ease;
  margin-bottom: 0;
}

.bf-profile-image {
  width: 70px;
  height: 70px;
  margin: 0 auto 10px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.bf-profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bf-profile-name {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 3px;
}

.bf-profile-title {
  font-size: 14px;
  opacity: 0.8;
  margin-bottom: 10px;
}

/* Chat container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Initial view */
/* Style moved to .initial-view below */

/* Suggested questions */
.bf-chatbot-suggested {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.bf-chatbot-suggested-title {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-bottom: 8px;
  opacity: 0.8;
}

.bf-chatbot-suggested-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bf-chatbot-suggested-btn {
  background: rgba(255, 255, 255, 0.01) !important; /* Increased opacity by 25% from 0.1 */
  border: 1px solid rgba(255, 255, 255, 0.25) !important; /* Increased opacity by 25% from 0.2 */
  color: white !important;
  padding: 10px 16px !important;
  border-radius: 8px !important;
  text-align: left !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
  width: 100% !important;
  box-shadow: none !important;
  font-size: 13px !important;
  display: block !important;
  margin-bottom: 6px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.bf-chatbot-suggested-btn:hover {
  background: rgba(255, 255, 255, 0.05) !important; /* Increased opacity by 25% from 0.15 */
  border-color: rgba(255, 255, 255, 0.31) !important; /* Increased opacity by 25% from 0.25 */
}

/* Chat view */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  height: 100%;
  padding-top: 0; /* Remove top padding */
  z-index: 5; /* Ensure proper z-index */
}

.chat-view.active {
  opacity: 1 !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 10 !important;
  display: flex !important;
}

/* Hide initial view when chat is active */
#bf-chatbot.chatting .initial-view {
  display: none !important;
}

#bf-chatbot.chatting .chat-view {
  opacity: 1;
  visibility: visible;
  position: relative;
  max-height: calc(100% - 145px); /* Leave space for the footer container */
  display: flex !important; /* Ensure it's displayed as flex */
  z-index: 10; /* Higher z-index */
  flex: 1;
  flex-direction: column;
  height: 100%;
}

/* Mini profile in chat view */
.chat-mini-profile {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: transparent; /* Remove background to use modal's background */
  border-bottom: none; /* Remove bottom border */
  height: 58px; /* Increased height to accommodate larger profile image */
  box-sizing: border-box;
  margin-top: 35px; /* Add space to avoid overlapping with close button */
  z-index: 15;
}

.mini-profile-image {
  width: 38px; /* Increased by 25% from 30px */
  height: 38px; /* Increased by 25% from 30px */
  border-radius: 50%;
  overflow: hidden;
  margin-right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.mini-profile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.mini-profile-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.mini-profile-title {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
}

/* Toggle visibility */
.chatbot-modal {
  display: flex !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Hidden state - single definition */
.hidden.chatbot-modal {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Chatlog content wrapper */
.chatlog-content-wrapper {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  padding-bottom: 60px !important; /* Increased padding to provide more space at the bottom */
  padding-top: 10px !important; /* Reduced top padding */
  -webkit-overflow-scrolling: touch;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent !important;
  height: calc(100% - 58px) !important; /* Updated to match new mini profile height */
  margin-bottom: 0;
  padding-right: 4px;
  mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}

/* Chat area */
#chatlog {
  padding: 0 20px;
  font-size: 14px;
  background: transparent;
  color: #fff;
  width: 100%;
  min-height: 100px;
  flex: 1;
  overflow-y: visible;
  margin-top: 5px; /* Add some space at the top */
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
}

/* Message bubbles */
#chatlog div {
  margin-bottom: 14px;
  max-width: 80%; /* Reduced max-width to prevent covering close button */
  padding: 12px 16px;
  border-radius: 18px;
  background: #fff;
  color: #000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  display: inline-block; /* Ensure proper display */
  width: auto; /* Allow natural width */
  opacity: 1;
  animation: fadeIn 0.3s ease-in-out;
}

/* Make sure the last message has extra margin */
#chatlog div:last-child {
  margin-bottom: 20px; /* Extra margin for the final message */
}

#chatlog div b {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #333;
}

#chatlog div:after {
  content: "";
  display: table;
  clear: both;
}

.user-msg {
  background: #fff !important;
  align-self: flex-end;
  margin-left: auto;
  float: right; /* Ensure it's aligned right */
  clear: both; /* Clear previous messages */
  border-bottom-right-radius: 3px !important; /* Sharp corner on bottom right */
}

.bot-msg {
  background: #fff !important;
  margin-right: auto;
  float: left; /* Ensure it's aligned left */
  clear: both; /* Clear previous messages */
  border-bottom-left-radius: 3px !important; /* Sharp corner on bottom left */
  opacity: 1 !important;
  visibility: visible !important;
  /* Display is controlled by float, removing conflicting display property */
}

.bot-msg.error {
  background: #ffe5e5 !important;
  color: #a00 !important;
}

/* Chat input container */
.chat-input-container {
  padding: 15px 20px 10px;
  position: relative;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  background: transparent;
}

/* Input row */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.25); /* Increased opacity by 25% from 0.2 */
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06); /* Increased opacity by 25% from 0.05 */
}

/* Message input field */
#userInput {
  flex: 1;
  padding: 12px 20px;
  border-radius: 20px;
  border: none;
  background: rgba(255, 255, 255, 0.03);
  font-size: 15px;
  outline: none;
  color: white;
  height: 44px;
  box-sizing: border-box;
  font-family: inherit;
  transition: all 0.2s ease-in-out;
}

#userInput:focus {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

#userInput::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Send button */
.send-btn {
  background: var(--bf-main-color) !important;
  color: white !important;
  border: none !important;
  padding: 12px 24px !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.send-btn:hover {
  background: var(--bf-main-dark) !important;
}

/* Send button */
#bf-chatbot button {
  padding: 12px 24px;
  border-radius: 20px;
  background: linear-gradient(
    135deg,
    var(--bf-main-color) 0%,
    var(--bf-main-dark) 100%
  );
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: none;
  height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 101; /* Match the input z-index */
}

#bf-chatbot button:hover {
  filter: brightness(0.9);
  transform: translateY(-1px);
}

/* Floating launcher icon */
#chat-launcher {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(
    135deg,
    var(--bf-main-color) 0%,
    var(--bf-main-dark) 100%
  );
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  padding: 0;
  overflow: hidden;
}

#chat-launcher svg {
  width: 28px;
  height: 28px;
}

#chat-launcher .custom-widget-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#chat-launcher.has-custom-icon {
  width: auto;
  max-width: 300px;
  height: auto;
  max-height: 100px;
  border-radius: 12px;
  padding: 0;
  background: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

#chat-launcher:hover {
  filter: brightness(0.9);
  transform: translateY(-2px);
}

/* Footer text */
.bf-chatbot-disclaimer {
  font-size: 11px;
  text-align: center;
  line-height: 1.4;
  padding: 5px 20px;
  user-select: none;
  pointer-events: none;
  z-index: 6;
  margin: 5px 0;
  width: 100%;
  color: rgba(255, 255, 255, 0.75);
  box-sizing: border-box;
  background: transparent;
}

.bf-chatbot-footer {
  font-size: 10px;
  text-align: center;
  line-height: 1.4;
  padding: 5px 20px 15px;
  user-select: none;
  z-index: 6;
  font-weight: 500;
  letter-spacing: 0.5px;
  width: 100%;
  color: rgba(255, 255, 255, 0.65);
  box-sizing: border-box;
  background: transparent;
}

/* Profile container */
.bf-profile-container {
  position: static;
  text-align: center;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
  padding-top: 20px;
  padding-bottom: 10px;
  background: none;
}

.bf-profile-image {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
}

.bf-profile-name {
  color: #fff;
  font-weight: 600;
  margin-top: 10px;
  font-size: 16px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.bf-profile-title {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  margin-top: 4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Profile image shifting when chat starts */
.chat-active .bf-profile-container {
  transform: scale(0.8) translateY(-15px);
  top: 25px;
}

.chat-active .bf-profile-image {
  width: 50px;
  height: 50px;
}

/* Initial View Styles */
.initial-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  max-height: calc(100% - 145px); /* Leave space for the footer container */
  overflow-y: auto; /* Add scrolling capability */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  padding-bottom: 15px; /* Add bottom padding for better spacing */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.bf-chatbot-suggested {
  padding: 10px 20px 15px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  max-width: 400px;
  width: 100%;
  margin-top: 5px;
  margin-bottom: 20px; /* Add bottom margin for better spacing */
  box-sizing: border-box;
}

/* This duplicate styling has been removed to avoid conflicts */

/* Removed duplicate styling */

/* Footer Elements */
.bf-chatbot-disclaimer,
.bf-chatbot-footer {
  text-align: center;
  box-sizing: border-box;
  z-index: 5;
}

.bf-footer-highlight {
  color: #fff;
  font-weight: 600;
  opacity: 1;
}

/* Header buttons */
.chatbot-header-buttons {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 8px; /* Reduced from 10px */
  z-index: 1001; /* Higher z-index to appear above chat content */
}

.chatbot-header-buttons button {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border: none !important;
  background: rgba(255, 255, 255, 0.125) !important; /* Increased opacity by 25% from 0.1 */
  border-radius: 8px !important;
  cursor: pointer;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important; /* Added shadow for better visibility */
}

.chatbot-header-buttons button:hover {
  background: rgba(255, 255, 255, 0.25) !important; /* Increased opacity by 25% from 0.2 */
  transform: translateY(0) !important;
}

/* Make sure close button is extra-visible */
.chatbot-close {
  background: rgba(255, 255, 255, 0.19) !important; /* Increased opacity by 25% from 0.15 */
  margin-right: 5px; /* Add extra space to the right */
}

/* Fullscreen toggle button styles */
.chatbot-fullscreen {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border: none !important;
  background: rgba(255, 255, 255, 0.19) !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease !important;
  color: white !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

.chatbot-fullscreen:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

.chatbot-fullscreen svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.fullscreen .chatbot-fullscreen svg {
  transform: rotate(180deg);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}