/* Animations pour le chat */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Container des messages - style Apple Messages */
[data-generic-chat-target="messagesContainer"] {
    background: #ffffff !important;
    border: none !important;
    padding: 16px !important;
}

/* Scrollbar personnalisée pour le chat */
[data-generic-chat-target="messagesContainer"]::-webkit-scrollbar {
    width: 6px;
}

[data-generic-chat-target="messagesContainer"]::-webkit-scrollbar-track {
    background: transparent;
}

[data-generic-chat-target="messagesContainer"]::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 3px;
}

[data-generic-chat-target="messagesContainer"]::-webkit-scrollbar-thumb:hover {
    background: #aeaeb2;
}

/* Bulles de messages - style Apple */
.chat-message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    margin-bottom: 2px;
}

/* Messages de l'utilisateur (bleu, à droite) */
.chat-message-own .chat-message-bubble {
    background: #007AFF;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Messages des autres (gris, à gauche) */
.chat-message-other .chat-message-bubble {
    background: #E5E5EA;
    color: #000000;
    border-bottom-left-radius: 4px;
}

/* Texte dans les bulles */
.chat-message-content {
    font-size: 15px;
    line-height: 1.4;
    margin: 0;
}

/* Métadonnées (nom, organisme) */
.chat-message-meta {
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 4px;
}

.chat-message-own .chat-message-meta {
    color: rgba(255, 255, 255, 0.8);
}

.chat-message-other .chat-message-meta {
    color: rgba(0, 0, 0, 0.6);
}

/* Timestamp */
.chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.chat-message-own .chat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

.chat-message-other .chat-message-time {
    color: rgba(0, 0, 0, 0.5);
}

/* Groupement des messages */
.chat-message-group {
    margin-bottom: 12px;
}

/* Badge du nombre de messages (en-tête de carte) */
.chat-message-count-badge {
    font-size: 11px;
    font-weight: 500;
    color: #94A3B8;
    background: #F8FAFC;
    padding: 4px 9px;
    border-radius: 20px;
    border: 1px solid #F1F5F9;
    white-space: nowrap;
}

/* État vide (aucun message) */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    text-align: center;
    color: #94A3B8;
    padding: 20px;
}

.chat-empty-state p {
    margin: 0;
}

.chat-empty-state-icon {
    width: 52px;
    height: 52px;
    background: #F8FAFC;
    border: 1.5px dashed #CBD5E1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #CBD5E1;
}

/* Formulaire d'envoi - style Apple */
.chat-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: #f6f6f6;
    border-radius: 20px;
}

.chat-input-form input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 15px;
    outline: none;
}

.chat-input-form input::placeholder {
    color: #8e8e93;
}

.chat-input-form button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #007AFF;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.chat-input-form button:hover {
    background: #0051D5;
}

.chat-input-form button:disabled {
    background: #c7c7cc;
    cursor: not-allowed;
}

/* Bouton joindre un fichier */
.chat-attach-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: #e5e5ea;
    color: #007AFF;
}

/* Aperçu du fichier sélectionné avant envoi */
.chat-file-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin-bottom: 6px;
    background: #f6f6f6;
    border-radius: 12px;
    font-size: 13px;
    color: #3c3c43;
}

.chat-file-preview-remove {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #8e8e93;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
}

.chat-file-preview-remove:hover {
    color: #ff3b30;
}

/* Pièces jointes dans les bulles de messages */
.chat-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: inherit;
    font-size: 13px;
}

.chat-message-own .chat-attachment {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.chat-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-size {
    opacity: 0.7;
    flex-shrink: 0;
}

.chat-attachment-image {
    display: block;
    margin-top: 6px;
    padding: 0;
    background: none;
}

.chat-attachment-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    display: block;
}

/* Animation des points de frappe */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6c757d;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.typing-indicator {
    transition: opacity 0.3s;
}

/* Bouton nouveaux messages */
.new-messages-button {
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

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

/* ===== Dark Mode Chat Styles ===== */
[data-bs-theme="dark"] [data-generic-chat-target="messagesContainer"] {
    background: #212529 !important;
}

[data-bs-theme="dark"] [data-generic-chat-target="messagesContainer"]::-webkit-scrollbar-thumb {
    background: #495057;
}

[data-bs-theme="dark"] [data-generic-chat-target="messagesContainer"]::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

[data-bs-theme="dark"] .chat-message-other .chat-message-bubble {
    background: #495057;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .chat-message-other .chat-message-meta {
    color: rgba(255, 255, 255, 0.6);
}

[data-bs-theme="dark"] .chat-message-other .chat-message-time {
    color: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="dark"] .chat-input-form {
    background: #343a40;
}

[data-bs-theme="dark"] .chat-input-form input {
    color: #dee2e6;
}

[data-bs-theme="dark"] .chat-input-form input::placeholder {
    color: #6c757d;
}

[data-bs-theme="dark"] .chat-attach-btn {
    color: #adb5bd;
}

[data-bs-theme="dark"] .chat-attach-btn:hover {
    background: #495057;
    color: #fff;
}

[data-bs-theme="dark"] .chat-file-preview {
    background: #343a40;
    color: #dee2e6;
}

