.chat-container {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 500px;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
}

/* ── Panneau gauche : liste conversations ── */
.chat-sidebar {
    width: 300px;
    min-width: 300px;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
}

.chat-conversations {
    overflow-y: auto;
}

.chat-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    background: #f1f3f5;
    border-top: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}

.queue-item {
    border-left: 3px solid #24A88E;
}

.chat-conv-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.chat-conv-item:hover {
    background: #e9ecef;
}

.chat-conv-item.active {
    background: #e8f7f4;
    border-left: 3px solid #24A88E;
}

.chat-conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-preview {
    font-size: 0.78rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ── Panneau droit : messages ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.chat-main-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.9rem;
}

/* ── Bulles de messages ── */
.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.chat-msg.moi {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg.autre {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 0.5rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    word-break: break-word;
}

.chat-msg.moi .chat-bubble {
    background: #24A88E;
    color: #fff;
    border-bottom-right-radius: 0.2rem;
}

.chat-msg.autre .chat-bubble {
    background: #f0f0f0;
    color: #212529;
    border-bottom-left-radius: 0.2rem;
}

.chat-msg-meta {
    font-size: 0.72rem;
    color: #6c757d;
    margin-top: 0.2rem;
    padding: 0 0.2rem;
}

/* ── Zone de saisie ── */
.chat-input-zone {
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input-zone textarea {
    resize: none;
    border-radius: 1.2rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
}

.chat-input-zone .btn-send {
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Badge navbar ── */
.chat-nav-badge {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    margin-left: 2px;
    vertical-align: middle;
}

/* ══════════════════════════════════════════════════
   Widget flottant (support / contact rapide)
   ══════════════════════════════════════════════════ */

/* Bouton flottant */
.chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #24A88E;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(36,168,142,.45);
    z-index: 1050;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    border: none;
}

.chat-widget-btn.visible {
    opacity: 1;
    transform: translateY(0);
}

.chat-widget-btn:hover {
    background: #1d9078;
}

/* Variante pill avec étiquette texte (widget site public) */
.chat-widget-btn.with-label {
    width: auto;
    height: 48px;
    border-radius: 24px;
    padding: 0 18px 0 14px;
    gap: 8px;
    font-size: 1.1rem;
}
.chat-widget-btn-label {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.chat-widget-btn-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Panneau popup */
.chat-widget-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 340px;
    height: 480px;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    z-index: 1049;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: widgetSlideIn 0.25s ease;
}

@keyframes widgetSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.chat-widget-header {
    padding: 0.85rem 1rem;
    background: #24A88E;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.chat-widget-header .btn-close-widget {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.chat-widget-header .btn-close-widget:hover {
    color: #fff;
}

/* Sélecteur de contact (Moniteur) */
.chat-widget-contact-selector {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.chat-widget-contact-selector select {
    width: 100%;
    font-size: 0.875rem;
}

/* Zone messages */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: #f8f9fa;
}

.chat-widget-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
}

/* Bulles dans le widget */
.chat-widget-messages .chat-msg {
    max-width: 85%;
}

/* Zone de saisie */
.chat-widget-input {
    padding: 0.6rem;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 0.4rem;
    align-items: flex-end;
    flex-shrink: 0;
    background: #fff;
}

.chat-widget-input textarea {
    flex: 1;
    resize: none;
    border-radius: 1rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border: 1px solid #dee2e6;
    max-height: 80px;
}

.chat-widget-input textarea:focus {
    outline: none;
    border-color: #24A88E;
    box-shadow: 0 0 0 2px rgba(36,168,142,.15);
}

.chat-widget-input .btn-send-widget {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #24A88E;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.chat-widget-input .btn-send-widget:hover {
    background: #1d9078;
}

/* ══ Widget multi-conv (Admin / Moniteur) ══ */

.chat-widget-panel.multiconv {
    width: 580px;
    height: 460px;
}

.chat-widget-body-multiconv {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar du widget multi-conv */
.widget-sidebar {
    width: 195px;
    min-width: 175px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.widget-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    background: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}

.widget-conv-item {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 0.82rem;
}

.widget-conv-item:hover {
    background: #f0faf8;
}

.widget-conv-item.active {
    background: #e8f7f4;
    border-left: 3px solid #24A88E;
}

.widget-conv-name {
    font-weight: 600;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.widget-conv-preview {
    font-size: 0.74rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-queue-item {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    border-left: 3px solid #24A88E;
    font-size: 0.82rem;
}

.widget-queue-item .btn {
    font-size: 0.75rem;
    padding: 2px 8px;
}

/* Panneau principal messages (dans le widget multi-conv) */
.widget-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.widget-main .chat-widget-messages {
    flex: 1;
}

.widget-main .chat-widget-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlay nouvelle conversation (moniteur) */
.widget-new-conv-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 2;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Bouton icône dans le header du widget */
.btn-icon-widget {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.btn-icon-widget:hover {
    background: rgba(255,255,255,.35);
}

/* ── Responsive ── */
@media (max-width: 576px) {
    .chat-sidebar {
        width: 100%;
        min-width: unset;
    }
    .chat-container {
        flex-direction: column;
        height: auto;
    }
    .chat-sidebar.d-none-mobile {
        display: none;
    }
}
