/* ============================================================
   CHATBOT IA — ESMA Concours Créa 2026
   Widget flottant (bas droite)
   ============================================================ */

/* --- BOUTON FLOTTANT --- */
#chatbot-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9990;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #FE5516;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(254, 85, 22, 0.5);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    animation: chatBtnAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 2.5s both;
}

@keyframes chatBtnAppear {
    from { transform: scale(0) rotate(-180deg); opacity: 0; }
    to   { transform: scale(1) rotate(0deg);    opacity: 1; }
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(254, 85, 22, 0.65);
}

#chatbot-toggle.open {
    background: #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

#chatbot-toggle .chat-icon,
#chatbot-toggle .close-icon {
    position: absolute;
    transition: opacity 0.25s, transform 0.25s;
    color: #fff;
}
#chatbot-toggle .close-icon { opacity: 0; transform: rotate(90deg) scale(0.5); }
#chatbot-toggle.open .chat-icon  { opacity: 0; transform: rotate(-90deg) scale(0.5); }
#chatbot-toggle.open .close-icon { opacity: 1; transform: rotate(0deg) scale(1); }

/* Badge notification */
#chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #fff;
    color: #FE5516;
    font-size: 0.6rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.15); }
}
#chatbot-badge.hidden { display: none; }

/* --- FENÊTRE DU CHAT --- */
#chatbot-window {
    position: fixed;
    bottom: 6.5rem;
    right: 2rem;
    z-index: 9989;
    width: 340px;
    max-height: 520px;
    background: #0D0D0D;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
    transform-origin: bottom right;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
}

#chatbot-window.hidden {
    transform: scale(0.85) translateY(10px);
    opacity: 0;
    pointer-events: none;
}

/* --- EN-TÊTE --- */
.chatbot-header {
    background: linear-gradient(135deg, #1a1a1a, #111);
    border-bottom: 1px solid rgba(254, 85, 22, 0.2);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.chatbot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(254, 85, 22, 0.15);
    border: 1.5px solid rgba(254, 85, 22, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.chatbot-header-info { flex: 1; }
.chatbot-header-name {
    font-family: 'Oswald', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.03em;
}
.chatbot-header-status {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.1rem;
}
.chatbot-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: statusPulse 2.5s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* --- ZONE DE MESSAGES --- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* Bulles de message */
.chat-msg {
    display: flex;
    gap: 0.5rem;
    animation: msgAppear 0.3s ease;
}
@keyframes msgAppear {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user { flex-direction: row-reverse; }

.chat-msg-bubble {
    max-width: 78%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    line-height: 1.5;
}

.chat-msg.bot .chat-msg-bubble {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
    background: #FE5516;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Avatar bot */
.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(254, 85, 22, 0.12);
    border: 1px solid rgba(254, 85, 22, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    align-self: flex-end;
}

/* Indicateur "en train d'écrire" */
.chat-typing {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.chat-typing-dots {
    display: flex;
    gap: 4px;
    padding: 0.6rem 0.9rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.chat-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: typingDot 1.2s ease-in-out infinite;
}
.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%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* Questions suggérées */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.5rem;
}
.chat-suggestion-btn {
    background: rgba(254, 85, 22, 0.08);
    border: 1px solid rgba(254, 85, 22, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.chat-suggestion-btn:hover {
    background: rgba(254, 85, 22, 0.18);
    border-color: rgba(254, 85, 22, 0.4);
    color: #fff;
}

/* --- PIED DE PAGE (input) --- */
.chatbot-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

#chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    padding: 0.55rem 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
}
#chatbot-input::placeholder { color: rgba(255, 255, 255, 0.25); }
#chatbot-input:focus { border-color: rgba(254, 85, 22, 0.4); }

#chatbot-send {
    width: 36px;
    height: 36px;
    background: #FE5516;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    color: #fff;
}
#chatbot-send:hover { background: #e64d10; transform: scale(1.05); }
#chatbot-send:disabled { background: rgba(255,255,255,0.1); cursor: not-allowed; transform: none; }

.chatbot-footer-brand {
    text-align: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.18);
    padding: 0 1rem 0.5rem;
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 480px) {
    #chatbot-window {
        right: 0.75rem;
        bottom: 5.5rem;
        width: calc(100vw - 1.5rem);
        max-height: 60vh;
    }
    #chatbot-toggle {
        right: 1rem;
        bottom: 1rem;
    }
}
