/* ═══ CHAT WIDGET ═══════════════════════════════════════════ */

/* Icone flottante */
#chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #C9A84C, #8B6914);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 4px 20px rgba(201,168,76,0.4), 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
}
#chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(201,168,76,0.6), 0 2px 10px rgba(0,0,0,0.5);
}
#chat-fab svg {
  width: 26px;
  height: 26px;
  fill: #1a1200;
}
#chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #E05555;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #0D0D0D;
  animation: chat-pulse 2s infinite;
}
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,85,85,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(224,85,85,0); }
}

/* Fenetre chat */
#chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 360px;
  height: 520px;
  background: #111318;
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 20px;
  display: none;
  flex-direction: column;
  z-index: 8999;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(201,168,76,0.1);
  overflow: hidden;
  animation: chat-slide-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes chat-slide-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#chat-header {
  background: linear-gradient(135deg, #1a1200, #2a1e00);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
#chat-header-title .chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #8B6914);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
#chat-title-text { color: #F2EAD3; font-weight: 700; font-size: 14px; }
#chat-subtitle-text { color: #9A8060; font-size: 11px; margin-top: 1px; }
#chat-close-btn {
  background: rgba(255,255,255,0.06);
  border: none;
  color: #9A8060;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#chat-close-btn:hover { background: rgba(255,255,255,0.12); color: #F2EAD3; }

/* Liste des conversations */
#chat-conversations {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chat-conversations::-webkit-scrollbar { width: 4px; }
#chat-conversations::-webkit-scrollbar-track { background: transparent; }
#chat-conversations::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 2px; }

.chat-conv-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-conv-item:hover { background: rgba(201,168,76,0.08); border-color: rgba(201,168,76,0.25); }
.chat-conv-item.unread { border-color: rgba(201,168,76,0.35); background: rgba(201,168,76,0.06); }
.chat-conv-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2a2000, #1a1200);
  border: 1px solid rgba(201,168,76,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-name { color: #F2EAD3; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-preview { color: #9A8060; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-conv-meta { text-align: right; flex-shrink: 0; }
.chat-conv-time { color: #6A5840; font-size: 10px; }
.chat-conv-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #C9A84C; margin: 4px auto 0;
}

/* Vue conversation individuelle */
#chat-messages-view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
#chat-back-btn {
  background: none; border: none; color: #C9A84C;
  font-size: 13px; cursor: pointer; padding: 10px 16px;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid rgba(201,168,76,0.1);
  flex-shrink: 0;
}
#chat-back-btn:hover { color: #F2EAD3; }
#chat-messages-list {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
#chat-messages-list::-webkit-scrollbar { width: 4px; }
#chat-messages-list::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 2px; }

.chat-msg {
  max-width: 80%; padding: 10px 14px;
  border-radius: 16px; font-size: 13px; line-height: 1.5;
  word-break: break-word;
}
.chat-msg.sent {
  background: linear-gradient(135deg, #C9A84C, #8B6914);
  color: #1a1200; align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.received {
  background: rgba(255,255,255,0.07);
  color: #F2EAD3; align-self: flex-start;
  border: 1px solid rgba(201,168,76,0.1);
  border-bottom-left-radius: 4px;
}
.chat-msg-time { font-size: 10px; opacity: 0.6; margin-top: 4px; }

/* Zone de saisie */
#chat-input-zone {
  padding: 12px 16px;
  border-top: 1px solid rgba(201,168,76,0.15);
  display: flex; gap: 10px; align-items: flex-end;
  flex-shrink: 0;
  background: #111318;
}
#chat-input {
  flex: 1; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 12px; color: #F2EAD3;
  padding: 10px 14px; font-size: 13px;
  resize: none; max-height: 100px; min-height: 40px;
  outline: none; font-family: inherit;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: rgba(201,168,76,0.5); }
#chat-input::placeholder { color: #6A5840; }
#chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #8B6914);
  border: none; cursor: pointer; color: #1a1200;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 0.15s;
}
#chat-send-btn:hover { transform: scale(1.08); }
#chat-send-btn svg { width: 18px; height: 18px; fill: #1a1200; }

/* Nouveau message */
#chat-new-btn {
  margin: 12px; padding: 10px;
  background: rgba(201,168,76,0.08);
  border: 1px dashed rgba(201,168,76,0.3);
  border-radius: 10px; color: #C9A84C;
  font-size: 13px; cursor: pointer; text-align: center;
  transition: background 0.15s;
}
#chat-new-btn:hover { background: rgba(201,168,76,0.15); }

/* Responsive mobile */
@media (max-width: 480px) {
  #chat-window { width: calc(100vw - 32px); right: 16px; bottom: 80px; }
}
