/* Body Styling */
body {
  font-family: "Comic Sans MS", sans-serif;
  background: #eafaf1;
  margin: 0;
  padding: 0;
  color: #2e2e2e;
}

/* Chat Container */
#chat-container {
  width: 600px;
  margin: 40px auto;
  background: #ffffffee;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  padding: 12px;
  background-color: #4CAF50;
  color: white;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
}

/* Message Area */
#messages {
  flex-grow: 1;
  height: 400px;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid #ddd;
}

/* Message Alignment Containers */
.message-container {
  display: flex;
  width: 100%;
}

.message-container.left {
  justify-content: flex-start;
}

.message-container.right {
  justify-content: flex-end;
}

/* Message Bubbles */
.my-message,
.other-message {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  line-height: 1.5;
  position: relative;
}

.my-message {
  background-color: #dcf8c6;
}

.other-message {
  background-color: #f1f0f0;
}

/* Timestamp inside bubble */
.timestamp {
  font-size: 12px;
  color: #888;
  text-align: right;
  margin-top: 4px;
  display: block;
}

/* Typing Indicator */
#typing-indicator {
  font-size: 14px;
  font-style: italic;
  color: #555;
  padding: 8px 15px;
  height: 20px;
}

/* Input Area */
#input-area {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid #eee;
  background-color: #ffffff;
}

#messageInput,
#gifInput {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

/* Buttons */
#sendBtn,
#gifBtn {
  padding: 10px 16px;
  font-size: 16px;
  border: none;
  background-color: #81c784;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s ease;
}

#sendBtn:hover,
#gifBtn:hover {
  background-color: #66bb6a;
}

/* GIF Result Area */
#gifResults {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid #eee;
}

#gifResults img {
  cursor: pointer;
  max-width: 150px;
  border-radius: 8px;
  transition: transform 0.2s;
}

#gifResults img:hover {
  transform: scale(1.05);
}

/* Login / Register Form Container */
.form-container {
  max-width: 400px;
  margin: 80px auto;
  padding: 30px;
  background-color: white;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.form-container h2 {
  margin-bottom: 16px;
  color: #2e2e2e;
  font-weight: 600;
}

.form-container p {
  margin-bottom: 20px;
  color: #444;
  font-size: 15px;
}

.form-container input[type="text"],
.form-container input[type="password"] {
  width: 100%;
  padding: 12px;
  margin: 12px 0;
  font-size: 16px;
  border: 1.5px solid #dcdcdc;
  border-radius: 10px;
  box-sizing: border-box;
  background-color: #fdfdfd;
}

.form-container input:focus {
  border-color: #81c784;
  outline: none;
  box-shadow: 0 0 5px #a5d6a7;
}

.form-container button {
  width: 100%;
  padding: 12px;
  background-color: #81c784;
  color: white;
  border: none;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 10px;
  font-weight: 600;
  transition: background-color 0.3s ease;
}

.form-container button:hover {
  background-color: #66bb6a;
}

.form-container a {
  display: block;
  margin-top: 15px;
  color: #388e3c;
  text-decoration: none;
  font-size: 14px;
}

/* Animations */
.message {
  animation: fadeIn 0.3s ease-in-out;
}

.message-wrapper {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing Indicator Bubble */
#typingIndicator {
  font-style: italic;
  color: #555;
  padding: 8px 14px;
  font-size: 14px;
  max-width: 200px;
  background-color: #f1f0f0;
  border-radius: 14px;
  margin: 8px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: inline-block;
}

.typing-indicator::after {
  content: '...';
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* Responsive */
@media screen and (max-width: 600px) {
  #chat-container {
    width: 100%;
    border-radius: 0;
    margin: 0;
  }

  #gifResults img {
    max-width: 100px;
  }

  #input-area {
    flex-direction: column;
    gap: 5px;
  }

  #messageInput,
  #gifInput {
    width: 100%;
  }
}

/* Dark Mode (Only for Chat) */
body.dark-mode {
  background: #1e1e1e;
  color: #f5f5f5;
}

.dark-mode #chat-container {
  background: #2c2c2c;
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

.dark-mode #messages {
  border-bottom: 1px solid #444;
}

.dark-mode .my-message {
  background-color: #81b583;
  color: white;
}

.dark-mode .other-message {
  background-color: #444;
  color: #eee;
}

.dark-mode .timestamp {
  color: #0f0d1c;
}

.dark-mode #messageInput,
.dark-mode #gifInput {
  background-color: #555;
  color: white;
  border: 1px solid #777;
}

.dark-mode #sendBtn,
.dark-mode #gifBtn {
  background-color: #4caf50;
  color: white;
}

.dark-mode #sendBtn:hover,
.dark-mode #gifBtn:hover {
  background-color: #66bb6a;
}

.dark-mode #gifResults img {
  border: 2px solid #777;
}