/* --- VARIABLES & RESET --- */
:root {
    --bg-color: #212121; /* Gris très foncé (style ChatGPT dark) */
    --chat-bg: #2f2f2f;
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --accent-color: #10a37f; /* Un vert/bleu moderne, ou choisis une autre couleur */
    --user-bubble: #3f4147;
    --ai-bubble: transparent;
    --input-bg: #40414f;
    --border-color: #565869;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    /* Utilisation d'une pile de polices modernes sans-serif */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    font-size: 16px;
}

/* --- HEADER (ASCII ART VERSION) --- */
header {
    background: var(--bg-color);
    padding: 15px 0; /* Un peu d'espace haut/bas */
    border-bottom: 1px solid var(--border-color);
    overflow: hidden; /* Coupe ce qui dépasse au cas où */
    display: flex;
    justify-content: center;
    align-items: center;
}

.ascii-logo {
    font-family: 'Courier New', Courier, monospace; /* Police obligatoire pour l'ASCII */
    font-weight: bold;
    color: var(--accent-color); /* Le vert Matrix */
    line-height: 10px; /* Resserre les lignes verticalement */
    font-size: 10px;   /* Taille par défaut pour PC */
    margin: 0;
    white-space: pre;  /* Garde les espaces intacts */
    text-shadow: 0 0 5px rgba(16, 163, 127, 0.5); /* Petit effet néon */
}

/* 📱 RESPONSIVE : Si l'écran est petit (Mobile), on réduit la taille */
@media (max-width: 600px) {
    .ascii-logo {
        font-size: 5px; /* Beaucoup plus petit sur téléphone */
        line-height: 6px;
    }
}
/* --- LOGIN AREA --- */
#login-area {
    background: var(--chat-bg);
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

#password-input {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 20px;
    width: 250px;
    text-align: center;
    outline: none;
    font-family: inherit;
    transition: border 0.3s;
}
#password-input:focus { border-color: var(--accent-color); }

/* --- CHAT CONTAINER --- */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* On centre le contenu sur grand écran pour la lisibilité */
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    /* Scrollbar subtile */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-color);
}

/* --- MESSAGES --- */
.message {
    display: flex;
    gap: 12px;
    padding: 5px 0;
    align-items: flex-end; /* Aligne l'avatar en bas du message */
    animation: fadeIn 0.3s ease-in;
}

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

/* Design des Avatars */
.avatar {
    width: 35px; height: 35px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background-color: #333; /* Fond par défaut */
    color: #fff;
}

.avatar svg {
    width: 20px; height: 20px;
}

/* Style Utilisateur */
.user-msg {
    flex-direction: row-reverse; /* Avatar à droite ! */
}

.user-msg .content {
    background-color: var(--user-bubble);
    padding: 10px 15px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
}
.user-msg .avatar {
    background-color: var(--border-color); /* Gris pour l'user */
}

/* Style IA */
.ai-msg {
    flex-direction: row; /* Avatar à gauche */
}

.ai-msg .content {
    background-color: var(--ai-bubble);
    padding: 10px 0;
    max-width: 90%;
    white-space: pre-wrap;
}
.ai-msg .avatar {
    background-color: var(--accent-color); /* Vert pour l'IA */
    box-shadow: 0 0 10px rgba(16, 163, 127, 0.4); /* Petit effet néon */
}

/* Effet "En train de réfléchir..." */
.thinking-text {
    color: #888;
    font-style: italic;
    font-size: 0.9rem;
    animation: pulse 1.5s infinite;
}

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

/* Style Utilisateur */
.user-msg {
    justify-content: flex-end;
}
.user-msg .content {
    background-color: var(--user-bubble);
    padding: 10px 15px;
    border-radius: 18px 18px 4px 18px; /* Coins arrondis modernes */
    max-width: 85%;
}
/* On cache l'avatar utilisateur pour un look plus épuré */
.user-msg .avatar { display: none; }


/* Style IA */
.ai-msg {
    justify-content: flex-start;
}
.ai-msg .avatar { background-color: var(--accent-color); color: #fff; }
.ai-msg .content {
    background-color: var(--ai-bubble);
    padding: 10px 0; /* Pas de bulle de fond pour l'IA, style ChatGPT */
    max-width: 100%;
    white-space: pre-wrap;
}

/* --- BARRE DE SAISIE MODERNE (Le gros changement) --- */
#input-container {
    background: var(--bg-color); /* Fond uni en bas */
    padding: 20px;
    display: flex;
    justify-content: center;
    position: relative;
    border-top: 1px solid var(--border-color);
}

/* La "capsule" flottante */
.input-capsule {
    width: 100%;
    max-width: 800px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 25px; /* Arrondi */
    padding: 5px 10px 5px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Ombre subtile */
    transition: border 0.3s, box-shadow 0.3s;
}

.input-capsule:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.2);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 0;
    resize: none; /* Empêche le redimensionnement manuel */
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    max-height: 200px; /* Hauteur max si on écrit un roman */
}

#send-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    margin-left: 10px;
    transition: background 0.2s, transform 0.1s;
}

#send-btn:hover { background-color: #15b38b; }
#send-btn:active { transform: scale(0.95); }
#send-btn:disabled { background-color: var(--border-color); cursor: not-allowed; }
#send-btn svg { width: 20px; height: 20px; }

/* Mobile adjustments */
@media (max-width: 768px) {
    #chat-container, .input-capsule { max-width: 100%; }
    .user-msg .content { max-width: 90%; }
}
