// src/components/ChatMessage.scss
.chat-message {
  display: flex;
  margin: 1rem 0;
  gap: 0.5rem;
  max-width: 100%;

  .message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    svg {
      width: 24px;
      height: 24px;
    }
  }

  .bot-avatar {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 4px;
    border-radius: 50%;
  }

  .user-avatar {
    background-color: #f5f5f5;
    color: #616161;
    padding: 4px;
    border-radius: 50%;
  }

  .message-content {
    flex: 1;
    max-width: calc(100% - 48px);

    .message-text {
      padding: 0.75rem 1rem;
      border-radius: 1rem;
      word-wrap: break-word;

      p {
        margin: 0;
        line-height: 1.4;
      }

      .chat-contact-form {
        max-width: 100%;
        overflow: hidden;
        border-radius: 8px;
        background: #fff;

        iframe {
          width: 100% !important;
          max-width: 100% !important;
          height: 700px !important;
          border: none;
          overflow-y: auto;
          overflow-x: hidden;
          display: block;

          // Remove iframe border and scrollbars
          border: 0;
          -webkit-overflow-scrolling: touch;
        }
      }

      // Add spacing between message and form
      p + .chat-contact-form {
        margin-top: 12px;
      }
    }

    .message-timestamp {
      font-size: 0.75rem;
      color: #666;
      margin-top: 0.25rem;
    }
  }
}

.bot-message {
  .message-content .message-text {
    background-color: #f8f9fa;
    border-radius: 0 1rem 1rem 1rem;
  }
}

.user-message {
  flex-direction: row-reverse;

  .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;

    .message-text {
      background-color: #e3f2fd;
      color: #1976d2;
      border-radius: 1rem 0 1rem 1rem;
    }
  }
}

// Loading animation for typing indicator
.typing-indicator {
  padding: 0.75rem 1rem;
  background-color: #f8f9fa;
  border-radius: 1rem;
  display: inline-block;
  margin: 1rem 0;
  animation: pulse 1.5s infinite;

  &::after {
    content: "...";
    animation: typing 1.5s infinite;
  }
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

@keyframes typing {
  0% { content: "."; }
  33% { content: ".."; }
  66% { content: "..."; }
  100% { content: "."; }
}

// Responsive adjustments
@media (max-width: 480px) {
  .chat-message {
    margin: 0.5rem 0;

    .message-content {
      max-width: calc(100% - 40px);

      .message-text {
        padding: 0.5rem 0.75rem;
      }
    }
  }
}