/* ══════════════ Bulle de messagerie support ══════════════
   Feuille autonome du composant js/chat-widget.js : chargée telle quelle
   sur toutes les pages publiques (accueil, tarifs, communauté, commander).
   Ne contient QUE le chat — rien qui dépende d'une page précise. */

/* ══════════════ Messagerie support ══════════════ */
.chat-widget { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 200; }
.chat-widget.hidden { display: none; }

.chat-fab {
  width: 3.5rem; height: 3.5rem; border-radius: 50%; border: none; cursor: pointer;
  background: #fe8ce3; color: #111; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); position: relative; transition: transform 0.15s ease;
}
.chat-fab:hover { transform: scale(1.06); }
.chat-badge {
  position: absolute; top: -4px; right: -4px; min-width: 1.25rem; height: 1.25rem; padding: 0 0.3rem;
  background: #e11; color: #fff; border-radius: 999px; font-size: 0.72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 2px solid #f4f4f0;
}
.chat-badge.hidden { display: none; }
body.dark-mode .chat-badge { border-color: #111; }

/* `position: fixed` et non `absolute` : le panneau ne depend alors ni de la
   taille de la bulle ni du CSS de la page hote. L'accueil applique un
   `max-width: 100%` global (Tailwind) qui, sur un panneau absolu, l'ecrasait
   a la largeur de la bulle (56 px) — d'ou le `max-width: none`. */
.chat-panel {
  position: fixed; right: 1.25rem; bottom: 5.25rem;
  width: min(22rem, calc(100vw - 2.5rem)); max-width: none;
  height: min(30rem, calc(100vh - 8rem)); background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28); display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
  box-sizing: border-box;
}
/* Le markup interne ne doit rien heriter non plus de la page hote. */
.chat-panel *, .chat-widget * { box-sizing: border-box; max-width: none; }
.chat-messages img.chat-att-img { max-width: 100%; }
.chat-panel.hidden { display: none; }
body.dark-mode .chat-panel { background: #1b1b1b; border-color: rgba(255,255,255,0.1); }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: #fe8ce3; color: #111; font-weight: 800; font-size: 0.95rem;
}
.chat-close { background: none; border: none; font-size: 1rem; cursor: pointer; color: #111; line-height: 1; }

.chat-messages { flex: 1; overflow-y: auto; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.chat-empty { margin: auto; opacity: 0.55; font-size: 0.85rem; text-align: center; padding: 1rem; }

.chat-msg { max-width: 80%; padding: 0.5rem 0.7rem; border-radius: 12px; font-size: 0.88rem; word-wrap: break-word; }
.chat-msg .chat-time { display: block; font-size: 0.66rem; opacity: 0.55; margin-top: 0.2rem; }
.chat-msg.from-user { align-self: flex-end; background: #fe8ce3; color: #111; border-bottom-right-radius: 3px; }
.chat-msg.from-admin { align-self: flex-start; background: #ececec; color: #111; border-bottom-left-radius: 3px; }
body.dark-mode .chat-msg.from-admin { background: #333; color: #f0f0f0; }
.chat-msg img.chat-att-img { max-width: 100%; border-radius: 8px; margin-top: 0.3rem; display: block; cursor: pointer; }
.chat-att-pdf { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.3rem; font-size: 0.82rem; text-decoration: underline; }

.chat-err { padding: 0.4rem 0.85rem; font-size: 0.8rem; color: #c00; }
body.dark-mode .chat-err { color: #ff8080; }
.chat-err.hidden { display: none; }

.chat-filechip {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin: 0 0.85rem; padding: 0.35rem 0.6rem; background: rgba(254,140,227,0.15);
  border-radius: 8px; font-size: 0.78rem;
}
.chat-filechip.hidden { display: none; }
.chat-filechip button { background: none; border: none; cursor: pointer; font-size: 0.85rem; color: inherit; }

.chat-input { display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem; border-top: 1px solid rgba(0,0,0,0.08); }
body.dark-mode .chat-input { border-color: rgba(255,255,255,0.1); }
.chat-attach { cursor: pointer; font-size: 1.2rem; padding: 0 0.2rem; user-select: none; }
.chat-input input[type="text"] {
  flex: 1; border: 1px solid rgba(0,0,0,0.15); border-radius: 999px; padding: 0.5rem 0.85rem;
  font-size: 0.88rem; background: #fff; color: #111; min-width: 0;
}
body.dark-mode .chat-input input[type="text"] { background: #262626; color: #f0f0f0; border-color: rgba(255,255,255,0.15); }
.chat-send {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; border: none; background: #fe8ce3; color: #111;
  cursor: pointer; font-size: 0.95rem; flex-shrink: 0;
}
.chat-send:disabled { opacity: 0.5; cursor: default; }

/* Visiteur non connecté : invitation à se connecter */
.chat-login-link {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  background: #fe8ce3;
  color: #111;
  font-weight: 700;
  text-decoration: none;
}
.chat-input.hidden { display: none; }

/* ══════════════ Mobile ══════════════ */
@media (max-width: 560px) {
  .chat-widget { right: 0.9rem; bottom: 0.9rem; }
  .chat-panel {
    right: 0.9rem; bottom: 4.9rem;
    width: calc(100vw - 1.8rem);
    height: min(70vh, calc(100vh - 6rem));
  }
}
