/**
 * Assistant IA - Style Crypto.com Pro
 * Positionné à côté du bouton WhatsApp (en bas à gauche)
 */

/* ===== BOUTON IA FLOTTANT ===== */
.ai-assistant-trigger {
    position: fixed;
    bottom: 90px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1199FA 0%, #0066CC 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 20px rgba(17, 153, 250, 0.4),
        0 0 0 3px rgba(17, 153, 250, 0.1);
    z-index: 9995;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #fff;
    padding: 0;
    overflow: visible;
}

.ai-assistant-trigger:hover {
    transform: scale(1.1);
    box-shadow:
        0 8px 30px rgba(17, 153, 250, 0.5),
        0 0 0 6px rgba(17, 153, 250, 0.15);
}

.ai-assistant-trigger.active {
    background: linear-gradient(135deg, #0066CC, #004499);
}

.ai-trigger-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.ai-assistant-trigger.active .ai-trigger-icon {
    transform: rotate(180deg);
    opacity: 0;
}

/* Label "IA" sous le bouton */
.ai-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 800;
    color: #1199FA;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    white-space: nowrap;
}

/* Badge notification */
.ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #EF4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    border: 2px solid #0d1117;
    animation: aiBadgePop 0.3s ease;
}

@keyframes aiBadgePop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Pulse animation sur le bouton */
.ai-assistant-trigger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #1199FA;
    animation: aiPulse 2.5s infinite;
}

@keyframes aiPulse {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ===== FENETRE DE CHAT ===== */
.ai-chat-window {
    position: fixed;
    bottom: 160px;
    left: 24px;
    width: 390px;
    max-width: calc(100vw - 40px);
    height: 530px;
    max-height: calc(100vh - 200px);
    background: linear-gradient(180deg, #0F172A 0%, #0A0F1C 100%);
    border-radius: 20px;
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(17, 153, 250, 0.2),
        0 0 40px rgba(17, 153, 250, 0.08);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ===== HEADER ===== */
.ai-chat-header {
    background: linear-gradient(135deg, #1199FA 0%, #0066CC 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.ai-chat-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M20 20h20v20H20zM0 0h20v20H0z'/%3E%3C/g%3E%3C/svg%3E");
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #fff;
}

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

.ai-header-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.ai-header-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    display: inline-block;
    animation: aiStatusPulse 2s ease-in-out infinite;
}

@keyframes aiStatusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ai-chat-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

/* ===== ZONE MESSAGES ===== */
.ai-chat-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.ai-chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(17, 153, 250, 0.4);
    border-radius: 3px;
}

/* ===== MESSAGE ===== */
.ai-message {
    display: flex;
    gap: 10px;
    animation: aiMsgSlide 0.3s ease forwards;
}

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

.ai-message.user {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    color: #fff;
}

.ai-msg-avatar.bot {
    background: linear-gradient(135deg, #1199FA, #0066CC);
}

.ai-msg-avatar.user {
    background: linear-gradient(135deg, #10B981, #059669);
}

.ai-msg-content {
    max-width: 88%;
}

.ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.65;
    letter-spacing: 0.01em;
}

.ai-message.bot .ai-msg-bubble {
    background: rgba(255, 255, 255, 0.07);
    color: #E2E8F0;
    border-bottom-left-radius: 4px;
}

.ai-message.bot .ai-msg-bubble strong {
    color: #fff;
    font-weight: 600;
}

.ai-message.user .ai-msg-bubble {
    background: linear-gradient(135deg, #1199FA 0%, #0066CC 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg-time {
    font-size: 10px;
    color: #64748B;
    margin-top: 4px;
    padding: 0 4px;
}

.ai-message.user .ai-msg-time {
    text-align: right;
}

/* ===== INDICATEUR DE FRAPPE ===== */
.ai-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.ai-typing-indicator span {
    width: 7px;
    height: 7px;
    background: #64748B;
    border-radius: 50%;
    animation: aiTypingBounce 1.4s ease-in-out infinite;
}

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

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

/* ===== OPTIONS RAPIDES ===== */
.ai-quick-options {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 18px 12px;
}

.ai-quick-btn {
    padding: 8px 14px;
    background: rgba(17, 153, 250, 0.1);
    border: 1px solid rgba(17, 153, 250, 0.3);
    border-radius: 20px;
    color: #1199FA;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-quick-btn:hover {
    background: rgba(17, 153, 250, 0.2);
    border-color: #1199FA;
    transform: translateY(-2px);
}

/* ===== ZONE DE SAISIE ===== */
.ai-chat-input-area {
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 10px;
    align-items: center;
}

.ai-chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 11px 14px;
    color: #fff;
    font-size: 13.5px;
    outline: none;
    transition: all 0.2s ease;
}

.ai-chat-input-area input::placeholder {
    color: #64748B;
}

.ai-chat-input-area input:focus {
    border-color: #1199FA;
    background: rgba(17, 153, 250, 0.08);
}

.ai-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1199FA 0%, #0066CC 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(17, 153, 250, 0.4);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 768px) {
    .ai-assistant-trigger {
        bottom: 140px;
        left: 16px;
        width: 48px;
        height: 48px;
    }

    .ai-trigger-icon svg {
        width: 22px;
        height: 22px;
    }

    .ai-label {
        font-size: 9px;
        bottom: -16px;
    }

    .ai-chat-window {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .ai-chat-header {
        padding: 14px 16px;
    }

    .ai-chat-messages {
        padding: 14px;
    }

    .ai-quick-options {
        padding: 0 14px 10px;
    }

    .ai-chat-input-area {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    .ai-assistant-trigger {
        bottom: 140px;
        left: 16px;
    }
}

/* ===== MODE CLAIR ===== */
[data-theme="light"] .ai-chat-window,
body.light-theme .ai-chat-window {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(17, 153, 250, 0.1);
}

[data-theme="light"] .ai-message.bot .ai-msg-bubble,
body.light-theme .ai-message.bot .ai-msg-bubble {
    background: #F1F5F9;
    color: #1E293B;
}

[data-theme="light"] .ai-message.bot .ai-msg-bubble strong,
body.light-theme .ai-message.bot .ai-msg-bubble strong {
    color: #0F172A;
}

[data-theme="light"] .ai-chat-input-area,
body.light-theme .ai-chat-input-area {
    background: #F8FAFC;
    border-color: #E2E8F0;
}

[data-theme="light"] .ai-chat-input-area input,
body.light-theme .ai-chat-input-area input {
    background: #fff;
    border-color: #E2E8F0;
    color: #1E293B;
}

[data-theme="light"] .ai-typing-indicator,
body.light-theme .ai-typing-indicator {
    background: #F1F5F9;
}

[data-theme="light"] .ai-quick-btn,
body.light-theme .ai-quick-btn {
    background: rgba(17, 153, 250, 0.06);
}

/* ===== ANIMATION ENTREE ===== */
@keyframes aiWindowOpen {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Cacher l'ancien chatbot s'il existe encore */
.chatbot-trigger,
#chatbot-container {
    display: none !important;
}
