/* ====================================================================
   CHATBOT DZ - WIDGET CHAT
   FICHIER : css/chat.css
   VERSION : FINAL.1
   DESCRIPTION : Barre du bas (Input) & Fenêtre Flottante (Style Gleap)
====================================================================
*/

/* -----------------------------------------------------------
   A. FENÊTRE DE CHAT FLOTTANTE (Hidden by default)
----------------------------------------------------------- */
.chat-window-container {
    position: fixed;
    bottom: 20px;
    right: 20px; /* Positionnée en bas à droite */
    width: 380px;
    height: 600px;
    max-height: 80vh; /* S'adapte aux petits écrans */
    background: #ffffff;
    border-radius: 24px; /* Arrondis modernes */
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.15), 
        0 5px 15px rgba(0,0,0,0.05),
        0 0 0 1px rgba(0,0,0,0.05); /* Bordure subtile */
    z-index: 10000; /* Au-dessus de tout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    /* État initial : Caché et légèrement décalé vers le bas */
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* État Actif : Visible */
.chat-window-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* --- Header de la fenêtre --- */
.chat-window-header {
    padding: 18px 24px;
    background: #ffffff;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* CORRECTION LOGO : Fond transparent pour le PNG */
.header-avatar {
    width: 45px;
    height: 45px;
    background: transparent !important; /* Plus de dégradé, transparent */
    box-shadow: none !important;        /* Plus d'ombre */
    border: none !important;
    
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Classe spécifique pour l'image du logo */
.chat-bot-avatar {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.header-info h4 {
    margin: 0;
    font-size: 1rem;
    color: #0f172a;
    font-weight: 700;
}

.header-info span {
    font-size: 0.8rem;
    color: #10b981; /* Vert "En ligne" */
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-info span::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

.close-chat-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-chat-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* --- Corps des messages --- */
.chat-window-body {
    flex: 1;
    padding: 20px;
    background-color: #ffffff;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Scrollbar fine */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* --- Footer (Input interne) --- */
.chat-window-footer {
    padding: 15px 20px;
    border-top: 1px solid #f3f4f6;
    background: #ffffff;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.footer-input-wrapper {
    flex: 1;
    background: #f8fafc;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    min-height: 44px;
    transition: 0.2s;
}

.footer-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #006AFF;
    box-shadow: 0 0 0 3px rgba(0, 106, 255, 0.1);
}

.footer-input-wrapper input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    color: #0f172a;
    font-family: inherit;
}

.footer-actions {
    display: flex;
    gap: 10px;
    margin-left: 8px;
    color: #94a3b8;
}
.footer-actions i { cursor: pointer; transition: 0.2s; }
.footer-actions i:hover { color: #006AFF; }

.send-circle-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #006AFF;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
}

.send-circle-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.powered-by {
    text-align: center;
    font-size: 0.7rem;
    color: #cbd5e1;
    padding-bottom: 8px;
    background: #fff;
}

/* -----------------------------------------------------------
   B. BARRE DE CHAT DU BAS (Visible par défaut)
----------------------------------------------------------- */
.fixed-chat-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 650px;
    background: #ffffff;
    border-radius: 100px; /* Forme de pilule */
    padding: 8px; /* Padding externe */
    box-shadow: 
        0 10px 30px -5px rgba(0,0,0,0.12), 
        0 0 0 1px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9990;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1); /* Animation fluide */
}

/* État Caché (Slide Down) */
.fixed-chat-bar.hidden {
    transform: translate(-50%, 120px); /* Descend hors de l'écran */
    opacity: 0;
    pointer-events: none;
}

.fixed-chat-bar:hover {
    transform: translate(-50%, -3px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
}

.chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    padding-left: 20px;
    height: 48px;
}

/* Le champ de saisie réel */
.bottom-chat-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 1rem;
    color: #0f172a;
    font-family: inherit;
    background: transparent;
}

.bottom-chat-input::placeholder {
    color: #94a3b8;
}

.chat-input-icons {
    display: flex;
    gap: 12px;
    margin-left: 10px;
    color: #94a3b8;
    font-size: 1.1rem;
    margin-right: 10px;
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #006AFF 0%, #6366F1 100%);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* -----------------------------------------------------------
   RESPONSIVE MOBILE
   CORRECTION : Hauteur dynamique (dvh) & Taille police (16px)
----------------------------------------------------------- */
@media (max-width: 768px) {
    .chat-window-container {
        width: 100%;
        height: 100%;
        /* Utilise dvh (Dynamic Viewport Height) pour gérer la barre d'adresse mobile */
        height: 100dvh; 
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        z-index: 20000; /* Au-dessus de tout */
    }
    
    /* Ajustement de la barre du bas (Input flottant) */
    .fixed-chat-bar {
        width: 94%; /* Un peu plus large sur mobile */
        bottom: 15px;
        padding: 6px 8px;
    }
    
    /* Important : 16px empêche le zoom automatique sur iOS lors du focus */
    .bottom-chat-input {
        font-size: 16px; 
    }
    
    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* -----------------------------------------------------------
   CORRECTIF GLOBAL : BULLES VISIBLES PAR DÉFAUT
----------------------------------------------------------- */
.chat-bubble {
    /* Force la visibilité par défaut */
    opacity: 1;
    transform: translateY(0) scale(1);
}