/* Chatbot ELYD - Style personnalisé */
#elyd-chatbot {
    position: fixed;
    bottom: 20px;
    right: 90px; /* Déplacé vers la gauche pour éviter le chevauchement avec back-to-top */
    z-index: 1000;
    font-family: "Hanken Grotesk", sans-serif;
}

/* Bouton du chatbot */
.chat-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #141414 0%, #1F1F25 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(20, 20, 20, 0.3);
    transition: all 0.3s ease;
    position: relative;
    color: #fff;
}

.chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(20, 20, 20, 0.4);
    background: linear-gradient(135deg, #1F1F25 0%, #141414 100%);
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #3EB75E;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Fenêtre du chatbot */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(116, 120, 124, 0.1);
}

.chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header du chat */
.chat-header {
    background: linear-gradient(135deg, #141414 0%, #1F1F25 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3EB75E;
}

.chat-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    color: #3EB75E;
    font-weight: 500;
}

.chat-close {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.chat-close svg {
    width: 18px;
    height: 18px;
}

/* Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden; /* Empêcher le scroll horizontal */
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafafa;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(116, 120, 124, 0.3);
    border-radius: 2px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
    word-wrap: break-word; /* Forcer le retour à la ligne */
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bot-message {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #141414 0%, #1F1F25 100%);
    color: #3EB75E;
}

.user-message .message-avatar {
    background: #3EB75E;
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0; /* Important pour éviter le débordement */
}

.message-content p {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 0 0 4px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #141414;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    word-wrap: normal; /* Forcer le retour à la ligne */
    overflow-wrap: normal; /* Support moderne */
    hyphens: none; /* Césure automatique */
    max-width: 100%; /* Empêcher le débordement */
}

.user-message .message-content p {
    background: #3EB75E;
    color: white;
}

/* Styles pour les liens dans les messages */
.message-content p a {
    color: inherit;
    text-decoration: underline;
    word-break: break-all; /* Forcer la coupure des liens longs */
}

.bot-message .message-content p a {
    color: #3EB75E;
}

.user-message .message-content p a {
    color: white;
}

.message-time {
    font-size: 11px;
    color: #74787C;
    padding: 0 4px;
}

/* Zone de saisie */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid rgba(116, 120, 124, 0.1);
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 2px solid rgba(116, 120, 124, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: "Hanken Grotesk", sans-serif;
    transition: all 0.3s ease;
    background: #fafafa;
}

#chat-input:focus {
    outline: none;
    border-color: #3EB75E;
    background: white;
}

.chat-send {
    background: #3EB75E;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.chat-send:hover {
    background: #2ea84e;
    transform: scale(1.05);
}

.chat-send:disabled {
    background: #74787C;
    cursor: not-allowed;
    transform: none;
}

/* Indicateur de frappe */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    align-items: center;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #74787C;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 480px) {
    #elyd-chatbot {
        right: 15px; /* Même position horizontale que le bouton back-to-top */
        bottom: 15px; /* Chatbot en bas */
    }
    
    .chat-window {
        width: calc(100vw - 30px); /* Largeur adaptée avec plus de marge */
        height: 60vh; /* Hauteur réduite pour ne pas masquer le contenu */
        right: 0;
        bottom: 85px; /* Position ajustée */
        border-radius: 12px;
        max-width: 350px; /* Largeur maximale réduite */
        max-height: 500px; /* Hauteur maximale */
        margin-right: 15px; /* Marge pour éviter de toucher le bord */
        overflow: hidden; /* Empêcher tout débordement */
    }
    
    .chat-header {
        padding: 12px 15px; /* Padding réduit */
    }
    
    .chat-header-content {
        gap: 10px;
    }
    
    .chat-info h4 {
        font-size: 14px;
    }
    
    .chat-close {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .chat-close svg {
        width: 16px;
        height: 16px;
    }
    
    .chat-messages {
        padding: 12px; /* Padding réduit */
        flex: 1;
        min-height: 0; /* Important pour le scroll */
        overflow-x: hidden; /* Forcer pas de scroll horizontal */
    }
    
    .chat-input-container {
        padding: 12px 15px; /* Padding réduit */
        flex-shrink: 0; /* Empêche la compression */
    }
    
    /* Messages spécifiques mobile */
    .message {
        max-width: 90%; /* Plus de place sur mobile */
    }
    
    .message-content p {
        font-size: 13px; /* Texte légèrement plus petit */
        padding: 10px 12px; /* Padding réduit */
        word-break: break-word; /* Forcer la coupure des mots longs */
        overflow-wrap: anywhere; /* Coupure agressive si nécessaire */
    }
    
    /* Liens sur mobile */
    .message-content p a {
        word-break: break-all; /* Forcer la coupure des liens */
        display: inline-block;
        max-width: 100%;
    }
    
    /* Zone de saisie mobile */
    #chat-input {
        font-size: 14px; /* Taille adaptée mobile */
        padding: 10px 14px;
    }
    
    /* Bouton back-to-top au-dessus du chatbot sur mobile */
    .progress-wrap {
        right: 15px !important;
        bottom: 85px !important; /* Au-dessus du chatbot */
        z-index: 10001 !important; /* Au-dessus du chatbot */
    }
}

/* Ajustement pour les écrans moyens */
@media (max-width: 768px) and (min-width: 481px) {
    #elyd-chatbot {
        right: 20px; /* Moins d'espace sur tablette */
        bottom: 20px;
    }
    
    .chat-window {
        width: 340px;
        height: 480px;
    }
}

/* Animations d'entrée */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.new {
    animation: fadeInUp 0.4s ease-out;
} 