/* copy-message.css - Styles pour le bouton de copie des messages */

/* Conteneur du message avec bouton de copie */
.message.assistant .message-bubble {
    position: relative;
    z-index: 999999;
    padding-right: 45px; /* Espace pour le bouton */
}

/* Bouton de copie */
.copy-button {
    position: absolute;
    bottom: 6px;
    right: 5px; 
    margin-left: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
    z-index: 100;
}

/* Afficher le bouton au survol du message */
.message.assistant:hover .copy-button {
    opacity: 1;
    transform: scale(1);
}

/* Toujours afficher sur mobile/tablette */
@media (max-width: 1024px) {
    .copy-button {
        opacity: 0.7;
        transform: scale(1);
    }
    
    .message.assistant:hover .copy-button {
        opacity: 1;
    }
}

/* États du bouton */
.copy-button:hover {
    background: #f8f9fa;
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
    transform: scale(1.1);
}

.copy-button:active {
    transform: scale(0.95);
}

/* Icône du bouton */
.copy-button i {
    font-size: 14px;
    color: #666;
    transition: color 0.3s ease;
}

.copy-button:hover i {
    color: #3498db;
}

/* État succès */
.copy-button.copy-success {
    background: #d4edda;
    border-color: #28a745;
    animation: successPulse 0.5s ease;
}

.copy-button.copy-success i {
    color: #28a745;
}

/* État erreur */
.copy-button.copy-error {
    background: #f8d7da;
    border-color: #dc3545;
    animation: shake 0.5s ease;
}

.copy-button.copy-error i {
    color: #dc3545;
}

/* Animations */
@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

/* Tooltip personnalisé pour le bouton */
.copy-button::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    padding: 5px 10px;
    background: #333;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 5px;
}

.copy-button::after {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 5px solid transparent;
    border-top-color: #333;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.copy-button:hover::before,
.copy-button:hover::after {
    opacity: 1;
}

/* Ajustements pour les messages longs */
.message.assistant .message-bubble.long-message {
    padding-right: 60px;
}

.message.assistant .message-bubble.long-message .copy-button {
    position: sticky;
    top: 10px;
    float: right;
    margin-left: 10px;
    margin-bottom: 10px;
    z-index: 999999;
}

/* Intégration avec les messages existants */
.message.assistant .message-bubble {
    min-height: 40px; /* Assurer un minimum de hauteur pour le bouton */
}

/* Animation d'apparition du bouton */
.copy-button {
    animation: fadeInScale 0.3s ease forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 0; /* Reste invisible jusqu'au survol */
        transform: scale(0.8);
    }
}

.message.assistant:hover .copy-button {
    z-index: 999999;
    animation: fadeInScaleHover 0.3s ease forwards;
}

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

/* Support pour le focus clavier (accessibilité) */
.copy-button:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    opacity: 1;
    transform: scale(1);
}

/* Ajustements pour mobile */
@media (max-width: 480px) {
    .copy-button {
        width: 35px;
        height: 35px;
        top: 5px;
        right: 5px;
    }
    
    .message.assistant .message-bubble {
        padding-right: 50px;
    }
    
    .copy-button i {
        font-size: 16px;
    }
}