/* === Bouton flottant === */
#chatbot-toggle {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007bff, #00b4ff);
  color: white;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(0,0,0,0.25);
  transition: all 0.3s ease;
  z-index: 9999;
}

#chatbot-toggle:hover {
  transform: scale(1.1) rotate(8deg);
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}

/* === Fenêtre du chatbot === */
#chat-container {
  position: fixed;
  bottom: 50px;
  right: 3px;
  width: 380px;
  height: 540px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === En-tête === */
#chat-header {
  background: linear-gradient(135deg, #007bff, #00b4ff);
  color: #fff;
  padding: 14px;
  text-align: center;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#chat-header span {
  flex: 1;
}

#close-chat {
  position: absolute;
  right: 15px;
  bottom: 30px;
  border: none;
  color: white;
  font-size: 30px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s;
}


/* === Zone de messages === */
#messages {
  flex-grow: 1;
  padding: 18px;
  overflow-y: auto;
  font-size: 15px;
  background: #f5f7fb;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 80%;
  line-height: 1.4em;
  word-wrap: break-word;
  animation: pop 0.25s ease;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* === Messages utilisateur === */
.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #007bff, #00b4ff);
  color: white;
  border-bottom-right-radius: 4px;
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* === Messages bot === */
.bot {
  align-self: flex-start;
  background-color: #e9eef7;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* === Zone de saisie === */
#input-container {
  display: flex;
  border-top: 1px solid #ddd;
  background: #fff;
}

#user-input {
  flex-grow: 1;
  border: none;
  padding: 14px;
  font-size: 15px;
  border-radius: 0 0 0 18px;
  outline: none;
  background: #fafafa;
}

button.send {
  border: none;
  background: linear-gradient(135deg, #007bff, #00b4ff);
  color: white;
  padding: 14px 20px;
  cursor: pointer;
  border-radius: 0 0 18px 0;
  font-weight: 600;
  transition: all 0.3s;
}
button.send:hover {
	color: white !important;
}
button.send:hover {
  background: linear-gradient(135deg, #0062cc, #0096d1);
  transform: scale(1.05);
}

/* === Animation de réflexion du bot === */
.thinking {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #007bff;
  border-radius: 50%;
  margin: 0 3px;
  animation: thinking 1.2s infinite ease-in-out both;
}
.thinking:nth-child(1) { animation-delay: 0s; }
.thinking:nth-child(2) { animation-delay: 0.2s; }
.thinking:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* === Scrollbar personnalisée === */
#messages::-webkit-scrollbar {
  width: 6px;
}
#messages::-webkit-scrollbar-thumb {
  background: #007bff33;
  border-radius: 3px;
}
#messages::-webkit-scrollbar-thumb:hover {
  background: #007bff66;
}

/* === RESPONSIVE === */

/* Écrans moyens (tablettes) */
@media (max-width: 900px) {
  #chat-container {
    width: 340px;
    height: 520px;
    bottom: 19px;
    right: 20px;
  }

  #chatbot-toggle {
    width: 60px;
    height: 60px;
    bottom: 20px;
    right: 20px;
  }
}

/* Écrans petits (smartphones en paysage ou petits laptops) */
@media (max-width: 600px) {
  #chat-container {
    width: 90vw;        /* Largeur relative à l'écran */
    height: 70vh;       /* Hauteur relative à l'écran */
    bottom: 90px;       /* On le remonte plus */
    right: 5vw;
    border-radius: 14px;
  }

  #messages {
    padding: 14px;
    font-size: 14px;
  }

  #user-input {
    font-size: 14px;
    padding: 12px;
  }

  button.send {
    padding: 12px 16px;
    font-size: 14px;
  }

  #chatbot-toggle {
    width: 55px;
    height: 55px;
    font-size: 22px;
    bottom: 20px;
    right: 20px;
  }
}

/* Très petits écrans / Smartphones portrait */
@media (max-width: 420px) {
  #chat-container {
    width: 90vw;        /* Largeur relative à l'écran */
    height: 70vh;       /* Hauteur relative à l'écran */
    bottom: 90px;       /* On le remonte plus */
    right: 5vw;
    border-radius: 18px;
  }

  #chat-header {
    padding: 12px;
    font-size: 16px;
  }

  #messages {
    padding: 12px;
    gap: 8px;
  }

  .message {
    font-size: 14px;
    padding: 8px 12px;
  }

  #user-input {
    padding: 12px;
  }

  button.send {
    padding: 12px 16px;
  }
}

/* Mode paysage smartphone très petit */
@media (max-height: 450px) {
  #chat-container {
    height: 90vh;
  }
}
