/* Widget Chat & Support (bulle flottante) : feuille unique partagée par le tableau de bord v2 et l'ancien tableau de bord.
   Markup + script : views/v2/partials/chat-widget.ejs. */
:root {
    --chat-card: var(--u-surface, var(--color-surface, rgba(15, 17, 26, 0.98)));
    --chat-border: var(--u-line, var(--color-border, rgba(255, 255, 255, 0.08)));
    --chat-accent: var(--u-info, var(--color-link, #3b82f6));
}
/* Thème : le chat suit le thème de la page (clair ou sombre). Il lit les jetons du site (--color-*, tokens.css) et les expose
   sous les noms --u-* et --red/--blue… que cette feuille utilise ; l'ancien tableau de bord (v1-theme.css) pose déjà les mêmes
   correspondances, donc rien ne change pour lui. Limité au widget et à ses fenêtres : aucun effet sur le reste de la page. */
#chat-widget-toggle, #chat-widget-panel, .chat-modal-overlay {
    --u-bg: var(--color-bg, #0d0f18);
    --u-surface: var(--color-surface, #0d0f18);
    --u-surface-2: var(--color-surface-2, #1b1e2b);
    --u-text: var(--color-text, #f7efea);
    --u-muted: var(--color-text-muted, #cdbbb4);
    --u-line: var(--color-border, #3a3f52);
    --u-info: var(--color-link, #3b82f6);
    --u-overlay: var(--color-overlay, rgba(0, 0, 0, .6));
    --red: var(--color-brand, #ff3366);
    --green: var(--color-success, #00cc66);
    --yellow: var(--color-warning, #ffcc00);
    --orange: var(--color-warning, #f97316);
    --blue: var(--color-link, #3b82f6);
    --purple: var(--color-link, #a855f7);
    --border: var(--u-line);
    --muted: var(--u-muted);
    --card: var(--u-surface);
    --chat-card: var(--u-surface);
    --chat-border: var(--u-line);
    --chat-accent: var(--u-info);
}
#chat-widget-panel { color: var(--u-text); }
#chat-widget-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    color: #fff;
    border: none;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(59, 130, 246, .45);
    z-index: 1150;
    transition: transform .2s, box-shadow .2s;
}

#chat-widget-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 32px rgba(59, 130, 246, .55);
}

#chat-widget-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--btn-bg, #db2c58);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--u-line, #0a0b11);
}

#chat-widget-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--u-surface);
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255,255,255,.04);
    z-index: 1140;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#chat-widget-panel.open { display: flex; }

/* Chat sur téléphone (demande du propriétaire du 14/10) : plein écran au lieu d'un panneau de 400 px qui sortait
   de l'écran ; hauteur dynamique (dvh) pour suivre le clavier ; champs à 16 px (pas de zoom forcé sur iOS) ;
   cibles tactiles d'au moins 44 px ; marges de sécurité des écrans à encoche. */
@media (max-width: 640px) {
    #chat-widget-panel {
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    body.chat-open #chat-widget-toggle { display: none; }
    #chat-widget-toggle { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: 16px; }
    #chat-widget-panel #chat-text-input, #chat-widget-panel #chat-search-input { font-size: 16px; }
    #chat-widget-panel .chat-widget-close, #chat-widget-panel .chat-detail-back, #chat-widget-panel #chat-send-btn { min-width: 44px; min-height: 44px; }
    #chat-widget-panel .chat-tab { min-height: 44px; }
    #chat-widget-panel #chat-input-container { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
    #chat-widget-panel .msg-actions { opacity: 1; }
}

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--chat-border);
    background: var(--u-surface, rgba(255,255,255,.02));
}

.chat-widget-header strong {
    font-size: 15px;
    color: var(--u-text, #fff);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.chat-widget-close {
    background: var(--u-surface-2, rgba(255,255,255,.06));
    border: none;
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    transition: background .15s;
}
.chat-widget-close:hover { background: var(--u-surface-2, rgba(255,255,255,.12)); color: var(--u-text, #fff); }

.chat-search-wrap {
    padding: 10px 12px 6px;
    border-bottom: 1px solid var(--chat-border);
}

#chat-search-input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border-radius: 10px;
    border: 1px solid var(--chat-border);
    background: var(--u-surface, rgba(255,255,255,.04));
    color: var(--u-text, #fff);
    font-size: 13px;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}
#chat-search-input:focus { border-color: var(--chat-accent); background-color: var(--u-surface-2, rgba(255,255,255,.06)); }
#chat-search-input::placeholder { color: var(--u-muted, rgba(255,255,255,.3)); }

.chat-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--chat-border);
}

.chat-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}

.chat-tab.active {
    background: var(--u-surface-2, rgba(59, 130, 246, .12));
    color: var(--blue);
}

.chat-body { flex: 1; display: flex; min-height: 0; }

#chat-list-view {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#chat-list-panel {
    width: 100%;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

#chat-detail-panel {
    width: 100%;
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#chat-detail-panel.open { display: flex; }

.chat-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--chat-border);
    background: var(--u-surface, rgba(255,255,255,.02));
}

.chat-detail-back {
    background: var(--u-surface-2, rgba(255,255,255,.06));
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
}
.chat-detail-back:hover { background: var(--u-surface-2, rgba(255,255,255,.1)); color: var(--u-text, #fff); }

#chat-room-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--u-surface-2, rgba(59,130,246,.15));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
    color: var(--blue);
    font-weight: 700;
}
#chat-room-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-detail-title-wrap { display: flex; flex-direction: column; min-width: 0; }
#chat-room-title { font-size: 14px; font-weight: 700; color: var(--u-text, #fff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-room-status { font-size: 11px; color: var(--green); }

#chat-messages-flow {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(180deg, var(--u-surface-2, rgba(10,11,17,.3)) 0%, var(--u-surface, rgba(10,11,17,.6)) 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(59,130,246,.4) transparent;
}
#chat-messages-flow::-webkit-scrollbar { width: 4px; }
#chat-messages-flow::-webkit-scrollbar-thumb { background: var(--u-surface-2, rgba(59,130,246,.4)); border-radius: 2px; }

.chat-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 13px;
}
.chat-placeholder-error { color: var(--red); }
.chat-load-more { text-align: center; padding: 8px; font-size: 11px; color: var(--muted); }

.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0 8px;
}
.chat-date-separator span {
    background: var(--u-surface-2, rgba(255,255,255,.06));
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 12px;
    letter-spacing: .02em;
}

/* Conversation list */
.chat-list-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
}
.btn-new-conv {
    flex: 1;
    background: var(--u-surface-2, rgba(59,130,246,.12));
    border: 1px solid rgba(59,130,246,.25);
    color: var(--blue);
    font-size: 11px;
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}
.btn-new-conv:hover { background: var(--u-surface-2, rgba(59,130,246,.2)); }
.btn-secondary-conv {
    background: var(--u-surface, rgba(255,255,255,.04));
    border-color: var(--chat-border);
    color: var(--muted);
}
.btn-archived-toggle {
    background: var(--u-surface, rgba(255,255,255,.04));
    border-color: var(--chat-border);
    color: var(--muted);
}
.btn-archived-toggle.active {
    background: var(--u-surface-2, rgba(168,85,247,.15));
    border-color: rgba(168,85,247,.3);
    color: var(--purple);
}
.btn-archived-toggle:hover {
    background: var(--u-surface-2, rgba(255,255,255,.08));
}

.chat-empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--muted);
    font-size: 13px;
}
.chat-empty-icon { font-size: 32px; margin-bottom: 8px; }

.room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    cursor: pointer;
    border-radius: 0;
    transition: background .12s;
    border-bottom: 1px solid var(--u-line, rgba(255,255,255,.03));
}
.room-item:hover { background: var(--u-surface, rgba(255,255,255,.04)); }
.room-item.active { background: var(--u-surface-2, rgba(59,130,246,.08)); }
.room-item.has-unread .room-name { color: var(--u-text, #fff); font-weight: 700; }
.room-item.has-unread .room-last-msg { color: var(--u-muted, rgba(255,255,255,.7)); }

.room-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--u-surface-2, rgba(59,130,246,.12));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}
.room-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.room-avatar-initial { font-weight: 700; font-size: 16px; color: var(--blue); }

.room-info { flex: 1; min-width: 0; }
.room-name-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.room-name { font-size: 13px; font-weight: 600; color: var(--u-text, rgba(255,255,255,.9)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.room-item.has-unread .room-time { color: var(--blue); font-weight: 700; }
.room-last-msg { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.room-hint { font-style: italic; opacity: .6; }

.room-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.room-badge {
    background: var(--blue);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}
.room-actions { display: none; gap: 2px; }
.room-actions button {
    background: none; border: none; color: var(--muted);
    cursor: pointer; font-size: 11px; padding: 2px 4px; border-radius: 4px;
}
.room-actions button:hover { background: var(--u-surface-2, rgba(255,255,255,.08)); color: var(--u-text, #fff); }
.room-delete-btn:hover { color: var(--red) !important; }

.ticket-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.ticket-open { background: var(--u-surface-2, rgba(59,130,246,.15)); color: var(--blue); }
.ticket-pending { background: var(--u-warning-soft, rgba(255,204,0,.15)); color: var(--yellow); }
.ticket-resolved { background: var(--u-success-soft, rgba(0,204,102,.15)); color: var(--green); }
.ticket-closed { background: var(--u-surface-2, rgba(255,255,255,.08)); color: var(--muted); }

/* Message bubbles — WhatsApp style */
.msg-wrapper { margin-bottom: 2px; max-width: 88%; min-width: 0; }
.msg-wrapper.self { align-self: flex-end; }
.msg-wrapper.other { align-self: flex-start; }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg-wrapper.self .msg-row { flex-direction: row-reverse; }

.msg-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--u-surface-2, rgba(59,130,246,.15)); overflow: hidden; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--blue);
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-wrapper.self .msg-avatar { display: none; }

.msg-content-col { max-width: 100%; min-width: 0; }
.msg-wrapper.self .msg-content-col { align-items: flex-end; display: flex; flex-direction: column; }

.msg-sender-name { font-size: 11px; font-weight: 700; color: var(--blue); margin-bottom: 3px; padding-left: 4px; }

.msg-bubble-wrap { display: flex; align-items: center; gap: 4px; }
.msg-wrapper.self .msg-bubble-wrap { flex-direction: row-reverse; }

.msg-bubble {
    padding: 8px 12px 6px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--u-text, #e8eaed);
    word-break: normal;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: manual;
    min-width: 0;
}
.msg-bubble-content { white-space: pre-wrap; }
.msg-wrapper.other .msg-bubble {
    background: var(--u-surface-2, rgba(255,255,255,.07));
    border-bottom-left-radius: 4px;
}
.msg-wrapper.self .msg-bubble {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-bubble.msg-reported { opacity: .5; border-left: 3px solid var(--red); }

.msg-time {
    display: block;
    font-size: 10px;
    color: var(--u-muted, rgba(255,255,255,.45));
    text-align: right;
    margin-top: 3px;
    line-height: 1;
}
.msg-wrapper.self .msg-time { color: var(--u-muted, rgba(255,255,255,.65)); }

.msg-actions { opacity: 0; transition: opacity .15s; }
.msg-bubble-wrap:hover .msg-actions { opacity: 1; }
.msg-action-btn {
    background: none; border: none; color: var(--muted);
    font-size: 11px; cursor: pointer; padding: 2px;
}
.msg-action-btn:hover { color: #fff; }

.msg-delete-menu {
    background: var(--u-surface, #1a1d2d);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    min-width: 200px;
    padding: 8px 0;
    z-index: 1000;
}
.delete-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.delete-menu-item:hover {
    background: var(--u-surface-2, rgba(59,130,246,.1));
}
.delete-menu-item span {
    font-size: 13px;
    font-weight: 600;
    color: var(--u-text, #fff);
}
.delete-menu-item small {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
}
.delete-menu-cancel {
    padding: 10px 16px;
    cursor: pointer;
    border-top: 1px solid var(--chat-border);
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    transition: color .15s;
}
.delete-menu-cancel:hover {
    color: var(--u-text, #fff);
}

.msg-attachment {
    display: flex; align-items: center; gap: 6px;
    color: var(--u-text, rgba(255,255,255,.9)); font-size: 12px;
    text-decoration: none; margin-top: 6px;
    background: rgba(0,0,0,.15); border-radius: 8px; padding: 6px 10px;
}
.msg-attachment:hover { background: var(--u-surface-2, rgba(0,0,0,.25)); }
.msg-file-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-attachment-view { background: var(--u-brand-soft, rgba(255,51,102,.12)); color: var(--u-brand, #ff3366); }
.chat-pdf-preview-link {
    display: flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; margin-bottom: 6px; border-radius: 10px;
    background: rgba(0,0,0,.2);
}
.chat-pdf-icon { font-size: 28px; }

.audio-msg-player { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.audio-control-btn { background: var(--u-surface-2, rgba(255,255,255,.15)); border: none; color: var(--u-text, #fff); border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 11px; }
.audio-timeline { flex: 1; height: 4px; background: var(--u-surface-2, rgba(255,255,255,.2)); border-radius: 2px; position: relative; cursor: pointer; }
.audio-progress { height: 100%; width: 0%; background: #fff; border-radius: 2px; }
.audio-time { font-size: 10px; color: var(--u-muted, rgba(255,255,255,.6)); }

#chat-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--chat-border);
    background: var(--u-surface, rgba(255,255,255,.02));
}

#chat-text-input {
    flex: 1;
    min-width: 0; /* sans ça, un flex item ne rétrécit jamais sous sa largeur naturelle : sur
                     un écran étroit, la rangée dépassait et poussait le bouton Envoyer hors
                     du cadre (coupé par l'« overflow: hidden » du panneau). */
    background: var(--u-surface-2, rgba(255,255,255,.05));
    border: 1px solid var(--chat-border);
    border-radius: 22px;
    padding: 10px 16px;
    color: var(--u-text, #fff);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
#chat-text-input:focus { border-color: var(--chat-accent); }
#chat-text-input::placeholder { color: var(--u-muted, rgba(255,255,255,.3)); }

#chat-send-btn {
    background: var(--blue);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, opacity .15s;
    flex-shrink: 0;
}
#chat-send-btn:hover { transform: scale(1.05); }
#chat-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Modals */
.chat-modal-overlay {
    position: fixed; inset: 0;
    background: var(--u-overlay, rgba(0,0,0,.65));
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1200; padding: 20px;
}
.chat-modal-card {
    width: 400px; max-width: 100%;
    background: var(--u-surface, #12141f);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.chat-modal-card h3 { font-size: 16px; font-weight: 700; color: var(--u-text, #fff); margin-bottom: 6px; }
.chat-modal-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.chat-modal-input { width: 100%; }
.chat-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Boutons et champs des fenêtres du chat (nouvelle conversation, groupe, ticket) : classes génériques .btn / .form-input,
   qui n'avaient aucun style dans le widget en v2. Limité à .chat-modal-card. Cibles tactiles de 44 px minimum. */
.chat-modal-card .form-group { margin-bottom: 14px; }
.chat-modal-card .form-label { display: block; font-size: 12px; font-weight: 600; color: var(--u-muted); margin-bottom: 6px; }
.chat-modal-card .form-input {
    width: 100%; box-sizing: border-box; min-height: 44px; padding: 10px 12px;
    background: var(--u-surface-2); color: var(--u-text);
    border: 1px solid var(--u-line); border-radius: 10px; font: inherit; font-size: 14px;
}
.chat-modal-card .form-input::placeholder { color: var(--u-muted); opacity: .8; }
.chat-modal-card .form-input:focus-visible { outline: 3px solid var(--u-info); outline-offset: 1px; border-color: var(--u-info); }
.chat-modal-card .btn {
    min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.chat-modal-card .btn-primary { background: #1d4ed8; color: #fff; }
.chat-modal-card .btn-primary:hover { background: #1e40af; }
.chat-modal-card .btn-secondary { background: transparent; color: var(--u-text); border-color: var(--u-line); }
.chat-modal-card .btn-secondary:hover { background: var(--u-surface-2); }
.chat-modal-card .btn-danger { background: #dc2626; color: #fff; }
.chat-modal-card .btn-danger:hover { background: #b91c1c; }
.chat-modal-card .btn:focus-visible { outline: 3px solid var(--u-info); outline-offset: 2px; }
.chat-modal-card .btn[disabled] { opacity: .55; cursor: not-allowed; }
.chat-modal-error { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--color-danger, #ef4444); border: 1px solid currentColor; }
.chat-modal-error[hidden] { display: none; }
.chat-confirm-text { margin: 0 0 4px; font-size: 14px; line-height: 1.5; color: var(--u-text, #fff); }

/* Alertes du chat (remplace alert()/confirm() du navigateur, sans design et non traduisibles). */
#chat-toast-stack {
    position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    z-index: 1300; display: flex; flex-direction: column-reverse; gap: 8px;
    width: min(360px, calc(100vw - 24px)); pointer-events: none;
}
.chat-toast {
    display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-radius: 12px;
    background: var(--u-surface, #12141f); border: 1px solid var(--chat-border);
    color: var(--u-text, #fff); font-size: 13px; font-weight: 600; line-height: 1.4;
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
    opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.chat-toast.is-visible { opacity: 1; transform: translateY(0); }
.chat-toast-icon { flex: none; font-size: 15px; }
.chat-toast-text { min-width: 0; }
.chat-toast--error { border-color: #dc2626; }
.chat-toast--success { border-color: #16a34a; }
.chat-toast--warning { border-color: #f59e0b; }

/* Panneau d'aide des visiteurs sans compte (views/v2/partials/chat-visitor.ejs) : même coque que le chat, contenu en liens. */
#chat-widget-panel.chat-visitor { height: auto; max-height: calc(100vh - 120px); }
.chat-visitor__body { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px 20px; overflow-y: auto; }
.chat-visitor__text { margin: 0 0 4px; font-size: 14px; line-height: 1.5; color: var(--u-muted); }
.chat-visitor__link {
    display: flex; align-items: center; min-height: 48px; padding: 0 14px; box-sizing: border-box;
    border: 1px solid var(--u-line); border-radius: 10px; background: var(--u-surface-2);
    color: var(--u-text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.chat-visitor__link:hover { border-color: var(--u-info); }
.chat-visitor__link:focus-visible { outline: 3px solid var(--u-info); outline-offset: 2px; }
.chat-visitor__link--primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.chat-visitor__link--primary:hover { background: #1e40af; }
@media (max-width: 640px) { #chat-widget-panel.chat-visitor { height: 100dvh; max-height: none; } }

/* Bouton « joindre » du chat (image ou petit PDF) */
#chat-attach-btn { flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 17px; cursor: pointer; }
#chat-attach-btn:disabled { opacity: .45; cursor: not-allowed; }

/* @pseudo : mentions, suggestions, message vocal */
#chat-mic-btn { flex: none; min-width: 36px; height: 36px; padding: 0 6px; border: 0; border-radius: 18px; background: transparent; color: inherit; cursor: pointer; font-size: 13px; font-weight: 700; }
#chat-mic-btn:disabled { opacity: .45; cursor: not-allowed; }
#chat-mic-btn.is-recording { background: #dc2626; color: #fff; }
.msg-mention { color: var(--chat-accent, #ff3366); font-weight: 700; cursor: pointer; }
.msg-mention:hover { text-decoration: underline; }
.handle-suggest { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30; max-height: 240px; overflow-y: auto; padding: 4px; background: var(--u-surface, #12141f); border: 1px solid var(--border, rgba(255,255,255,.12)); border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.4); }
.handle-suggest[hidden] { display: none; }
.handle-suggest__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.handle-suggest__item:hover, .handle-suggest__item.is-active { background: var(--u-brand-soft, rgba(255,51,102,.14)); }
.handle-suggest__item img, .handle-suggest__ini { flex: none; width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--u-surface-2, rgba(255,255,255,.08)); font-weight: 800; }
.handle-suggest__item span { display: grid; min-width: 0; }
.handle-suggest__item small { color: var(--muted, #9aa); }
.chat-modal-card .handle-suggest { bottom: auto; top: calc(100% + 4px); }


/* Communautés : hiérarchie visuelle et actions compactes, sans masquer les noms des membres. */
.chat-community-section, .chat-conversations-section { margin: 8px 10px 14px; }
.chat-section-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 4px; }
.chat-section-heading strong { display:block; font-size:13px; color:var(--u-text); }
.chat-section-heading small { display:block; margin-top:3px; font-size:11px; line-height:1.35; color:var(--u-muted); }
.chat-community-create { flex:0 0 auto; border:1px solid var(--chat-border); border-radius:9px; background:var(--u-surface-2); color:var(--u-text); padding:7px 10px; font-size:12px; font-weight:700; }
.chat-section-empty { margin:4px 2px 10px; padding:10px; border:1px dashed var(--chat-border); border-radius:10px; color:var(--u-muted); font-size:12px; }
.chat-modal-help { color:var(--u-muted); font-size:12px; line-height:1.45; margin:0 0 14px; }
.chat-modal-error { color:#f87171; font-size:12px; }
#chat-widget-panel #chat-poll-btn, #chat-widget-panel #chat-todo-btn {
    flex:0 0 34px; width:34px; min-width:34px; height:36px; min-height:36px;
    padding:0; border:1px solid var(--chat-border); border-radius:9px;
    background:var(--u-surface-2); color:var(--u-text); font-size:15px; cursor:pointer;
}
#chat-widget-panel #chat-input-container { gap:6px; }
.chat-interactive-card { min-width:190px; display:flex; flex-direction:column; gap:7px; }
.chat-interactive-card > strong { font-size:13px; line-height:1.4; margin-bottom:3px; }
.chat-interactive-card > small { color:var(--u-muted); font-size:10px; }
.chat-poll-option, .chat-todo-item {
    display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%;
    border:1px solid var(--chat-border); border-radius:8px; background:var(--u-surface-2);
    color:var(--u-text); padding:8px 10px; font-size:12px; text-align:left; cursor:pointer;
}
.chat-todo-item { justify-content:flex-start; }
.chat-todo-item.is-done span:last-child { text-decoration:line-through; opacity:.7; }
.chat-internal-staff { color:var(--u-muted); font-size:10px; font-weight:500; }

.chat-image-preview-link { display:block; max-width:min(260px, 68vw); margin-bottom:6px; border-radius:10px; overflow:hidden; }
.chat-image-preview { display:block; width:100%; max-height:260px; object-fit:cover; }
.chat-staff-contact { cursor:pointer; }
.chat-staff-contact:hover { filter:brightness(1.12); }
