/* =====================================================
   CHAT SYSTEM - RevisionBPEL
   Styles pour le système de messagerie en temps réel
   ===================================================== */

/* ===== VARIABLES ===== */
:root {
    --chat-primary: #6366f1;
    --chat-primary-hover: #4f46e5;
    --chat-bg: rgba(26, 26, 46, 0.98);
    --chat-header-bg: linear-gradient(135deg, #6366f1, #8b5cf6);
    --chat-border: rgba(99, 102, 241, 0.3);
    --chat-message-sent: linear-gradient(135deg, #6366f1, #8b5cf6);
    --chat-message-received: rgba(55, 55, 75, 0.9);
    --chat-input-bg: rgba(42, 42, 62, 0.9);
    --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --chat-width: 340px;
    --chat-height: 450px;
    --chat-minimized-width: 200px;
}

/* ===== ICÔNE CHAT DANS LE TOOLTIP ===== */
.chat-icon-btn {
    background: transparent;
    border: none;
    color: var(--chat-primary);
    cursor: pointer;
    padding: 4px 6px;
    margin-left: 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.7;
    font-size: 14px;
}

.chat-icon-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    opacity: 1;
    transform: scale(1.1);
}

.chat-icon-btn:active {
    transform: scale(0.95);
}

/* ===== CONTAINER DES FENÊTRES DE CHAT ===== */
#chatWindowsContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100000; /* Au-dessus du quiz (1000) */
}

#chatWindowsContainer .chat-window {
    pointer-events: auto;
}

/* ===== FENÊTRE DE CHAT ===== */
.chat-window {
    position: fixed;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    backdrop-filter: blur(20px);
    z-index: 100001; /* Au-dessus du quiz (1000) et des modales */
}

.chat-window:hover {
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.3);
}

.chat-window.dragging {
    box-shadow: 0 16px 48px rgba(99, 102, 241, 0.4);
    transform: scale(1.02);
    cursor: grabbing;
}

/* État minimisé */
.chat-window.minimized {
    width: var(--chat-minimized-width);
    height: 48px;
    border-radius: 24px;
}

.chat-window.minimized .chat-body,
.chat-window.minimized .chat-input-area {
    display: none;
}

.chat-window.minimized .chat-header {
    border-radius: 24px;
}

/* ===== HEADER DE LA FENÊTRE - COMPACT ===== */
.chat-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95), rgba(139, 92, 246, 0.95));
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header:active {
    cursor: grabbing;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* Texte du header (nom + indicateur typing) */
.chat-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.chat-user-name {
    font-weight: 600;
    font-size: 13px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Indicateur "écrit..." */
.chat-typing-indicator {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    height: 14px;
    line-height: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-typing-indicator.active {
    opacity: 1;
    animation: typingPulse 1.5s ease-in-out infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.chat-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

/* Indicateur en ligne sur l'avatar */
.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.95);
    transition: background 0.3s ease;
}

.chat-avatar.offline::after {
    background: #ef4444;
}

/* Note: .chat-user-name défini plus haut avec .chat-header-text */

/* Boutons du header */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.chat-header-btn.close:hover {
    background: rgba(239, 68, 68, 0.8);
}

/* Force la taille du bouton fermer - override global .close styles */
.chat-header .chat-header-actions .chat-header-btn.close {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    border: none !important;
    font-size: 12px !important;
    background: rgba(239, 68, 68, 0.5) !important;
}

.chat-header .chat-header-actions .chat-header-btn.close:hover {
    background: rgba(239, 68, 68, 0.8) !important;
}

/* ===== CORPS DU CHAT (MESSAGES) ===== */
.chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* Pour masquer le pseudo-element de sélection */
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 15, 26, 0.5);
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* Message vide */
.chat-empty {
    text-align: center;
    color: rgba(148, 163, 184, 0.6);
    padding: 40px 20px;
    font-size: 13px;
}

/* Container des messages - SCROLL ICI */
.chat-messages,
#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0;
    /* Désactiver la sélection de texte (comme WhatsApp) */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.chat-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

/* ===== BULLES DE MESSAGES ===== */
.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: chatMessageIn 0.3s ease;
    position: relative;
}

.chat-message-content {
    position: relative;
}

@keyframes chatMessageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    align-self: flex-end;
}

.chat-message.received {
    align-self: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.chat-message.sent .chat-bubble {
    background: var(--chat-message-sent);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.received .chat-bubble {
    background: var(--chat-message-received);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-message-time {
    font-size: 10px;
    color: rgba(148, 163, 184, 0.6);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.sent .chat-message-time {
    text-align: right;
}

/* Indicateur de lecture */
.chat-message-status {
    font-size: 10px;
    margin-left: 4px;
}

.chat-message-status.read {
    color: #60a5fa;
}

/* ===== ZONE DE SAISIE ===== */
.chat-footer {
    padding: 12px;
    background: var(--chat-input-bg);
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    flex-shrink: 0;
    position: relative; /* Pour le positionnement du emoji picker */
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* Boutons emoji et photo */
.chat-emoji-btn,
.chat-upload-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    border: none;
    color: var(--chat-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 16px;
}

.chat-emoji-btn:hover,
.chat-upload-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    transform: scale(1.1);
}

.chat-emoji-btn:active,
.chat-upload-btn:active {
    transform: scale(0.95);
}

.chat-input-area {
    padding: 12px;
    background: var(--chat-input-bg);
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    width: 100%;
    background: rgba(26, 26, 46, 0.8);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: var(--chat-primary);
}

.chat-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-header-bg);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== INDICATEUR DE FRAPPE ===== */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    color: rgba(148, 163, 184, 0.7);
    font-size: 12px;
}

.chat-typing-dots {
    display: flex;
    gap: 3px;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(99, 102, 241, 0.6);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===== BADGE NON LUS (dans le tooltip) ===== */
.chat-unread-badge {
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    min-width: 18px;
    text-align: center;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ===== NOTIFICATION TOAST ===== */
.chat-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: linear-gradient(145deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 35, 0.98));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    padding: 14px 18px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    z-index: 100002;
    animation: chatNotifSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 340px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

@keyframes chatNotifSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.chat-notification:hover {
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 
        0 15px 50px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
    transition: all 0.2s ease;
}

.chat-notification-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1em;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.chat-notification-content {
    flex: 1;
    min-width: 0;
}

.chat-notification-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-notification-text {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-notification-close {
    background: transparent;
    border: none;
    color: rgba(148, 163, 184, 0.6);
    cursor: pointer;
    padding: 4px;
}

.chat-notification-close:hover {
    color: var(--text-primary);
}

/* ===== BARRE DE CHATS MINIMISÉS ===== */
#minimizedChatsBar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 100001; /* Au-dessus du quiz */
    pointer-events: none;
}

#minimizedChatsBar > * {
    pointer-events: auto;
}

.minimized-chat-bubble {
    background: var(--chat-header-bg);
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    transition: all 0.2s ease;
    max-width: 200px;
}

.minimized-chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.minimized-chat-name {
    color: white;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.minimized-chat-unread {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    :root {
        --chat-width: calc(100vw - 20px);
        --chat-height: 60vh;
    }
    
    .chat-window {
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        width: auto !important;
        max-height: 70vh;
    }
    
    .chat-window.minimized {
        width: auto;
        left: auto !important;
        right: 10px !important;
    }
    
    /* Header toujours en ligne sur mobile */
    .chat-header {
        flex-direction: row !important;
        padding: 8px 12px !important;
    }
    
    .chat-header-info {
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    .chat-avatar {
        width: 28px !important;
        height: 28px !important;
    }
    
    .chat-user-name {
        font-size: 14px !important;
    }
    
    #minimizedChatsBar {
        bottom: 10px;
        right: 10px;
    }
    
    .chat-notification {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    /* 2 boutons séparés sur mobile : galerie + caméra */
    .chat-upload-btn {
        display: none; /* Cacher le bouton unique */
    }
    
    .chat-gallery-btn,
    .chat-camera-btn {
        display: flex !important;
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 14px;
    }
    
    .chat-emoji-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .chat-send-btn {
        width: 36px;
        height: 36px;
    }
}

/* Boutons galerie et caméra (cachés sur desktop, visibles sur mobile) */
.chat-gallery-btn,
.chat-camera-btn {
    display: none; /* Caché par défaut sur desktop */
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    border: none;
    color: var(--chat-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 16px;
}

.chat-gallery-btn:hover,
.chat-camera-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    transform: scale(1.1);
}

/* ===== EMOJIS DANS LES MESSAGES ===== */
/* Garder les emojis en taille normale (pas trop grands) */
.chat-message-text {
    font-size: 14px;
    line-height: 1.5;
}

/* Empêcher les emojis d'être agrandis */
.chat-message-text,
.chat-bubble {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Si uniquement des emojis, légèrement plus grand mais pas trop */
.chat-message-text.emoji-only {
    font-size: 24px;
    line-height: 1.2;
}

/* ===== SÉLECTEUR D'EMOJIS ===== */
.chat-emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--chat-shadow);
    z-index: 10001;
    display: none;
    width: 280px;
    max-height: 220px;
    overflow-y: auto;
}

.chat-emoji-picker.show {
    display: block;
    animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.chat-emoji-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.chat-emoji-item:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.2);
}

/* ===== PREVIEW IMAGE (dans le champ de message) ===== */
.chat-image-preview {
    /* Styles dans .chat-input-wrapper-whatsapp .chat-image-preview */
}

/* Item de preview (jusqu'à 4 images) */
.chat-preview-item {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: visible;
    background: transparent;
    border: none;
    flex-shrink: 0;
}

.chat-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.chat-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 2;
}

.chat-preview-remove:hover {
    background: #dc2626;
}

.chat-preview-count {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.8);
    padding: 4px 8px;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 10px;
}

/* ===== IMAGES DANS LES MESSAGES ===== */
.chat-message-images {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 200px;
    cursor: pointer;
}

/* Layout grille pour plusieurs images */
.chat-message-images.multi {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    max-width: 220px;
}

.chat-message-images img {
    width: 100%;
    border-radius: 8px;
    transition: transform 0.2s ease;
    object-fit: cover;
}

.chat-message-images:not(.multi) img {
    max-width: 200px;
    border-radius: 12px;
}

.chat-message-images.multi img {
    aspect-ratio: 1;
}

.chat-message-images img:hover {
    transform: scale(1.02);
}

/* Ancien style pour compatibilité */
.chat-message-image {
    max-width: 200px;
    cursor: pointer;
}

.chat-message-image img {
    max-width: 100%;
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.chat-message-image img:hover {
    transform: scale(1.02);
}

/* ===== LIGHTBOX ===== */
.chat-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    display: none;
}

.chat-lightbox.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.chat-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.chat-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.chat-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.chat-lightbox-close:hover {
    color: #ef4444;
}

/* ===== BULLE NOTIFICATION GLOBALE ===== */
.chat-notif-bubble {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-header-bg);
    box-shadow: var(--chat-shadow);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9997;
    transition: all 0.2s ease;
    color: white;
    font-size: 24px;
}

.chat-notif-bubble:hover {
    transform: scale(1.1);
}

.chat-notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ===== LISTE CONVERSATIONS ===== */
.chat-conv-list {
    position: fixed;
    bottom: 170px;
    right: 20px;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    box-shadow: var(--chat-shadow);
    min-width: 280px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9998;
    display: none;
}

.chat-conv-list.show {
    display: block;
    animation: fadeInUp 0.2s ease;
}

.chat-conv-list-title {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    color: var(--text-primary);
}

.chat-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-conv-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.chat-conv-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-header-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.chat-conv-info {
    flex: 1;
    min-width: 0;
}

.chat-conv-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.chat-conv-preview {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Bouton X pour supprimer notification */
.chat-conv-dismiss {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-conv-item:hover .chat-conv-dismiss {
    opacity: 1;
}

.chat-conv-dismiss:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    transform: scale(1.1);
}

/* Animation de sortie pour les items */
.chat-conv-item {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ===== ERREURS ===== */
.chat-error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    margin: 8px 0;
    animation: fadeInUp 0.2s ease;
}

/* ===== READ STATUS ===== */
.chat-read-status {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.7;
}

.chat-read-status.sent {
    color: rgba(255, 255, 255, 0.5);
}

.chat-read-status.read {
    color: #60a5fa;
}

/* ===== MESSAGE FOOTER ===== */
.chat-message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.chat-message-other .chat-message-footer {
    color: rgba(148, 163, 184, 0.6);
}

.chat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--chat-primary);
    margin-bottom: 2px;
}

/* ===== PARTNER NAME & STATUS ===== */
#chatPartnerName {
    font-weight: 600;
    font-size: 15px;
}

#chatStatus {
    font-size: 12px;
    color: #10b981;
}

/* ===== CHAT HIDDEN ===== */
.chat-hidden {
    display: none !important;
}

/* ===== CHAT DRAGGING ===== */
.chat-dragging {
    opacity: 0.9;
    cursor: grabbing !important;
}

/* ===== MOBILE RESPONSIVE ADDITIONNEL ===== */
@media (max-width: 768px) {
    /* Emoji picker style WhatsApp - intégré dans le chat, pousse les messages */
    .chat-emoji-picker {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 200px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        padding: 10px 8px !important;
        background: #1a1a2e !important;
        border: none !important;
        border-top: 1px solid rgba(99, 102, 241, 0.2) !important;
        box-shadow: none !important;
        z-index: 1 !important;
        overflow-y: auto !important;
    }
    
    .chat-emoji-picker.show {
        display: block !important;
    }
    
    .chat-emoji-grid {
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 4px !important;
        padding: 4px !important;
    }
    
    .chat-emoji-item {
        width: 100% !important;
        height: 36px !important;
        font-size: 22px !important;
    }
}

@media (max-width: 480px) {
    .chat-emoji-grid {
        grid-template-columns: repeat(7, 1fr) !important;
    }
    
    .chat-notif-bubble {
        bottom: 80px;
        right: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .chat-conv-list {
        left: 10px;
        right: 10px;
        bottom: 140px;
        min-width: auto;
    }
    
    /* Fix bouton envoi coupé */
    .chat-footer {
        padding: 8px;
    }
    
    .chat-input-container {
        gap: 6px;
        align-items: flex-end;
    }
    
    .chat-emoji-btn,
    .chat-upload-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 14px;
    }
    
    .chat-send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        flex-shrink: 0;
    }
    
    .chat-input {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 0;
        height: 36px;
    }
}

/* Fix général pour éviter débordement */
.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

.chat-input {
    flex: 1;
    min-width: 0; /* Permet au champ de rétrécir */
}

.chat-send-btn {
    flex-shrink: 0;
}

/* ===== PROTECTION EN MODE QUIZ ===== */
/* Empêcher le flex du quiz de déformer les éléments chat */
#quizInterface .chat-notif-bubble {
    flex: none !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    position: fixed !important;
}

#quizInterface .chat-window {
    flex: none !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    position: fixed !important;
}

#quizInterface #notification {
    flex: none !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    position: fixed !important;
}

#quizInterface .chat-lightbox {
    flex: none !important;
    position: fixed !important;
}

/* Mobile - taille plus petite mais toujours protégée */
@media (max-width: 768px) {
    #quizInterface .chat-notif-bubble {
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
        min-height: 50px !important;
        max-width: 50px !important;
        max-height: 50px !important;
    }
}

/* ===== MODAL PARTAGE DE GROUPE ===== */
.chat-group-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    padding: 20px;
}

.chat-group-modal.show {
    display: flex;
}

.chat-group-modal-content {
    background: var(--card-bg, #1e1e2e);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-group-modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-group-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-group-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chat-group-modal-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.chat-group-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-group-loading,
.chat-group-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.6);
}

.chat-group-loading i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

/* Répertoire */
.chat-group-directory {
    margin-bottom: 16px;
}

.chat-group-directory-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-group-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.chat-group-item:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}

.chat-group-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.chat-group-item-info {
    flex: 1;
    min-width: 0;
}

.chat-group-item-name {
    font-size: 14px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-group-item-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

/* ===== CARTE DE GROUPE DANS LE CHAT ===== */
.chat-group-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    overflow: hidden;
    min-width: 200px;
    max-width: 280px;
}

.chat-group-card-header {
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.3);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-group-card-body {
    padding: 14px;
}

.chat-group-card-name {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin-bottom: 6px;
}

.chat-group-card-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-group-card-actions {
    padding: 10px 14px;
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-group-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.chat-group-btn-study {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.chat-group-btn-study:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chat-group-btn-add {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-group-btn-add:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== CARTE GROUPE - MESSAGE ENVOYÉ (fond sombre pour contraste) ===== */
.chat-message-mine .chat-group-card {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(40, 40, 70, 0.95));
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.chat-message-mine .chat-group-card-header {
    background: rgba(99, 102, 241, 0.4);
}

.chat-message-mine .chat-group-card-actions {
    border-top: 1px solid rgba(99, 102, 241, 0.3);
}

/* Responsive modal */
@media (max-width: 768px) {
    .chat-group-modal {
        padding: 10px;
    }
    
    .chat-group-modal-content {
        max-height: 80vh;
    }
    
    .chat-group-card {
        min-width: 180px;
        max-width: 240px;
    }
}

/* ===== NOUVEAU FOOTER STYLE WHATSAPP ===== */
.chat-footer {
    padding: 8px 10px;
    background: rgba(15, 15, 26, 0.8);
    border-top: none;
    flex-shrink: 0;
}

.chat-input-wrapper-whatsapp {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0;
    background: rgba(42, 42, 62, 0.95);
    border-radius: 20px;
    padding: 4px 4px 4px 8px;
    min-height: 44px;
}

/* Preview des images DANS le champ de message */
.chat-input-wrapper-whatsapp .chat-image-preview {
    width: 100%;
    display: flex;
    gap: 6px;
    padding: 8px 4px;
    flex-wrap: wrap;
    align-items: center;
    order: -1; /* Toujours en haut */
}

.chat-btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #8696a0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.chat-btn-icon:hover {
    color: #aebac1;
}

.chat-btn-icon i {
    font-size: 18px;
}

/* Textarea style WhatsApp */
.chat-input-whatsapp {
    flex: 1;
    background: transparent;
    border: none;
    color: #e9edef;
    font-size: 14px;
    padding: 8px 4px;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    overflow-y: auto;
}

.chat-input-whatsapp::placeholder {
    color: #8696a0;
}

.chat-input-whatsapp::-webkit-scrollbar {
    width: 4px;
}

.chat-input-whatsapp::-webkit-scrollbar-thumb {
    background: rgba(134, 150, 160, 0.3);
    border-radius: 2px;
}

/* Pièce jointe (trombone tourné) */
.chat-attach-btn i {
    transform: rotate(45deg);
}

/* Bouton envoyer - VIOLET (thème du site) */
.chat-send-btn-whatsapp {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
    margin-bottom: 4px;
}

.chat-send-btn-whatsapp i {
    font-size: 14px;
}

.chat-send-btn-whatsapp:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.chat-send-btn-whatsapp:active {
    transform: scale(0.95);
}

/* Liens cliquables dans les messages */
.chat-link {
    color: #53bdeb;
    text-decoration: none;
    word-break: break-all;
}

.chat-link:hover {
    text-decoration: underline;
}

.chat-message-mine .chat-link {
    color: #b8d4ff;
}

/* Responsive mobile - footer WhatsApp */
@media (max-width: 768px) {
    .chat-input-wrapper-whatsapp {
        padding: 3px 3px 3px 6px;
        min-height: 40px;
    }
    
    .chat-btn-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .chat-btn-icon i {
        font-size: 16px;
    }
    
    .chat-input-whatsapp {
        font-size: 15px;
        padding: 6px 4px;
    }
    
    .chat-send-btn-whatsapp {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .chat-send-btn-whatsapp i {
        font-size: 12px;
    }
}


/* ========================================
   TYPING INDICATOR (WebSocket)
   ======================================== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin: 5px 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    max-width: 150px;
}

.typing-dots {
    animation: typingDots 1.4s infinite;
}

@keyframes typingDots {
    0%, 20% { opacity: 0.2; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.2; }
}

/* WebSocket status indicator */
.ws-status {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4444;
    transition: background 0.3s ease;
}

.ws-status.connected {
    background: #44ff44;
}

/* ===== MODAL CHOIX VERROUILLAGE ===== */
#lockChoiceModal {
    z-index: 100020 !important;
}

.lock-choice-modal {
    max-width: 400px !important;
}

.lock-choice-body {
    padding: 20px;
}

.lock-choice-title {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
    font-size: 15px;
}

.lock-choice-buttons {
    display: flex;
    gap: 12px;
}

.lock-choice-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lock-choice-btn:hover {
    transform: translateY(-2px);
}

.lock-choice-btn i {
    font-size: 24px;
}

.lock-choice-btn span {
    font-weight: 600;
    font-size: 14px;
}

.lock-choice-btn small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
}

.lock-choice-unlocked:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
}

.lock-choice-unlocked i {
    color: #22c55e;
}

.lock-choice-locked:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.lock-choice-locked i {
    color: #ef4444;
}

/* ===== ICÔNE CADENAS DANS LISTE GROUPES ===== */
.chat-group-item-icon {
    position: relative;
}

.chat-group-lock-icon {
    position: absolute;
    bottom: -2px;
    right: -4px;
    font-size: 10px;
    color: #f59e0b;
    background: rgba(15, 15, 30, 0.9);
    border-radius: 50%;
    padding: 2px;
}

/* ===== CADENAS DANS CARTE GROUPE CHAT ===== */
.chat-group-card-lock {
    color: #f59e0b;
    margin-left: auto;
    font-size: 14px;
}

.chat-group-card-locked .chat-group-card-header {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.1));
}

.chat-group-card-locked {
    border-color: rgba(245, 158, 11, 0.3);
}

/* ===== ACTIONS SUR MESSAGES (WhatsApp-style) ===== */

/* Boutons hover dans le coin du message */
.chat-msg-hover-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    align-items: center;
    gap: 2px;
    background: transparent;
    border-radius: 4px;
    padding: 2px;
    z-index: 10;
}

.chat-message:hover .chat-msg-hover-actions {
    display: flex;
}

.chat-msg-emoji-btn,
.chat-msg-dropdown-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.15s ease;
}

.chat-msg-emoji-btn:hover,
.chat-msg-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-msg-dropdown-btn i {
    font-size: 10px;
}

/* Popup réactions rapides */
.chat-quick-reactions {
    position: fixed;
    display: flex;
    gap: 4px;
    background: rgba(30, 30, 50, 0.98);
    padding: 8px 12px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100060;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.15s ease;
}

.chat-quick-reactions.show {
    opacity: 1;
    transform: scale(1);
}

.chat-quick-emoji {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.15s ease;
}

.chat-quick-emoji:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.2);
}

/* Menu contextuel */
.chat-msg-context-menu {
    position: fixed;
    background: rgba(30, 30, 50, 0.98);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 0;
    min-width: 180px;
    z-index: 100050;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.15s ease;
}

.chat-msg-context-menu.show {
    opacity: 1;
    transform: scale(1);
}

.chat-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 14px;
}

.chat-menu-item:hover {
    background: rgba(99, 102, 241, 0.2);
}

.chat-menu-item i {
    width: 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

/* Message en édition */
.chat-message.editing {
    outline: 2px solid rgba(99, 102, 241, 0.5);
    outline-offset: 2px;
}

/* Message sélectionné */
.chat-message.selected {
    background: rgba(99, 102, 241, 0.15) !important;
}

.chat-message.selected::before {
    content: '✓';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #6366f1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

/* Message supprimé */
.chat-message-text.deleted,
.chat-message-text.chat-message-deleted {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
}

.chat-message-text.deleted i,
.chat-message-text.chat-message-deleted i {
    margin-right: 6px;
}

/* Indicateur message modifié */
.edited-indicator {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    margin-left: 4px;
}

/* Preview réponse - WhatsApp style */
.chat-reply-preview {
    display: none;
    align-items: stretch;
    background: rgba(30, 40, 50, 0.95);
    border-left: 4px solid #25D366;
    padding: 10px 12px;
    gap: 10px;
    margin: 0 10px 0 10px;
    border-radius: 8px;
}

.chat-reply-bar {
    display: none;
}

.chat-reply-content {
    flex: 1;
    min-width: 0;
}

.chat-reply-name {
    font-size: 13px;
    font-weight: 600;
    color: #25D366;
    margin-bottom: 4px;
}

.chat-reply-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-cancel {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
}

.chat-reply-cancel:hover {
    color: white;
}

/* Citation dans un message (réponse) - WhatsApp style */
.chat-quoted-msg {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #25D366;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 6px;
    cursor: pointer;
}

.chat-message-mine .chat-quoted-msg {
    border-left-color: #b8d4ff;
}

.chat-quoted-name {
    font-size: 12px;
    font-weight: 600;
    color: #25D366;
    margin-bottom: 2px;
}

.chat-message-mine .chat-quoted-name {
    color: #b8d4ff;
}

.chat-quoted-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Indicateur d'édition */
.chat-edit-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(245, 158, 11, 0.15);
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    color: #f59e0b;
    font-size: 13px;
    margin-bottom: -1px;
}

.chat-edit-indicator button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    margin-left: auto;
    padding: 4px;
}

.chat-edit-indicator button:hover {
    color: white;
}

/* Bouton envoyer en mode édition */
#chatSend.editing {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

/* Barre de sélection */
.chat-selection-bar {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(30, 30, 50, 0.98);
    padding: 10px 16px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.chat-sel-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.15s ease;
}

.chat-sel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-sel-count {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

/* Mobile: Cacher les actions hover, utiliser long press */
@media (max-width: 480px) {
    .chat-msg-hover-actions {
        display: none !important;
    }
    
    .chat-message.selected::before {
        left: 5px;
    }
    
    .chat-msg-context-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto !important;
        border-radius: 20px 20px 0 0;
        padding: 10px 0 20px;
        transform: translateY(100%);
    }
    
    .chat-msg-context-menu.show {
        transform: translateY(0);
    }
    
    .chat-menu-item {
        padding: 14px 20px;
    }
    
    .chat-quick-reactions {
        bottom: 20px;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) scale(0.9);
    }
    
    .chat-quick-reactions.show {
        transform: translateX(-50%) scale(1);
    }
}


/* ===== HIGHLIGHT MESSAGE (scroll to quoted) ===== */
.chat-message-highlight {
    animation: highlightPulse 2s ease-out;
}

@keyframes highlightPulse {
    0%, 100% { background-color: transparent; }
    20%, 80% { background-color: rgba(139, 92, 246, 0.3); }
}

/* ===== MODAL D'ÉDITION (WhatsApp style) ===== */
.chat-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100002;
    animation: fadeIn 0.15s ease-out;
}

.chat-edit-modal-content {
    background: #1e1e2e;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    padding: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.chat-edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    color: #fff;
}

.chat-edit-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.chat-edit-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-edit-textarea {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
}

.chat-edit-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-edit-cancel,
.chat-edit-save {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.chat-edit-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-edit-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-edit-save {
    background: #8b5cf6;
    color: #fff;
}

.chat-edit-save:hover {
    background: #7c3aed;
}

/* ===== BOUTON EMOJI REPOSITIONNÉ ===== */
/* Le bouton emoji est maintenant EN DEHORS de .chat-message-content */
.chat-message .chat-msg-emoji-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    z-index: 5;
}

.chat-message:hover .chat-msg-emoji-btn {
    opacity: 1;
}

/* Message envoyé (droite) : emoji à gauche du message */
.chat-message-mine .chat-msg-emoji-btn {
    right: 100%;
    margin-right: 8px;
}

/* Message reçu (gauche) : emoji à droite du message */
.chat-message-other .chat-msg-emoji-btn {
    left: 100%;
    margin-left: 8px;
}

/* Cacher l'ancien bouton dans hover-actions s'il existe encore */
.chat-msg-hover-actions .chat-msg-emoji-btn {
    display: none;
}

/* Citation cliquable */
.chat-quoted-msg {
    cursor: pointer;
    transition: background 0.15s;
}

.chat-quoted-msg:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* ===== RÉACTIONS SUR LES MESSAGES ===== */
.chat-reactions {
    position: absolute;
    bottom: -10px;
    display: flex;
    gap: 2px;
    z-index: 10;
}

/* Message reçu (gauche) : réaction au coin bas-droit (intérieur) */
.chat-message-other .chat-reactions {
    right: -5px;
}

/* Message envoyé (droite) : réaction au coin bas-gauche (intérieur) */
.chat-message-mine .chat-reactions {
    left: -5px;
}

.chat-reaction-badge {
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.15s;
}

.chat-reaction-badge:hover {
    transform: scale(1.3);
}

/* Ajouter un margin-bottom au message pour laisser de la place aux réactions */
.chat-message:has(.chat-reactions) {
    margin-bottom: 14px;
}

/* ===== SÉLECTION WHATSAPP STYLE ===== */
.chat-message {
    position: relative;
}

/* Désactiver la sélection de texte en mode sélection */
.chat-messages-container.selection-mode {
    user-select: none;
    -webkit-user-select: none;
}

.chat-messages-container.selection-mode .chat-message {
    cursor: pointer;
}

/* Message sélectionné - fond opaque sur toute la largeur avec pseudo-element */
.chat-message.selected::before {
    content: '';
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: -100vw;
    right: -100vw;
    background: rgba(139, 92, 246, 0.25);
    z-index: -1;
    pointer-events: none;
}

/* Barre de sélection en bas (WhatsApp style) */
.chat-selection-bar {
    position: absolute;
    bottom: 70px;
    background: #1e1e2e;
    border-radius: 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
    animation: slideUpBar 0.2s ease-out;
}

@keyframes slideUpBar {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.chat-sel-count {
    flex: 1;
    text-align: center;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.chat-sel-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: all 0.15s;
}

.chat-sel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-sel-btn i {
    font-size: 14px;
}

/* Bouton supprimer en rouge */
.chat-sel-btn:has(.fa-trash) {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.chat-sel-btn:has(.fa-trash):hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Bouton fermer */
.chat-sel-btn:has(.fa-times) {
    padding: 10px 12px;
}


/* ===== MODAL DE CONFIRMATION ===== */
.chat-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100002;
    animation: fadeIn 0.15s ease-out;
}

.chat-confirm-content {
    background: #1e1e2e;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.2s ease-out;
}

.chat-confirm-message {
    color: #fff;
    font-size: 15px;
    text-align: center;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.chat-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chat-confirm-cancel,
.chat-confirm-ok {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    flex: 1;
}

.chat-confirm-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-confirm-ok {
    background: #ef4444;
    color: #fff;
}

.chat-confirm-ok:hover {
    background: #dc2626;
}


/* ===== NOTIFICATION DE RÉACTION ===== */
.chat-reaction-notif {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #2a2a3e;
    color: #fff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100003;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.chat-reaction-notif.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chat-reaction-notif-emoji {
    font-size: 18px;
}



/* ===== CONVERSATIONS DE GROUPE ===== */

/* Indicateur nombre de participants dans le header */
.chat-group-members {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    display: block;
    margin-top: 2px;
}

/* Avatar groupe (icône users au lieu de user) */
.chat-avatar:has(.fa-users) {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
}

/* Modal ajouter des personnes */
.chat-add-people-modal {
    max-width: 400px;
    width: 95%;
}

.chat-group-name-input {
    margin-bottom: 16px;
}

.chat-group-name-input label {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 6px;
}

.chat-group-name-input input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-group-name-input input:focus {
    border-color: #8b5cf6;
}

.chat-current-participant {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.chat-current-participant > span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    display: block;
    margin-bottom: 8px;
}

.chat-participant-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-participant-badge {
    background: rgba(139, 92, 246, 0.3);
    color: #c4b5fd;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.chat-select-users-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 10px;
}

.chat-users-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-user-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-user-checkbox:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-user-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #8b5cf6;
    cursor: pointer;
}

.chat-user-checkbox-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.chat-user-checkbox-name {
    flex: 1;
    color: #fff;
    font-size: 14px;
}

.chat-visitor-badge {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.chat-no-users {
    padding: 30px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.chat-group-modal-footer {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-cancel-btn,
.chat-confirm-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.chat-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-confirm-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #fff;
}

.chat-confirm-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}

.chat-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* En mode groupe, afficher le nom même pour ses propres messages */
.chat-message-mine .chat-message-sender {
    font-size: 11px;
    margin-bottom: 4px;
}

/* Les couleurs des expéditeurs sont définies en inline via JavaScript */

/* Style conversation groupe dans la liste */
.chat-conv-item.is-group .chat-conv-avatar {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
}

.chat-conv-item.is-group .chat-conv-avatar i::before {
    content: "\f0c0"; /* fa-users */
}

/* Badge groupe dans la liste des conversations */
.chat-conv-group-badge {
    font-size: 9px;
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.2);
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
}


/* ========================================
   MODAL INFOS GROUPE
   ======================================== */

.chat-group-info-section {
    padding: 10px 0;
}

.chat-group-info-title {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    margin-bottom: 12px;
    padding: 0 5px;
}

.chat-group-participants-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.chat-group-participant {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
}

.chat-group-participant:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-group-participant.online {
    background: rgba(52, 211, 153, 0.08);
}

.chat-group-participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    position: relative;
    flex-shrink: 0;
}

.chat-group-participant-avatar i {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
}

.chat-group-participant-avatar .online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #34d399;
    border: 2px solid var(--chat-bg, #1e1e2e);
    border-radius: 50%;
}

.chat-group-participant-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-group-participant-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-group-admin-badge {
    font-size: 10px;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.chat-group-kick-btn {
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-group-participant:hover .chat-group-kick-btn {
    opacity: 1;
}

.chat-group-kick-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: scale(1.1);
}

.chat-group-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
}

.chat-group-leave-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.chat-group-leave-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.chat-group-leave-btn i {
    font-size: 14px;
}

/* Scrollbar pour la liste des participants */
.chat-group-participants-list::-webkit-scrollbar {
    width: 6px;
}

.chat-group-participants-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-group-participants-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-group-participants-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}


/* ========================================
   MODAL DE CONFIRMATION
   ======================================== */

.chat-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100020;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-confirm-modal.show {
    opacity: 1;
}

.chat-confirm-modal-content {
    background: linear-gradient(145deg, #2a2a3e 0%, #1e1e2e 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: confirmModalSlideIn 0.25s ease;
}

@keyframes confirmModalSlideIn {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.chat-confirm-modal-header {
    padding: 20px 20px 10px;
    text-align: center;
}

.chat-confirm-modal-header i {
    font-size: 40px;
    color: #fbbf24;
    margin-bottom: 10px;
    display: block;
}

.chat-confirm-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.chat-confirm-modal-body {
    padding: 10px 20px 20px;
    text-align: center;
}

.chat-confirm-modal-body p {
    margin: 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.5;
}

.chat-confirm-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chat-confirm-btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.chat-confirm-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.chat-confirm-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-confirm-btn.confirm {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.chat-confirm-btn.confirm:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    transform: translateY(-1px);
}


/* ========================================
   MESSAGES SYSTÈME DANS LE CHAT
   ======================================== */

.chat-system-message {
    display: flex;
    justify-content: center;
    padding: 8px 16px;
    margin: 12px 0;
}

.chat-system-message span {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 20px;
    text-align: center;
    max-width: 80%;
}


/* ========================================
   BOUTONS D'ACTION PARTICIPANTS GROUPE
   ======================================== */

.chat-group-participant-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-group-participant:hover .chat-group-participant-actions {
    opacity: 1;
}

.chat-group-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
}

.chat-group-action-btn.promote {
    color: rgba(251, 191, 36, 0.6);
}

.chat-group-action-btn.promote:hover {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    transform: scale(1.1);
}

.chat-group-action-btn.demote {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
}

.chat-group-action-btn.demote:hover {
    background: rgba(251, 191, 36, 0.3);
    transform: scale(1.1);
}

.chat-group-action-btn.kick {
    color: rgba(239, 68, 68, 0.6);
}

.chat-group-action-btn.kick:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: scale(1.1);
}

/* Badge créateur */
.chat-group-creator-badge {
    font-size: 10px;
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Ancien bouton kick (pour rétro-compatibilité) */
.chat-group-kick-btn {
    display: none;
}


/* ========================================
   RECHERCHE UTILISATEURS (AJOUT GROUPE)
   ======================================== */

.chat-search-users-container {
    position: relative;
    margin-bottom: 12px;
}

.chat-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.chat-search-input-wrapper i {
    position: absolute;
    left: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

.chat-search-input-wrapper input {
    width: 100%;
    padding: 12px 12px 12px 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-search-input-wrapper input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.chat-search-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-search-results {
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
}

.chat-search-hint,
.chat-search-loading,
.chat-search-no-results,
.chat-search-error {
    padding: 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
}

.chat-search-loading i {
    font-size: 20px;
    color: #6366f1;
}

.chat-search-error {
    color: #ef4444;
}

.chat-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-search-result-item:hover {
    background: rgba(99, 102, 241, 0.15);
}

.chat-search-result-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.chat-search-result-avatar i {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.chat-search-result-avatar.online {
    background: rgba(52, 211, 153, 0.15);
}

.chat-search-result-avatar .online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #34d399;
    border: 2px solid var(--card-bg, #1e1e2e);
    border-radius: 50%;
}

.chat-search-result-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-search-result-name {
    font-size: 14px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-offline-badge {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
}

.chat-search-result-add {
    background: rgba(99, 102, 241, 0.2);
    border: none;
    color: #818cf8;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.chat-search-result-item:hover .chat-search-result-add {
    opacity: 1;
}

.chat-search-result-add:hover {
    background: #6366f1;
    color: white;
    transform: scale(1.1);
}

/* Utilisateurs sélectionnés (tags) */
.chat-selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chat-selected-user-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    border: 1px solid rgba(99, 102, 241, 0.4);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 13px;
    color: white;
    animation: tagAppear 0.2s ease;
}

@keyframes tagAppear {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-selected-user-tag span {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-selected-user-tag button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.chat-selected-user-tag button:hover {
    color: #ef4444;
}

/* Scrollbar pour les résultats */
.chat-search-results::-webkit-scrollbar {
    width: 6px;
}

.chat-search-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}


/* ========================================
   MESSENGER MODAL
   ======================================== */

.messenger-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    animation: fadeIn 0.2s ease;
}

.messenger-container {
    background: linear-gradient(145deg, #1e1e2e 0%, #151521 100%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.messenger-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
}

.messenger-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.messenger-header h3 i {
    color: #a78bfa;
}

.messenger-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.messenger-close:hover {
    background: rgba(239, 68, 68, 0.5);
}

.messenger-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.messenger-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.messenger-tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
}

.messenger-tab.active {
    color: white;
    background: rgba(99, 102, 241, 0.2);
}

.messenger-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    border-radius: 2px 2px 0 0;
}

.messenger-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.messenger-panel {
    display: none;
    height: 100%;
    overflow-y: auto;
    max-height: calc(80vh - 130px);
}

.messenger-panel.active {
    display: block;
}

/* Liste des conversations */
.messenger-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.messenger-conv-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.messenger-conv-item.unread {
    background: rgba(99, 102, 241, 0.1);
}

/* Bouton supprimer conversation */
.messenger-conv-delete {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
}

.messenger-conv-item:hover .messenger-conv-delete {
    opacity: 1;
}

.messenger-conv-delete:hover {
    background: rgba(239, 68, 68, 0.5);
    color: white;
}

.messenger-conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(139, 92, 246, 0.4));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-size: 16px;
}

.messenger-conv-avatar.group {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(52, 211, 153, 0.4));
}

.messenger-conv-info {
    flex: 1;
    min-width: 0;
}

.messenger-conv-name {
    font-weight: 600;
    font-size: 14px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messenger-conv-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.messenger-conv-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.messenger-conv-badge {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Recherche */
.messenger-search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.messenger-search-wrapper i {
    color: rgba(255, 255, 255, 0.4);
}

#messengerSearchInput {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 14px;
    outline: none;
}

#messengerSearchInput::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.messenger-search-results {
    max-height: calc(80vh - 180px);
    overflow-y: auto;
}

.messenger-search-hint {
    padding: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

.messenger-search-hint i {
    display: block;
    font-size: 24px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.messenger-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.messenger-search-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.messenger-search-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    position: relative;
}

.messenger-search-avatar .online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #1e1e2e;
}

.messenger-search-info {
    flex: 1;
}

.messenger-search-name {
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.messenger-search-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

/* États vide et erreur */
.messenger-loading,
.messenger-empty,
.messenger-error {
    padding: 40px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.messenger-empty i,
.messenger-error i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.messenger-empty p,
.messenger-error p {
    font-size: 16px;
    margin: 0 0 5px 0;
    color: rgba(255, 255, 255, 0.7);
}

.messenger-empty span {
    font-size: 13px;
}

/* Scrollbar */
.messenger-panel::-webkit-scrollbar,
.messenger-search-results::-webkit-scrollbar {
    width: 6px;
}

.messenger-panel::-webkit-scrollbar-track,
.messenger-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.messenger-panel::-webkit-scrollbar-thumb,
.messenger-search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Mobile */
@media (max-width: 480px) {
    .messenger-container {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}
