/* === reset / global === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, sans-serif;
  height: 100vh;
  display: flex;
  background: #f3f4f6;
}

/* === layout principal === */
.container {
  flex: 1;
  display: flex;
  overflow: hidden;
}
/* conteneur de chaque chat dans la sidebar */
.chat-item {
  position: relative;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 4px;
  transition: background .2s;
}
.chat-item:hover {
  background: rgba(255,255,255,0.05);
}

/* le bouton ⋮ */
.menu-toggle {
  background: none;
  border: none;
  font-size: 18px;
  color: #ddd;
  cursor: pointer;
}

.retry-btn {
  margin: 10px auto;
  display: block;
  padding: 6px 12px;
  background-color: #6658d3;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}
.retry-btn:hover {
  background-color: #4b3cb8;
}

/* la dropdown cachée */
.dropdown {
  position: absolute;
  top: 100%;
  right: 8px;
  background: #2a2a2a;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  display: none;
  z-index: 10;
}

/* quand on l’ouvre */
.dropdown.show {
  display: block;
}

/* boutons à l’intérieur */
.dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: #eee;
  text-align: left;
  cursor: pointer;
  transition: background .2s;
}
.dropdown button:hover {
  background: #3d3d3d;
}

/* --- Sidebar (gauche) --- */
.sidebar {
  flex: 0 0 250px;
  min-width: 200px;
  background: #1f2937;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}
.sidebar h2 {
  margin-bottom: 1rem;
}
.sidebar ul {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}
.sidebar li {
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .2s;
}
.sidebar li:hover {
  background: #374151;
}
.sidebar > button {
  margin-top: 1rem;
  padding: .75rem 0;
  background: #4f46e5;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
}

/* --- Zone de chat centrée --- */
.chat-area {
  flex: 1;
  display: flex;
  justify-content: center; /* centre horizontalement */
  padding: 20px 0;          /* un peu d’air en haut/bas */
  overflow: hidden;
}

.chat-container {
  width: 100%;
  max-width: 800px; /* largeur max du chat */
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  height: 100%;
  min-height: 0;
}

/* on masque le style par défaut et on centre la flèche */
.send-btn {
  width: 3rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 0 4px 4px 0;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background .2s;
}
.send-btn:disabled {
  background: #999;
  cursor: not-allowed;
}
.send-btn:not(:disabled):hover {
  background: #4338ca;
}

/* --- fenêtre de messages --- */
.chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.chat-message {
  max-width: 90%;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  line-height: 1.5;
  text-align: justify; /* JUSTIFIED */
  white-space: pre-wrap;
}
.chat-message.user {
  align-self: flex-end;
  background: #4f46e5;
  color: #fff;
}
.chat-message.assistant {
  align-self: flex-start;
  background: #fff;
  border-left: 4px solid #4f46e5;
  color: #111;
}
.chat-message ul {
  margin: .5rem 0;
  padding-left: 1.5rem;
}
.chat-message li {
  margin-bottom: .25rem;
}

/* --- formulaire en bas --- */
#chatForm {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  background: #e5e7eb;
  display: flex;
  padding: 10px 20px;
  border-top: 1px solid #ccc;
}
#chatInput {
  flex: 1;
  padding: .75rem 1rem;
  border: 1px solid #ccc;
  border-radius: 4px 0 0 4px;
  font-size: 1rem;
}
#chatForm button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  background: #4f46e5;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  padding: 0;
}
#chatForm button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#chatForm button svg {
  width: 20px;
  height: 20px;
}

/* --- indicateur “réfléchit” --- */
#thinking {
  margin: 8px 0;
  text-align: left;
}
.dots::after {
  content: '';
  animation: dots 1.2s steps(4,end) infinite;
}
@keyframes dots {
  0%,20%   { content: ''; }
  40%      { content: '.'; }
  60%      { content: '..'; }
  80%,100% { content: '...'; }
}

