/* ============================================
   ESTG-BENIN — CHATBOT IA
   Feuille de style pour le widget de chat
   ============================================ */

/* ============================================
   CONTENEUR PRINCIPAL
   ============================================ */
.ai-chatbot {
    position: fixed;
    bottom: 90px;
    right: 30px;
    z-index: 99998;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ============================================
   BOUTON FLOTTANT (pour ouvrir le chat)
   ============================================ */
.ai-chat-toggle {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    position: relative;
    box-shadow: 
        0 8px 25px rgba(30, 58, 138, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 
        0 12px 35px rgba(30, 58, 138, 0.55),
        0 4px 10px rgba(0, 0, 0, 0.2);
}

.ai-chat-toggle:active {
    transform: scale(0.95);
}

/* Badge de notification */
.ai-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #E8112D;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(232, 17, 45, 0.5);
    animation: aiPulseBadge 2s infinite;
}

@keyframes aiPulseBadge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(232, 17, 45, 0.5);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 4px 15px rgba(232, 17, 45, 0.8);
    }
}

.ai-chat-toggle.hidden .ai-chat-badge {
    display: none;
}

/* ============================================
   FENÊTRE DE CHAT
   ============================================ */
.ai-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: 75vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.2),
        0 8px 25px rgba(30, 58, 138, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    animation: aiSlideUp 0.3s ease;
}

@keyframes aiSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-window.active {
    display: flex;
}

/* ============================================
   EN-TÊTE DU CHAT
   ============================================ */
.ai-chat-header {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ai-chat-header strong {
    font-size: 0.9rem;
    display: block;
    line-height: 1.2;
}

.ai-chat-header small {
    font-size: 0.72rem;
    opacity: 0.85;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-header small::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px #4ade80;
}

.ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ============================================
   ZONE DES MESSAGES
   ============================================ */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Scrollbar personnalisée */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   MESSAGES
   ============================================ */
.ai-message {
    display: flex;
    animation: aiMessageIn 0.3s ease;
}

@keyframes aiMessageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.86rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-message-bot .ai-message-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ai-message-user .ai-message-content {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.25);
}

/* Indicateur de frappe */
.ai-message-typing .ai-message-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom-left-radius: 4px;
}

.ai-typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 5px;
}

.ai-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #6b7280;
    animation: aiTyping 1.4s infinite;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aiTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ============================================
   ZONE DE SAISIE
   ============================================ */
.ai-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    padding: 10px 16px;
    font-size: 0.86rem;
    outline: none;
    font-family: inherit;
    transition: all 0.3s ease;
    color: #1f2937;
    background: #f9fafb;
}

.ai-chat-input:focus {
    border-color: #1e3a8a;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.ai-chat-input::placeholder {
    color: #9ca3af;
}

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(30, 58, 138, 0.45);
}

.ai-chat-send:active {
    transform: scale(0.95);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.2);
}

/* ============================================
   RESPONSIVE — TABLETTE
   ============================================ */
@media (max-width: 768px) {
    .ai-chatbot {
        bottom: 85px;
        right: 20px;
    }

    .ai-chat-window {
        width: 350px;
        height: 500px;
    }

    .ai-chat-toggle {
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
    }
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 576px) {
    .ai-chatbot {
        bottom: 80px;
        right: 15px;
    }

    .ai-chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
    }

    .ai-chat-badge {
        width: 18px;
        height: 18px;
        font-size: 0.65rem;
    }

    .ai-chat-window {
        position: fixed;
        bottom: 140px;
        right: 15px;
        left: 15px;
        width: auto;
        max-width: none;
        height: calc(100vh - 200px);
        max-height: 520px;
    }

    .ai-chat-header {
        padding: 12px;
    }

    .ai-chat-avatar {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .ai-chat-header strong {
        font-size: 0.85rem;
    }

    .ai-chat-message-content,
    .ai-message-content {
        max-width: 88%;
        font-size: 0.84rem;
        padding: 9px 13px;
    }

    .ai-chat-input {
        font-size: 0.84rem;
        padding: 9px 14px;
    }

    .ai-chat-send {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   TRÈS PETIT MOBILE
   ============================================ */
@media (max-width: 400px) {
    .ai-chat-toggle {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
    }

    .ai-chat-window {
        bottom: 130px;
        height: calc(100vh - 180px);
    }

    .ai-chat-header {
        padding: 10px;
    }

    .ai-chat-messages {
        padding: 12px;
        gap: 10px;
    }

    .ai-chat-input-area {
        padding: 10px;
    }

    .ai-chat-input {
        font-size: 0.82rem;
        padding: 8px 12px;
    }

    .ai-chat-send {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
}

/* ============================================
   MODE SOMBRE (OPTIONNEL)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Désactivé par défaut, décommentez si vous voulez l'activer */
    /*
    .ai-chat-window {
        background: #1f2937;
        border-color: #374151;
    }
    .ai-chat-messages {
        background: #111827;
    }
    .ai-message-bot .ai-message-content {
        background: #1f2937;
        border-color: #374151;
        color: #e5e7eb;
    }
    .ai-chat-input-area {
        background: #1f2937;
        border-top-color: #374151;
    }
    .ai-chat-input {
        background: #111827;
        border-color: #374151;
        color: #e5e7eb;
    }
    */
}

/* ============================================
   ACCESSIBILITÉ — Réduction des animations
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .ai-chat-toggle,
    .ai-chat-window,
    .ai-message,
    .ai-chat-send,
    .ai-chat-close,
    .ai-chat-badge {
        animation: none !important;
        transition: none !important;
    }
}