/* ------------------------------------------------------------------
   VARIABLES & RESET
   ------------------------------------------------------------------ */
:root {
    /* Palette de couleurs "Apaisement & Espoir" */
    --primary-color: #5A7D7C;       /* Vert Sauge foncé (Header) */
    --secondary-color: #A4C3B2;     /* Vert d'eau doux */
    --bg-color: #E6EBE0;            /* Fond global très pâle */
    
    --msg-bot-bg: #FFFFFF;          /* Bulle Barnabé (Blanc pur) */
    --msg-bot-text: #333333;
    
    --msg-user-bg: #CCE3DE;         /* Bulle Adeline (Vert menthe très doux) */
    --msg-user-text: #1A2E2C;

    --input-bg: #FFFFFF;
    --shadow-soft: 0 1px 2px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: #333;
    /* 100dvh est crucial sur mobile pour gérer la barre d'adresse dynamique */
    height: 100dvh; 
    overflow: hidden; /* Empêche le scroll global, seul le chat scrolle */
}

/* ------------------------------------------------------------------
   LAYOUT GLOBAL
   ------------------------------------------------------------------ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 600px; /* Limite la largeur sur PC pour garder l'aspect mobile */
    margin: 0 auto;   /* Centre sur PC */
    background-color: #f0f2f5;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* ------------------------------------------------------------------
   HEADER
   ------------------------------------------------------------------ */
.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 10;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    border: 2px solid rgba(255,255,255,0.5);
}

.header-info h1 {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.status {
    font-size: 0.8rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Bouton d'installation PWA */
.install-btn {
    margin-left: auto;
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.install-btn:active {
    transform: scale(0.95);
}

/* ------------------------------------------------------------------
   ZONE DE CHAT (MAIN)
   ------------------------------------------------------------------ */
.chat-window {
    flex: 1; /* Prend tout l'espace restant */
    padding: 20px;
    overflow-y: auto; /* Active le scroll vertical */
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgb3BhY2l0eT0iMC4wNSI+PHBhdGggZD0iTTEwIDBMMCAxMEwxMCAyMEwyMCAxMHoiIGZpbGw9IiM1QTdEN0MiLz48L2c+PC9zdmc+'); /* Motif subtil */
}

/* Scrollbar jolie pour Windows/Chrome */
.chat-window::-webkit-scrollbar {
    width: 6px;
}
.chat-window::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.1);
    border-radius: 3px;
}

/* ------------------------------------------------------------------
   BULLES DE MESSAGES
   ------------------------------------------------------------------ */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    /* Animation d'apparition douce */
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    box-shadow: var(--shadow-soft);
    word-wrap: break-word; /* Coupe les mots trop longs */
}

/* Style Barnabé (Aligné gauche) */
.message-bot {
    align-self: flex-start;
}
.message-bot .bubble {
    background-color: var(--msg-bot-bg);
    color: var(--msg-bot-text);
    border-top-left-radius: 4px; /* Petit coin carré comme WhatsApp */
}

/* Style Adeline (Aligné droite) */
.message-user {
    align-self: flex-end;
}
.message-user .bubble {
    background-color: var(--msg-user-bg);
    color: var(--msg-user-text);
    border-top-right-radius: 4px;
}

.meta {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
    margin-left: 5px;
    align-self: flex-start;
}
.message-user .meta {
    align-self: flex-end;
    margin-right: 5px;
}

/* ------------------------------------------------------------------
   ZONE DE SAISIE (FOOTER)
   ------------------------------------------------------------------ */
.chat-input-area {
    background-color: #f0f2f5;
    padding: 10px;
    display: flex;
    align-items: center;
    border-top: 1px solid rgba(0,0,0,0.05);
}

#chat-form {
    display: flex;
    width: 100%;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 24px;
    border: none;
    outline: none;
    font-size: 1rem;
    background: white;
    box-shadow: var(--shadow-soft);
}

#send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: background-color 0.2s;
}
#send-btn:hover {
    background-color: #496665;
}

/* ------------------------------------------------------------------
   ANIMATION "EN TRAIN D'ÉCRIRE" (...)
   ------------------------------------------------------------------ */
.hidden {
    display: none !important;
}

.typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #b0b0b0;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}