/* --- RESET E VARIABILI --- */
:root {
    --bg-color: #121212;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --header-bg: #1e1e1e;
    --andy-msg-bg: #2c2c2c;
    --user-msg-bg: #0066cc; /* Un blu calmo per i tuoi messaggi */
    --input-bg: #1e1e1e;
    --input-border: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    /* Evita lo scroll di tutta la pagina, farà scorrere solo la chat */
    height: 100vh;
    overflow: hidden; 
}

/* --- CONTENITORE PRINCIPALE --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Usa dvh per gestire bene la barra di navigazione su mobile */
    max-width: 800px;
    margin: 0 auto; /* Centra l'app se aperta da PC */
    background-color: var(--bg-color);
    position: relative;
}

/* --- HEADER --- */
.chat-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--input-border);
    z-index: 10;
}

.profile-pic {
    width: 40px;
    height: 40px;
    background-color: var(--user-msg-bg);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 15px;
}

.header-info h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-info .status {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- AREA CHAT --- */
.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Stile base dei messaggi */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Messaggi di Andy (Sinistra) */
.message.andy {
    background-color: var(--andy-msg-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* I tuoi messaggi (Destra) */
.message.user {
    background-color: var(--user-msg-bg);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* --- AREA DI INPUT --- */
.input-area {
    display: flex;
    align-items: flex-end;
    padding: 15px 20px;
    background-color: var(--input-bg);
    border-top: 1px solid var(--input-border);
}

#user-input {
    flex: 1;
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--input-border);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 1rem;
    outline: none;
    transition: border 0.3s ease;
}

#user-input:focus {
    border-color: var(--user-msg-bg);
}

#send-btn {
    background: none;
    border: none;
    color: var(--user-msg-bg);
    margin-left: 15px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

#send-btn:active {
    transform: scale(0.9);
}

/* Animazione di caricamento (i puntini di sospensione) */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}