/* Chat Container styling matching docs-container */
.chat-container {
  position: relative;
  z-index: 5;
  /* Reduced the top margin from 80px to 30px */
  margin: 80px auto 20px auto; 
  /* Reduced overall width from 90% to 70% */
  width: 90%;
  max-width: 1400px;
  /* Reduced padding from 40px to 20px */
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 15px;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

/* Subtle animated background for visual effect */
.chat-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(to right, transparent, transparent 10px, rgba(0,255,255,0.2) 11px, transparent 12px),
    repeating-linear-gradient(to bottom, transparent, transparent 10px, rgba(0,255,255,0.2) 11px, transparent 12px);
  background-blend-mode: screen;
  animation: flow 10s linear infinite;
  pointer-events: none;
  z-index: -1;
  opacity: 0.3;
}

/* Title */
.chat-container h1 {
  text-align: center;
  /* Reduced margin-bottom from 30px to 15px */
  margin-bottom: 15px;
  color: #00ffff;
  text-shadow: 0 0 10px #00ffff;
  /* Reduced font-size from 2rem to 1.6rem */
  font-size: 1.6rem; 
  font-weight: 700;
}

/* Chat Output */
.chat-output {
  flex-grow: 1;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 0 15px rgba(0, 255, 255, 0.3);
}

/* User & AI Messages */
.chat-output .chat-message {
  padding: 14px 20px;
  border-radius: 20px;
  font-size: 1.2rem;
  max-width: 80%;
  margin: 8px 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.chat-output .chat-message.user {
  align-self: flex-end;
  background-color: #ffffff;
  color: #000;
  border: 2px solid #00aaff;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
  border-radius: 25px;
}

.chat-output .chat-message.ai {
  align-self: flex-start;
  background-color: #f0f0f0;
  color: #333;
  border: 2px solid #ff4081;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
  border-radius: 25px;
  max-width: 90%;         
  font-size: 1.3rem;      
}

/* Loading Indicator - Enhanced Visibility */
.chat-output .chat-message.loading {
  align-self: center;
  font-size: 1.3rem;
  font-weight: bold;
  color: #00ffff;
  background: none;
  border: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading Animation - Pulsing Dots */
.chat-output .chat-message.loading::after {
  content: "⏳";
  font-size: 1.8rem;
  margin-left: 10px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0.3; transform: scale(1); }
}

/* Chat Form Layout: input on top, buttons below */
#chat-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

#chat-input {
  flex-grow: 1;
  padding: 16px;
  border: none;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: background 0.3s ease;
}

#chat-input:focus {
  background: rgba(255, 255, 255, 0.3);
}

/* Button Container: holds the Send and Clear Conversation buttons */
.button-container {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Shared Button Styles with Bigger Fonts */
#chat-form button {
  padding: 14px 28px;
  border: none;
  border-radius: 25px;
  background: linear-gradient(45deg, #00ffff, #0077ff);
  color: #fff;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chat-form button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* Specific style for the Clear Conversation Button */
#clear-chat {
  background: linear-gradient(45deg, #ff4d4d, #ff1a1a);
}

#clear-chat:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

.clear-chat-toggle {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #00ffff;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
}

.clear-chat-toggle input[type="checkbox"] {
  transform: scale(1.2);
  accent-color: #00ffff;
  cursor: pointer;
  margin-right: 6px;
}

.clear-chat-toggle label {
  color: #00ffff; /* Neon blue */
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

#clear-chat {
  background: linear-gradient(45deg, #ff4d4d, #ff1a1a);
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
  display: none; /* hidden by default */
  cursor: pointer;
  transition: all 0.3s ease-in-out;
}

#clear-chat:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

/* ===============================
   RESPONSIVE ADJUSTMENTS (Chat Page)
============================== */

/* Adjustments for tablets and small desktops */
@media only screen and (max-width: 768px) {
  .chat-container {
    margin: 30px auto 20px auto;
    width: 90%;
    padding: 20px;
  }

  .chat-output {
    max-height: 50vh;
    padding: 12px;
    font-size: 1rem;
  }

  #chat-form {
    gap: 10px;
  }
  
  #chat-input {
    padding: 12px;
    font-size: 0.9rem;
  }

  .button-container {
    gap: 10px;
  }
  
  .button-container button {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
}

/* Adjustments for very small screens (e.g., iPhone SE) */
@media only screen and (max-width: 480px) {
  .chat-container {
    margin: 80px auto 10px auto;
    width: 95%;
    padding: 15px;
  }

  .chat-output {
    height: 50vh;
    padding: 10px;
  }

  #chat-input {
    padding: 10px;
    font-size: 0.8rem;
  }

  .button-container {
    gap: 6px;
  }

  .button-container button {
    padding: 10px 16px;
    font-size: 0.8rem;
  }
}