/* === Chatbot BEA - Styles CSS === */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    margin: 0;
}

/* --- Bouton flottant 💬 --- */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 100px;
    background: #72683f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle:hover {
    background: #5a5332;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* --- Fenêtre chatbot flottante --- */
.chat-container {
    position: fixed;
    bottom: 90px;
    right: 100px;
    width: 350px;
    height: 480px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #72683f;
    display: none;
    animation: fadeIn 0.3s ease-in-out;
    z-index: 9999;
}

/* Animation ouverture */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- En-tête --- */
.chat-header {
    background: #72683f;
    color: white;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-weight: bold;
    min-height: 30px;
}

.chat-header img {
    height: 26px;
    width: auto;
}

/* Bouton fermeture */
#close-chat {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    line-height: 1;
}

#close-chat:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Sélecteur de langue */
.chat-lang-switch {
    margin-left: auto;
    margin-right: 10px;
}

.chat-lang-switch select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-lang-switch select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
}

.chat-lang-switch select:focus {
    outline: none;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.25);
}

.chat-lang-switch select option {
    background: #fff;
    color: #72683f;
    padding: 8px;
}

/* --- Zone de messages --- */
.chat-box {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Scrollbar custom */
.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Messages */
.bot-message,
.user-message {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    animation: messageSlide 0.2s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    background: #e6f0ff;
    color: #2c3e50;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background: #d9f7ff;
    color: #2c3e50;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    text-align: left;
    /* Toujours aligné à gauche pour la lisibilité */
}

/* Style pour les liens dans les messages */
.bot-message a {
    color: #72683f;
    text-decoration: underline;
    font-weight: 500;
}

.bot-message a:hover {
    color: #5a5332;
}

/* --- Zone de saisie --- */
.chat-input {
    display: flex;
    border-top: 1px solid #e0e0e0;
    background: white;
    padding: 0;
}

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

.chat-input input:focus {
    background: #fafafa;
}

.chat-input input::placeholder {
    color: #999;
}

.chat-input button {
    background: #72683f;
    color: white;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 60px;
}

.chat-input button:hover {
    background: #5a5332;
}

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

/* === Support RTL pour l'arabe === */
html[lang="ar"] .chat-container {
    right: auto;
    left: 100px;
}

html[lang="ar"] .chat-toggle {
    right: auto;
    left: 100px;
}

html[lang="ar"] .chat-header {
    flex-direction: row-reverse;
}

html[lang="ar"] .chat-lang-switch {
    margin-left: 0;
    margin-right: auto;
}

html[lang="ar"] .bot-message {
    align-self: flex-end;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
    text-align: right;
}

html[lang="ar"] .user-message {
    align-self: flex-start;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
    text-align: right;
}

html[lang="ar"] .chat-input {
    flex-direction: row-reverse;
}

/* === Responsive Design === */
@media (max-width: 768px) {
    .chat-toggle {
        right: 20px;
        bottom: 20px;
        width: 55px;
        height: 55px;
        font-size: 24px;
    }

    .chat-container {
        right: 10px;
        bottom: 80px;
        width: calc(100vw - 20px);
        max-width: 350px;
        height: 450px;
    }

    html[lang="ar"] .chat-toggle {
        right: auto;
        left: 20px;
    }

    html[lang="ar"] .chat-container {
        right: auto;
        left: 10px;
    }
}

@media (max-width: 480px) {
    .chat-container {
        height: 400px;
        bottom: 70px;
    }

    .chat-header {
        padding: 12px;
    }

    .chat-box {
        padding: 10px;
    }

    .bot-message,
    .user-message {
        padding: 8px 12px;
        font-size: 13px;
        max-width: 90%;
    }
}

/* États de chargement */
.chat-input button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
}

/* Indicateur de frappe */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #e6f0ff;
    border-radius: 12px;
    align-self: flex-start;
    max-width: 60px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #72683f;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}