/* ===== LEA IA CHATBOT ===== */

#lea-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Bouton flottant */
.lea-chat-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #7C3AED;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(124, 58, 237, .45);
    transition: background .15s, transform .15s, box-shadow .15s;
    position: relative;
    outline: none;
}

.lea-chat-btn:hover {
    background: #6D28D9;
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(124, 58, 237, .55);
}

.lea-chat-btn:focus-visible {
    outline: 3px solid #a78bfa;
    outline-offset: 2px;
}

.lea-btn-icon {
    position: absolute;
    transition: opacity .2s, transform .2s;
}

.lea-btn-close {
    opacity: 0;
    transform: rotate(-90deg) scale(.7);
}

.lea-chat-btn[aria-expanded="true"] .lea-btn-open {
    opacity: 0;
    transform: rotate(90deg) scale(.7);
}

.lea-chat-btn[aria-expanded="true"] .lea-btn-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Notification badge */
.lea-chat-notif {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Fenetre de chat */
.lea-chat-box {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: leaChatIn .2s cubic-bezier(.34,1.56,.64,1);
}

.lea-chat-box[hidden] {
    display: none;
}

@keyframes leaChatIn {
    from { opacity: 0; transform: translateY(12px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.lea-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #7C3AED;
    color: #fff;
}

.lea-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lea-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lea-chat-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.lea-chat-status {
    font-size: 11px;
    color: rgba(255,255,255,.7);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lea-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ADE80;
    display: inline-block;
    animation: leaPulse 2s infinite;
}

@keyframes leaPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}

.lea-chat-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.lea-chat-close:hover { background: rgba(255,255,255,.2); }

/* Messages */
.lea-chat-messages {
    flex: 1;
    height: 300px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.lea-chat-messages::-webkit-scrollbar { width: 4px; }
.lea-chat-messages::-webkit-scrollbar-track { background: transparent; }
.lea-chat-messages::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 4px; }

/* Bulles */
.lea-msg {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
    animation: leaMsgIn .15s ease;
}

@keyframes leaMsgIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lea-msg-bot {
    background: #F3F4F6;
    color: #111827;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.lea-msg-user {
    background: #7C3AED;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Indicateur de frappe */
.lea-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #F3F4F6;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    align-items: center;
}

.lea-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9CA3AF;
    animation: leaDot 1.2s infinite;
}

.lea-typing span:nth-child(2) { animation-delay: .2s; }
.lea-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes leaDot {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-4px); }
}

/* Input */
.lea-chat-input-wrap {
    padding: 10px 12px;
    border-top: 1px solid #F3F4F6;
}

.lea-chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lea-chat-input {
    flex: 1;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: #111827;
    outline: none;
    transition: border-color .15s;
    background: #F9FAFB;
}

.lea-chat-input:focus {
    border-color: #7C3AED;
    background: #fff;
}

.lea-chat-send {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #7C3AED;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}

.lea-chat-send:hover { background: #6D28D9; }

/* Responsive */
@media (max-width: 400px) {
    #lea-chat {
        bottom: 16px;
        right: 16px;
    }

    .lea-chat-box {
        width: calc(100vw - 32px);
        right: 0;
    }
}
