/* === Chat menu === */
#chatMenu {
  height: 100%;
  width: 0;
  max-width: 320px;
  position: fixed;
  top: 0;
  right: 0;
  background: rgba(0,0,50,0.95);
  overflow: hidden;
  transition: width 0.5s;
  display: flex;
  flex-direction: column;
  z-index: 10000;
  box-sizing: border-box;
  padding-top: 60px; /* espace pour bouton chat */
}

/* Messages */
#chatMessages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 5px;
  padding: 10px;
  scroll-behavior: smooth;
}

.msg {
  margin-bottom: 5px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #fff;
  text-shadow: 0 0 2px rgba(0,255,255,0.2);
}
.msg:hover {
  text-shadow: 0 0 8px cyan,0 0 15px cyan,0 0 25px cyan;
}
.msg.new-message {
  animation: glowNew 1s ease forwards;
}
@keyframes glowNew {
  0% { background-color: rgba(0,255,255,0.3); }
  50% { background-color: rgba(0,255,255,0.1); }
  100% { background-color: transparent; }
}
.msg strong {
  text-shadow: 0 0 5px cyan,0 0 10px cyan,0 0 15px cyan;
}

/* Header pseudo/date */
.msg-header {
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}
.msg-body {
  padding-left: 5px;
  word-wrap: break-word;
}

/* Date / heure */
.time {
  font-size: 0.85rem;
  text-shadow: 0 0 5px cyan;
}
.pulse-neon {
  font-size: 0.85em;
  color: hsl(var(--base-hue), 100%, 65%);
  text-shadow:
    0 0 3px hsl(var(--base-hue), 100%, 65%),
    0 0 8px hsl(var(--base-hue), 100%, 65%),
    0 0 12px hsl(var(--base-hue), 100%, 65%);
  animation: neonPulse 2s infinite alternate;
}
@keyframes neonPulse {
  0% {
    color: hsl(var(--base-hue),100%,50%);
    text-shadow:0 0 2px hsl(var(--base-hue),100%,50%),0 0 5px hsl(var(--base-hue),100%,50%),0 0 10px hsl(var(--base-hue),100%,50%);
  }
  50% {
    color: hsl(calc(var(--base-hue)+30),100%,65%);
    text-shadow:0 0 4px hsl(calc(var(--base-hue)+30),100%,65%),0 0 10px hsl(calc(var(--base-hue)+30),100%,65%),0 0 20px hsl(calc(var(--base-hue)+30),100%,65%);
  }
  100% {
    color: hsl(var(--base-hue),100%,70%);
    text-shadow:0 0 3px hsl(var(--base-hue),100%,70%),0 0 8px hsl(var(--base-hue),100%,70%),0 0 12px hsl(var(--base-hue),100%,70%);
  }
}

/* Input et bouton envoyer */
#chatInput {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  padding: 5px;
}
#chatInput input {
  flex: 1;
  padding: 10px;
  border-radius: 10px 0 0 10px;
  border: none;
  outline: none;
}
#chatInput button {
  padding: 10px 15px;
  border: none;
  border-radius: 0 10px 10px 0;
  background: cyan;
  cursor: pointer;
  transition: 0.3s;
}
#chatInput button:hover {
  box-shadow: 0 0 15px cyan;
}

#openChatBtn {
  position: fixed;
  top: 10px;
  right: 20px;
  background: cyan;
  color: black;
  padding: 10px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  z-index: 10001;
  box-shadow: 0 0 15px cyan;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

/* Badge compteur façon WhatsApp */
#openChatBtn::after {
    content: attr(data-unread);
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: red;
    color: white;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    pointer-events: none;
    opacity: 0; /* caché si pas de message */
    transition: opacity 0.2s ease;
}

#openChatBtn.new-message::after {
    opacity: 1;
}

#openChatBtn:hover {
  box-shadow: 0 0 25px cyan;
}

#openChatBtn:active {
  transform: scale(0.9); /* rétrécit un peu au clic */
  box-shadow: 0 0 35px cyan; /* glow plus intense */
}

/* --- Chat Emoji Picker --- */
#chatEmojiPickerContainer {
  max-height: 120px;
  overflow-y: auto;
  padding: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  display: block;  /* Assurez-vous que l'élément est bien visible */
}

#chatEmojiPicker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); /* Alignement en grille */
  gap: 5px;
  width: 100%;
}

.chat-emoji {
  font-size: 1.5em;
  cursor: pointer;
  text-align: center;
  margin: 2px;
  transition: transform 0.2s, text-shadow 0.3s;
}

.chat-emoji:hover {
  transform: scale(1.4);  /* Zoom sur hover */
  text-shadow: 0 0 5px cyan, 0 0 10px cyan, 0 0 15px cyan;
}

/* === Responsive mobile === */
@media(max-width: 480px){
  #chatMenu { max-width: 100%; padding-top: 70px; }
  #openChatBtn { padding: 8px 12px; font-size: 0.9rem; }
  #chatInput input { padding: 8px; font-size: 0.9rem; }
  #chatInput button { padding: 8px 12px; font-size: 0.9rem; }
  .chat-emoji { font-size: 1.3em; }
  .time { font-size: 0.75rem; }
}

#changePseudoBtn {
  background: linear-gradient(45deg, #d3d3d3, #eaeaea);
  color: #333;
  font-weight: bold;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  margin: 5px auto;
  cursor: pointer;
  text-shadow: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  display: block;
}

#changePseudoBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

#changePseudoBtn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.hidden {
  display: none;
}

/* Effet quand nouveau message non lu */
#openChatBtn.new-message {
  animation: chatPulse 1s infinite alternate;
}

@keyframes chatPulse {
  0% {
    background: cyan;
    box-shadow: 0 0 10px cyan;
  }
  50% {
    background: magenta;
    box-shadow: 0 0 20px magenta;
  }
  100% {
    background: lime;
    box-shadow: 0 0 25px lime;
  }
}

/* Style du bouton du chat */
#sendBtn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s ease;
}

#sendBtn:hover {
    background-color: #218838;
}

/* Style du bouton désactivé */
#sendBtn.disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Style du message d'erreur */
#chatErrorMessage {
    display: none;
    color: red;
    font-weight: bold;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 5px;
    margin-top: 10px;
}


/* Message d'erreur pour les invités */
.invite-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.8);  /* Fond rouge pour l'alerte */
    color: white;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.2rem;
    z-index: 10000;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    display: none;  /* Initialement caché */
    text-align: center;
}

.invite-message.show {
    display: block;  /* Afficher le message */
    animation: fadeInOut 5s ease forwards;  /* Animer pour disparaître après un certain temps */
}

@keyframes fadeInOut {
    0% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; }
}
.chat-link {
  color: #29c9ff;
  position: relative;
  text-decoration: none; /* On retire le soulignement par défaut */
  animation: pulse 2s infinite; /* Animation de pulse */
}

/* Animation pulse */
@keyframes pulse {
  0% {
    transform: scale(1); /* Taille normale */
  }
  50% {
    transform: scale(1.05); /* Légère expansion */
  }
  100% {
    transform: scale(1); /* Retour à la taille normale */
  }
}

.chat-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px; /* Distance sous le texte */
  width: 0;
  height: 2px;
  background: #29c9ff;
  transition: all 0.6s ease;
}

.chat-link:hover::after,
.chat-link:active::after {
  animation: underline 1s ease infinite; /* Animation à appliquer */
}

/* Animation de soulignement */
@keyframes underline {
  0% {
    width: 0;
    left: 0;
  }
  50% {
    width: 100%;
    left: 0;
  }
  100% {
    width: 0;
    left: 100%;
  }
}
