/* Chat communautaire portable (2026-09-20) : styles du tiroir + bouton flottant, extraits de
   styles-lobby.css (valeurs des variables --lobby-* recopiées en dur pour rester autonome, sans
   dépendre du fichier CSS du lobby ni risquer de collision de classes génériques sur d'autres
   pages). Mêmes classes/IDs que le lobby (#chat-drawer, .account-chat-*) pour rester compatible
   avec account-chat-widget.js ET lobby-chat-drawer.js sans rien changer à ces deux fichiers. */

.chat-launcher-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 13010;
    display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 18px;
    border: 1px solid rgba(125, 195, 255, 0.45); border-radius: 999px; cursor: pointer;
    background: linear-gradient(180deg, #3a7bff, #1352db); color: #fff; font-weight: 800; font-size: 13px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}
.chat-launcher-fab.is-active { background: linear-gradient(180deg, #2a5fd6, #0e3fae); }

.chat-launcher-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 4px;
    font-size: 10px; font-weight: 900; color: #fff;
    background: #e0616e; border-radius: 50%; box-shadow: 0 0 0 2px rgba(4, 7, 13, 0.9);
}
@keyframes chatLauncherPop { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
.chat-launcher-fab.has-new-message .chat-launcher-badge, .chat-launcher-fab.has-new-message { animation: chatLauncherPop 0.5s ease; }

.chat-drawer-backdrop {
    display: none !important;

}
.chat-drawer {
    position: fixed; top: auto; right: 18px; bottom: 76px; z-index: 13020;
    width: min(380px, calc(100vw - 36px)); height: min(560px, calc(100dvh - 110px));
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, rgba(8, 15, 28, 0.98), rgba(4, 8, 16, 0.99));
    border: 1px solid rgba(125, 195, 255, 0.45); border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.58);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding: 18px 18px 14px; overflow: hidden; box-sizing: border-box;
}
.chat-drawer.is-open { transform: translateX(0); }
.chat-drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.chat-drawer-head h2 { margin: 3px 0 4px; font-size: 16px; color: #f2f7ff; }
.chat-drawer-head p { margin: 0; color: #66779a; font-size: 11.5px; line-height: 1.4; }
.chat-drawer-head button { width: 32px; height: 32px; flex: 0 0 auto; border: 1px solid rgba(90, 155, 255, 0.20); background: rgba(255, 255, 255, 0.04); color: #a9b8d2; font-size: 18px; cursor: pointer; }
.chat-room-bar-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chat-live-pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 10px; font-size: 10px; font-weight: 800; color: #57c97a; background: rgba(87, 201, 122, 0.12); border: 1px solid rgba(87, 201, 122, 0.28); }
#account-chat-online-count { color: #66779a; font-size: 11px; }
.chat-channel-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chat-channel-tabs button { min-height: 28px; padding: 0 11px; font-size: 11.5px; font-weight: 700; color: #a9b8d2; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(90, 155, 255, 0.20); cursor: pointer; }
.chat-channel-tabs button.active { color: #fff; background: rgba(69, 119, 255, 0.22); border-color: rgba(69, 119, 255, 0.4); }
/* Corrige (2026-09-26, retour utilisateur "Général31 collé") : le compteur de messages non lus
   n'avait jamais eu de style ici - texte brut accolé au label, sans pastille. Repris de
   styles-compte.css, où ce badge existe déjà correctement. */
.chat-channel-tabs button span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: #9fdcff; font-size: .66rem; }
.chat-room-bar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(90, 155, 255, 0.20); }
.chat-room-bar strong { color: #f2f7ff; font-size: 13px; }
#account-chat-room-help { color: #66779a; font-size: 11px; margin-left: 8px; }

/* Corrige (2026-09-26, "chat écrasé quand il y a beaucoup de messages") : avec overflow:hidden,
   un message n'a plus de hauteur minimale liée à son contenu ; la grille répartissait alors la
   hauteur du tiroir entre tous les messages (40 messages => ~16px chacun, texte et avatar
   coupés) au lieu de laisser la liste défiler. grid-auto-rows:max-content + overflow-x:clip
   (qui ne crée pas de conteneur de défilement) gardent chaque ligne à sa vraie hauteur. */
.account-chat-messages { flex: 1 1 0; min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 9px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin-bottom: 10px; padding-right: 4px; align-content: start; }
.account-chat-message { width: 100%; max-width: 100%; min-width: 0; display: flex; flex-shrink: 0; gap: 9px; padding: 7px; border: 1px solid transparent; box-sizing: border-box; overflow-x: clip; }
.account-chat-message.is-me { background: rgba(69, 119, 255, 0.06); border-color: rgba(69, 119, 255, 0.14); }
.account-chat-message.is-staff .account-chat-author { color: #ffd574; }
.chat-message-avatar { width: 28px; height: 28px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; background: rgba(6, 11, 22, 0.97); border: 1px solid rgba(90, 155, 255, 0.20); border-radius: 50%; overflow: hidden; font-size: 11px; font-weight: 800; color: #7fb4ff; }
.chat-message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-chat-top { min-width: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px; }
.account-chat-author { min-width: 0; font-weight: 800; font-size: 12px; color: #f2f7ff; overflow-wrap: anywhere; }
.chat-staff-badge { margin-left: 6px; font-size: 9px; padding: 1px 5px; color: #ffd574; background: rgba(255, 213, 116, 0.12); border: 1px solid rgba(255, 213, 116, 0.28); }
.chat-discord-badge { margin-left: 6px; font-size: 9px; padding: 1px 5px; color: #c9cdfb; background: rgba(88, 101, 242, 0.18); border: 1px solid rgba(88, 101, 242, 0.45); }
.chat-message-content { flex: 1 1 0%; max-width: 100%; min-width: 0; font-size: 12.5px; color: #a9b8d2; line-height: 1.4; overflow-x: clip; }
.chat-message-content p { width: 100%; max-width: 100%; min-width: 0; margin: 0; white-space: pre-wrap !important; overflow-wrap: anywhere; word-break: break-word; }
.account-chat-actions { display: flex; gap: 8px; }
.chat-message-action { background: none; border: 0; color: #66779a; font-size: 10.5px; cursor: pointer; }
.chat-message-action:hover { color: #7fb4ff; }
.chat-message-action.danger:hover { color: #e0616e; }
.chat-reply-quote { width: 100%; max-width: 100%; min-width: 0; display: grid; justify-items: start; gap: 2px; margin-bottom: 4px; padding: 6px 8px; box-sizing: border-box; overflow: hidden; white-space: normal !important; background: rgba(255, 255, 255, 0.03); border-left: 2px solid #4577ff; font-size: 11px; color: #66779a; text-align: left; cursor: pointer; }
.chat-reply-quote strong, .chat-reply-quote span { display: block; width: 100%; max-width: 100%; min-width: 0; white-space: normal !important; overflow-wrap: anywhere; word-break: break-word; }
.chat-highlight { animation: chatHighlightPulse 1.2s ease; }
@keyframes chatHighlightPulse { 0% { background: rgba(69, 119, 255, 0.28); } 100% { background: transparent; } }

.account-chat-reply { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px; margin-bottom: 8px; background: rgba(255, 255, 255, 0.03); border-left: 2px solid #7fb4ff; font-size: 11.5px; }
.account-chat-reply[hidden] { display: none !important; }
.account-chat-reply small { display: block; color: #66779a; font-size: 9.5px; }
.account-chat-form { display: flex; gap: 8px; align-items: flex-end; }
.account-chat-form textarea { flex: 1; padding: 9px 11px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(90, 155, 255, 0.20); color: #f2f7ff; font-size: 12.5px; resize: none; }
.account-chat-form button { min-height: 38px; padding: 0 16px; font-weight: 800; font-size: 12px; color: #fff; background: linear-gradient(180deg, #3a7bff, #1352db); border: 1px solid rgba(125, 195, 255, 0.5); cursor: pointer; }
.account-chat-form button:disabled { opacity: .5; cursor: not-allowed; }

.chat-drawer .empty-state { padding: 20px 8px; text-align: center; color: #66779a; font-size: 12.5px; }

@media (max-width: 700px) {
    .chat-drawer {
        right: 8px; bottom: 64px; width: calc(100vw - 16px);
        height: min(560px, calc(var(--chat-visual-height, 100dvh) - 82px));
        max-height: calc(var(--chat-visual-height, 100dvh) - 82px);
        min-height: min(390px, calc(var(--chat-visual-height, 100dvh) - 82px));
        padding: 10px; border-radius: 14px; overflow: hidden;
    }
    .chat-drawer.is-keyboard-open {
        bottom: 6px;
        height: calc(var(--chat-visual-height, 100dvh) - 12px);
        max-height: calc(var(--chat-visual-height, 100dvh) - 12px);
        min-height: 0;
    }
    .chat-drawer-head { margin-bottom: 5px; align-items: center; }
    .chat-drawer-head .eyebrow, .chat-drawer-head h2 + p { display: none; }
    .chat-drawer-head h2 { margin: 0; font-size: 14px; }
    .chat-drawer-head button { width: 36px; height: 36px; }
    .chat-room-bar-top { margin-bottom: 5px; }
    .chat-channel-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -2px 6px; padding: 0 2px 4px; scrollbar-width: none; }
    .chat-channel-tabs::-webkit-scrollbar { display: none; }
    .chat-channel-tabs button { flex: 0 0 auto; min-height: 32px; }
    .chat-room-bar { margin-bottom: 5px; padding-bottom: 6px; }
    #account-chat-room-help { display: none; }
    .account-chat-messages { min-height: 110px; margin-bottom: 6px; padding: 2px 2px 8px 0; }
    .account-chat-message { padding: 6px 3px; gap: 7px; }
    .account-chat-form { flex: 0 0 auto; gap: 6px; padding-top: 6px; border-top: 1px solid rgba(90,155,255,.16); background: rgba(4,8,16,.98); }
    .account-chat-form textarea { min-height: 40px; max-height: 82px; padding: 8px 9px; font-size: 16px; }
    .account-chat-form button { min-height: 40px; padding: 0 12px; }
    .account-chat-reply { flex: 0 0 auto; margin-bottom: 4px; padding: 5px 7px; }
    .chat-launcher-fab { right: 12px; bottom: 12px; padding: 0 14px; }
}

/* Contrôles de notifications persistantes du chat. */
.chat-drawer-head-actions { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.chat-drawer-head .chat-notification-toggle { width: auto; min-width: 32px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 11px; border-radius: 8px; }
.chat-notification-toggle.is-muted { color: #e7ad63; border-color: rgba(224, 159, 77, .38); background: rgba(224, 159, 77, .09); }
.chat-launcher-fab.chat-notifications-muted { filter: saturate(.72); }
@media (max-width: 700px) {
    .chat-notification-toggle-label { display: none; }
    .chat-drawer-head .chat-notification-toggle { padding: 0; }
    .pixi-page .chat-launcher-fab { bottom: 70px; }
    .pixi-page .chat-drawer { bottom: 124px; height: min(520px, calc(var(--chat-visual-height, 100dvh) - 142px)); max-height: calc(var(--chat-visual-height, 100dvh) - 142px); min-height: min(340px, calc(var(--chat-visual-height, 100dvh) - 142px)); }
    .pixi-page .chat-drawer.is-keyboard-open { bottom: 6px; height: calc(var(--chat-visual-height, 100dvh) - 12px); max-height: calc(var(--chat-visual-height, 100dvh) - 12px); min-height: 0; }
}

/* Garde-fou de largeur : certaines pages chargent ensuite leurs propres styles de boutons/chat.
   Le scope #chat-drawer empêche un nowrap global d'agrandir la colonne et de couper la fin. */
#chat-drawer .account-chat-messages { min-width: 0; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; overflow-x: hidden; }
#chat-drawer .account-chat-message { width: 100%; max-width: 100%; min-width: 0; flex-shrink: 0; overflow-x: clip; box-sizing: border-box; }
#chat-drawer .chat-message-content { flex: 1 1 0%; max-width: 100%; min-width: 0; overflow-x: clip; }
#chat-drawer .chat-message-content p,
#chat-drawer .chat-reply-quote,
#chat-drawer .chat-reply-quote strong,
#chat-drawer .chat-reply-quote span {
    max-width: 100%;
    min-width: 0;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word;
}
#chat-drawer .chat-reply-quote { width: 100%; display: grid; box-sizing: border-box; overflow: hidden; }
#chat-drawer .chat-reply-quote strong,
#chat-drawer .chat-reply-quote span { display: block; width: 100%; text-overflow: clip; overflow: visible; }
.chat-launcher-badge[hidden] { display: none !important; }

/* Actions de message (2026-09-26, retour utilisateur "vide au-dessus du message") : les boutons
   Répondre/Supprimer, masqués hors survol, occupaient quand même une ligne entière. Ils flottent
   désormais en haut à droite du message, sans prendre de place ; sur écran tactile (pas de survol)
   ils restent visibles dans la ligne du pseudo. */
#chat-drawer .account-chat-message { position: relative; }
#chat-drawer .account-chat-actions { position: absolute; top: 5px; right: 6px; z-index: 1; display: flex; gap: 4px; opacity: 0; pointer-events: none; transition: opacity .12s ease; }
#chat-drawer .account-chat-message:hover .account-chat-actions,
#chat-drawer .account-chat-message:focus-within .account-chat-actions { opacity: 1; pointer-events: auto; }
#chat-drawer .chat-message-action { min-height: 0 !important; padding: 2px 8px !important; border-radius: 6px !important; font-size: 10.5px !important; line-height: 1.5; color: #a9c4ea !important; background: rgba(8, 18, 34, .94) !important; border: 1px solid rgba(110, 169, 255, .22) !important; cursor: pointer; }
#chat-drawer .chat-message-action.danger { color: #ffb5bf !important; }
#chat-drawer .chat-reply-quote { display: grid; gap: 2px; }
#chat-drawer .chat-reply-quote strong, #chat-drawer .chat-reply-quote span { display: block; }
@media (hover: none) {
    #chat-drawer .account-chat-actions { position: static; opacity: 1; pointer-events: auto; margin-left: auto; }
}
