/* Import Roboto */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap');

/* Color Variables */
:root {
  --primary-color: #003366; /* TPA Deep Blue */
  --secondary-color: #e6f0fa; /* TPA Light Blue */
  --accent-color: #198754; /* Success/Resolve button */
  --bubble-user: #e1f0ff;
  --bubble-agent: #f4f4f4;
  --text-dark: #1c1e21;
  --border-color: #dee2e6;
}

/* Global Styles */
body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--secondary-color);
  color: var(--text-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top-logo {
  margin-top: 20px;
}
.top-logo img {
  height: 50px;
}

/* Chat container */
.chat-container {
  width: 95%;
  max-width: 600px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  height: 80vh;
  overflow: hidden;
}

/* Header */
.chat-header {
  background-color: var(--primary-color);
  color: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

/* Resolve Button */
.resolve-btn {
  background-color: var(--accent-color);
  border: none;
  color: white;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.resolve-btn:hover {
  background-color: #157347;
}

/* Messages Area */
.chat-messages {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Message Bubble */
.message-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 20px;
  margin-bottom: 10px;
  line-height: 1.4;
  word-wrap: break-word; /* Prevents long words from overflowing */
  font-size: 14px;
  position: relative;
  align-self: flex-start;
  opacity: 0; /* Start with the message invisible */
  transform: translateY(20px); /* Start it off-screen, below its final position */
  animation: slide-up 0.5s ease-out forwards; /* Apply the animation */
  /* Removed box-shadow and transition as requested */
}

/* Specific styling for Bot messages */
.message-bubble.bot {
    background-color: #f0f0f0; /* Light gray for bot messages */
    color: #333;
    border-bottom-left-radius: 2px;
    margin-right: auto; /* Pushes the bot bubble to the left */
    align-self: flex-start; /* Corrected to align to the left */
}

/* Specific styling for User messages */
.message-bubble.user {
  background-color: var(--bubble-user);
  align-self: flex-end;
  border-bottom-left-radius: 6px;
  margin-left: auto;
}

/* Specific styling for Agent messages */
.message-bubble.agent {
  background-color: var(--bubble-agent);
  align-self: flex-start; /* Corrected to align to the left */
  border-bottom-right-radius: 6px;
}

/* Bubble Arrows */
.message-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
}

.message-bubble.user::after {
  right: -10px;
  border-width: 10px 0 0 10px;
  border-style: solid;
  border-color: transparent transparent transparent var(--bubble-user);
}

.message-bubble.agent::after {
  left: -10px;
  border-width: 10px 10px 0 0;
  border-style: solid;
  border-color: var(--bubble-agent) transparent transparent transparent;
}

/* A subtle styling for the typing indicator bubble */
.message-bubble.typing-indicator {
    background-color: #e0e0e0;
    font-style: italic;
    color: #666;
    padding: 8px 16px;
    display: inline-flex; /* Aligns the text and gif */
    align-items: center;
    gap: 8px; /* Adds space between text and gif */
}

.message-text {
  text-align: justify;
}
.typing-indicator .message-text {
  font-style: italic;
  opacity: 0.7;
}

/* Input Area */
.chat-input-area {
  display: flex;
  padding: 15px;
  background-color: #f8f9fa;
  border-top: 1px solid var(--border-color);
  gap: 12px;
}

.chat-input-area input {
  flex: 1;
  padding: 12px 18px;
  border-radius: 25px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
  outline: none;
  background: #fff;
}

.chat-input-area button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 18px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.chat-input-area button:hover {
  background-color: #00254d;
}

/* Floating Message Animation */
@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Apply animation to floating bubbles */
.floating-bubble {
    animation: floatUp 0.8s ease-out forwards; /* Increased duration for smoother flow */
}

.floating-bubble.second {
    animation-delay: 0.3s; /* Adjusted delay for a better staggered effect */
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    width: 95%;
    height: 90vh;
  }

  .chat-header h2 {
    font-size: 1rem;
  }

  .chat-input-area input {
    font-size: 0.95rem;
  }
}

/* This is the container for the messages you want to animate */
#chat-window .message {
  opacity: 0;
  transform: translateY(20px); /* Adjust this value to control how far they start below their final position */
  animation: slide-up 0.5s ease-out forwards;
}

/* This is the first message to animate */
#chat-window .message:nth-child(1) {
  animation-delay: 0s;
}

/* This is the second message to animate */
#chat-window .message:nth-child(2) {
  animation-delay: 0.3s;
}

.slide-element {
  animation: slide-up 0.5s ease-out forwards;
}

@keyframes slide-up {
  from {
    opacity: 1;
    transform: translateY(250px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-messages {
  animation-name: slide-up;
  animation-duration: 0.5s; /* You can adjust this for speed */
  animation-timing-function: ease-out; /* This is the key change */
  animation-fill-mode: forwards;
}
