/* =============================================
   MOUSSA AI — Widget Chat Flottant
   ============================================= */

/* Variables */
:root {
    --ai-primary: #1c93e5;
    --ai-primary-dark: #1578c0;
    --ai-bg: #141414;
    --ai-panel-bg: #1a1a1a;
    --ai-message-bg: #242424;
    --ai-bot-bubble: #1e2a38;
    --ai-user-bubble: #1c93e5;
    --ai-text: #e8e8e8;
    --ai-text-muted: #888;
    --ai-border: #2e2e2e;
    --ai-radius: 16px;
    --ai-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    --ai-btn-size: 58px;
}

/* ---- Bouton flottant ---- */
#moussa-ai-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: var(--ai-btn-size);
    height: var(--ai-btn-size);
    border-radius: 50%;
    background: linear-gradient(135deg, #1c93e5 0%, #0e6db8 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 4px 20px rgba(28, 147, 229, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    outline: none;
}

#moussa-ai-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(28, 147, 229, 0.7);
}

#moussa-ai-btn:active {
    transform: scale(0.96);
}

#moussa-ai-btn svg {
    width: 26px;
    height: 26px;
    transition: opacity 0.2s ease;
}

#moussa-ai-btn .ai-icon-close {
    display: none;
}

#moussa-ai-btn.is-open .ai-icon-chat {
    display: none;
}

#moussa-ai-btn.is-open .ai-icon-close {
    display: block;
}

/* Badge notification */
#moussa-ai-btn .ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid #141414;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ai-badge-pulse 2s ease infinite;
}

@keyframes ai-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ---- Panneau Chat ---- */
#moussa-ai-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--ai-panel-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid var(--ai-border);
    z-index: 9997;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.25s ease;
}

#moussa-ai-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header du panneau ---- */
.ai-header {
    background: linear-gradient(135deg, #1c93e5 0%, #0e6db8 100%);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    border-radius: var(--ai-radius) var(--ai-radius) 0 0;
}

.ai-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.ai-header-avatar img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.ai-header-info {
    flex: 1;
}

.ai-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    font-family: 'Roboto', sans-serif;
}

.ai-header-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.ai-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2ecc71;
    display: inline-block;
    animation: ai-pulse 2s ease infinite;
}

@keyframes ai-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-header-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    outline: none;
}

.ai-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---- Zone de messages ---- */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: var(--ai-border);
    border-radius: 4px;
}

/* ---- Messages ---- */
.ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: ai-msg-in 0.25s ease;
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.ai-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ai-text);
    word-break: break-word;
    font-family: 'Roboto', sans-serif;
}

.ai-msg.bot .ai-msg-bubble {
    background: var(--ai-bot-bubble);
    border-radius: 4px 14px 14px 14px;
    border: 1px solid #263545;
}

.ai-msg.user .ai-msg-bubble {
    background: var(--ai-user-bubble);
    border-radius: 14px 4px 14px 14px;
    color: #fff;
}

.ai-msg-time {
    font-size: 10px;
    color: var(--ai-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

/* ---- Loader typing ---- */
.ai-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ai-bot-bubble);
    border-radius: 4px 14px 14px 14px;
    border: 1px solid #263545;
    width: fit-content;
}

.ai-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--ai-primary);
    border-radius: 50%;
    animation: ai-bounce 1.2s ease infinite;
}

.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* ---- Message d'accueil (chips suggestions) ---- */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    max-width: 100%;
}

.ai-suggestion-chip {
    background: #1e2a38;
    border: 1px solid var(--ai-primary);
    color: var(--ai-primary);
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: 'Roboto', sans-serif;
    white-space: nowrap;
}

.ai-suggestion-chip:hover {
    background: var(--ai-primary);
    color: #fff;
}

/* ---- Zone de saisie ---- */
.ai-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--ai-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--ai-panel-bg);
    flex-shrink: 0;
}

#moussa-ai-input {
    flex: 1;
    background: var(--ai-message-bg);
    border: 1px solid var(--ai-border);
    border-radius: 22px;
    color: var(--ai-text);
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: 'Roboto', sans-serif;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s;
    overflow-y: auto;
}

#moussa-ai-input::placeholder {
    color: var(--ai-text-muted);
}

#moussa-ai-input:focus {
    border-color: var(--ai-primary);
}

#moussa-ai-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ai-primary);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    outline: none;
}

#moussa-ai-send:hover:not(:disabled) {
    background: var(--ai-primary-dark);
    transform: scale(1.08);
}

#moussa-ai-send:disabled {
    background: #2e2e2e;
    cursor: not-allowed;
}

#moussa-ai-send svg {
    width: 18px;
    height: 18px;
}

/* ---- Footer ---- */
.ai-footer {
    padding: 6px 14px 10px;
    text-align: center;
    font-size: 10.5px;
    color: var(--ai-text-muted);
    flex-shrink: 0;
}

/* ---- Responsive mobile ---- */
@media (max-width: 480px) {
    #moussa-ai-panel {
        right: 12px;
        bottom: 90px;
        width: calc(100vw - 24px);
        height: 70vh;
    }

    #moussa-ai-btn {
        right: 16px;
        bottom: 20px;
    }
}
