/* Block specific styles */
.acf-block-caij-info-chat {
  position: fixed; /* Changed from relative for the bubble to float */
  bottom: 0; /* Aligns the block container to the bottom for bubble positioning */
  right: 0; /* Aligns the block container to the right for bubble positioning */
  z-index: 9999;
}

.caij-chat-bubble {
  position: fixed; /* Ensures it floats over content */
  width: 64px;
  height: 64px;
  background-color: var(--wp--preset--color--secondary);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  /* Animation properties */
  bottom: 0; /* Start position for animation */
  opacity: 0; /* Start opacity for animation */
  animation-name: messenger-button-shown-frames;
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.62, 0.28, 0.23, 0.99);
  animation-fill-mode: both; /* Keeps the final state of the animation */
}

.caij-chat-bubble svg {
  color: white;
  width: 32px; /* Adjust as needed */
  height: 32px; /* Adjust as needed */
}

/* Animation keyframes for the bubble */
@keyframes messenger-button-shown-frames {
  0% {
    bottom: 0;
    opacity: 0;
  }
  1% {
    /* Small step to ensure smooth start if issues with 0% scaling */
    bottom: 0;
    opacity: 0.5;
  }
  100% {
    bottom: 30px; /* Final position from bottom */
    right: 20px; /* Final position from right - added for consistency */
    opacity: 1;
  }
}

/* New animation for bubble reappearing */
@keyframes messenger-button-reappear-frames {
  0% {
    bottom: 0;
    opacity: 0;
  }
  100% {
    bottom: 30px; /* Final position from bottom */
    opacity: 1;
  }
}

.caij-chat-bubble.hidden {
  display: none;
}

.caij-chat-bubble.reappearing {
  display: flex; /* Or whatever its default display is */
  animation-name: messenger-button-reappear-frames;
  animation-duration: 0s; /* Adjust as needed */
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
  /* Reset other animation properties if they conflict */
  opacity: 0; /* Start animation from 0 opacity */
  bottom: 10px; /* Start animation from 10px bottom */
}

.caij-chat-window {
  position: fixed;
  bottom: 30px; /* Position above the bubble */
  right: 20px;
  width: 100%;
  max-width: 404px; /* Max width as specified */
  height: 554px; /* Height as specified */
  background-color: #f9f9f9; /* Light background for the chat window */
  display: none; /* Initially hidden */
  flex-direction: column;
  overflow: hidden;
  /* Animation for appearing - using 'backwards' to apply 0% state before animation */
  animation-fill-mode: backwards;
  z-index: 999999; /* High z-index */
  /* Default styles before animation for appearance */
  opacity: 0;
  transform: scale(0.8); /* Start slightly smaller for a pop-in effect */
  transform-origin: bottom right; /* Animation originates from where the button is */
}

.caij-chat-window.visible {
  display: flex; /* Use flex when visible */
  animation-name: chat-window-appear;
  animation-duration: 0.3s;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards; /* Keep the final state (visible) */
}

@keyframes chat-window-appear {
  0% {
    opacity: 0;
    transform: scale(0.1) translateY(20px); /* Start smaller and slightly down */
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0); /* End at full size and original position */
  }
}

@keyframes chat-window-disappear {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0); /* End at full size and original position */
  }
  100% {
    opacity: 0;
    transform: scale(0.1) translateY(20px); /* Start smaller and slightly down */
  }
}

/* Placeholder for the white div you mentioned for text content */
#chat-content-area {
  min-height: 100px; /* As requested */
  flex-grow: 1; /* Allows this area to take available space */
  overflow-y: auto; /* Add scroll if content overflows */
}

/* Basic styling for header and footer for completeness */
.caij-chat-window-header {
  padding: 10px;
  background-color: var(
    --wp--preset--color--secondary
  ); /* Match bubble color */
  color: white;
  border-bottom: 1px solid #ccc;
  text-align: center;
  display: flex; /* To align title and button */
  justify-content: space-between; /* Puts title left, button right */
  align-items: center; /* Vertically aligns items */
}

.caij-chat-window-body {
  flex-shrink: 1;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
}

.caij-chat-window-footer {
  padding: 10px;
  background-color: #fff;
}
.caij-chat-window-footer-button {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  padding: 10px 20px;
  background-color: var(--wp--preset--color--primary);
  color: white;
  border-radius: 8px;
  font-family: var(--wp--preset--font-family--primary);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  text-decoration: none;
}

/* Style for the close button */
.caij-chat-window-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px; /* Larger click target */
  cursor: pointer;
  padding: 0 5px; /* Add some padding for easier clicking */
  line-height: 1; /* Ensure proper vertical alignment */
}

.caij-chat-window-close:hover {
  opacity: 0.8;
}

.caij-chat-message-content {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}

.caij-chat-message-content-text {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.caij-chat-message-content-bubble {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 15px;
  background-color: #f4f6f8;
  border-radius: 20px;
  font-size: 14px;
}
.caij-chat-message-content-bubble-Title {
  font-weight: 600;
}

.caij-chat-message-time {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #666;
  opacity: 0.5;
  margin: 20px 0;
}
.caij-chat-message-content-author {
  display: flex;
  justify-content: start;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #666;
  opacity: 0.5;
}
.caij-chat-message-content-author {
  margin-left: 10px;
}

.caij-chat-question {
  display: flex;
  align-items: end;
  width: 100%;
  flex-direction: column;
  gap: 10px;
}

.caij-chat-question-button {
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  background-color: transparent;
  border: 1px solid var(--wp--preset--color--secondary);
  border-radius: 20px;
  color: #000;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

.caij-chat-question-button:hover {
  color: var(--wp--preset--color--secondary);
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .caij-chat-window {
    width: calc(100% - 20px); /* Near full width on small screens */
    max-width: none;
    height: 70vh; /* Adjust height for mobile */
    bottom: 20px; /* Adjust position based on new bubble position */
    right: 10px;
    left: 10px;
  }

  .caij-chat-bubble {
    bottom: 10px;
    right: 10px;
  }

  @keyframes messenger-button-shown-frames {
    0% {
      bottom: 0;
      opacity: 0;
      transform: scale(0);
    }
    1% {
      bottom: 0;
      opacity: 0;
      transform: scale(0.1);
    }
    100% {
      bottom: 10px; /* Adjusted for mobile */
      right: 10px; /* Adjusted for mobile */
      opacity: 1;
      transform: scale(1);
    }
  }
}
