/* style.css */

/* Styles de base */
body {
  margin: 0;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background-color: #fafafa;
  height: 100vh;
  /* Le body prend 100% de la hauteur de la vue */
  font-size: min(5vw, 18px);
}

main {
  height: 100vh;
  /* Le body prend 100% de la hauteur de la vue */
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

/* Conteneur principal du chat */
.chat-container {
  height: 100%;
  /* Le conteneur prend toute la hauteur du body */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Empêche le conteneur de déborder */
}

/* Zone des messages */
.messages-area {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
}

.messages-area::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

/* Style général des messages */
.message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  position: relative;
  animation: fadeIn 0.4s ease-out;
}

.message .message-content {
  padding: 12px 18px;
  border-radius: 18px;
  max-width: 75%;
}

.message-content ul,
.message-content ul li {
  list-style: none;
}

.message .message-content p {
  margin: 0;
  line-height: 1.5;
  list-style: none;
}

.message .message-content a {
  color: #167db8;
}

.message .message-content p:not(:last-child) {
  margin-bottom: 8px;
}

.message-footer {
  display: flex;
  align-items: center;
  gap: 15px;
  position: absolute;
  bottom: -18px;
  font-size: 0.75rem;
  color: #999;
}

.message-actions,
.rate-div {
  display: flex;
  gap: 10px;
}

.message-actions a {
  color: #999;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;

}

.message-actions a:hover,
.rate-div a:hover {
  color: #333;
  text-decoration: underline;
}

.rate-div a,
.rate-div a:hover {
  text-decoration: none;
}

.message-actions a i {
  font-size: 0.8em;
}

/* Message du bot (à gauche) */
.message.bot .avatar {
  width: min(40px, 9vw);
  height: min(40px, 9vw);
  border-radius: 50%;
  margin-right: 15px;
  background-image: url('henrribot.png');
  background-size: cover;
  background-position: center;
}

.message.bot .message-content {
  background-color: #fff;
  color: #333;
  border: 1px solid #ddd
}

.message.bot .message-footer {
  left: 75px;
  /* 40px avatar + 15px margin */
}

/* Message de l'utilisateur (à droite) */
.message.user {
  justify-content: flex-end;
}

.message.user .message-content {
  background-color: #aed9f2;
  color: #333;
}

.message.user .message-footer {
  right: 75px;
  /* 40px avatar + 15px margin */
}

.message.user .avatar {
  width: min(40px, 9vw);
  height: min(40px, 9vw);
  border-radius: 50%;
  margin-left: 15px;
  background-color: #78909c;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(1.2rem, 8vw);
}

/* Zone de saisie */
.input-area {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background-color: #f8f9fa;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.input-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
}

#userInput {
  flex-grow: 1;
  border: 1px solid #ddd;
  background: #fff;
  padding: 12px 54px 12px 20px;
  /* Espace pour le bouton */
  border-radius: 25px;
  font-size: 1rem;
  outline: none;
  height: 50px;
  box-sizing: border-box;
  width: 100%;
}

#userInput:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

#sendBtn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  background-color: #167db8;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sendBtn:hover {
  background-color: #0056b3;
}

/* Animation de vibration pour l'input vide */
.input-area.shake {
  animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Indicateur "en train d'écrire" */
.message.thinking .message-content {
  padding: 15px;
  display: flex;
  align-items: center;
}

.typing-indicator {
  display: flex;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  margin: 0 3px;
  background-color: #b0b0b0;
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

/* On décale l'animation pour chaque point */
.typing-indicator span:nth-child(1) {
  animation-delay: -0.24s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.12s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1.0);
  }
}

/* Animation d'apparition des messages */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

/* Animation d'explosion de smileys */
.smiley-particle {
  position: fixed;
  pointer-events: none;
  font-size: 1.2rem;
  z-index: 10000;
  user-select: none;
  animation: explode 0.8s ease-out forwards;
}

@keyframes explode {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.5) rotate(var(--tr));
    opacity: 0;
  }
}