:root {
    /* Palette RAG Agent: Deep Blue, Electric Cyan e Soft Slate */
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --chat-bg: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8; /* Cyan */
    --primary-light: #7dd3fc;
    --secondary: #2dd4bf; /* Teal */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --user-bubble: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    --assistant-bubble: rgba(51, 65, 85, 0.5);
    --shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    --border: rgba(255, 255, 255, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg-gradient);
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Sfondo Animato con Blobs per effetto "Flowing" */
body::before, body::after {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.2;
    animation: move 25s infinite alternate;
}
body::before { background: var(--primary); top: -10%; left: -10%; }
body::after { background: var(--secondary); bottom: -10%; right: -10%; animation-delay: -12s; }

@keyframes move {
    from { transform: translate(0, 0) rotate(0deg) scale(1); }
    to { transform: translate(150px, 100px) rotate(30deg) scale(1.1); }
}

.main-wrapper {
    width: 100%;
    height: 100%;
    max-width: 1000px;
    max-height: 850px;
    padding: 20px;
    z-index: 1;
}

.chat-container {
    width: 100%;
    height: 100%;
    background: var(--chat-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--border);
    border-radius: 30px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- HEADER --- */
header {
    padding: 20px 35px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.3);
}

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

.logo-circle {
    width: 42px; height: 42px;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #0f172a; font-weight: 800; font-size: 0.8rem;
    box-shadow: 0 8px 15px rgba(56, 189, 248, 0.2);
}

.brand-logo { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.5px; color: #fff; }
.brand-logo span { color: var(--primary); font-weight: 800; }

.status-wrapper { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.status-dot { 
    width: 8px; height: 8px; 
    background: #10b981; 
    border-radius: 50%; 
    box-shadow: 0 0 10px #10b981; 
}
.status-wrapper span { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }

.v-tag { font-size: 0.7rem; background: rgba(255,255,255,0.05); padding: 5px 12px; border-radius: 20px; color: var(--text-muted); font-weight: 700; border: 1px solid var(--border); }

/* --- CHAT WINDOW --- */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 30px 35px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chat-window::-webkit-scrollbar { width: 6px; }
.chat-window::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.message { display: flex; width: 100%; opacity: 0; transform: translateY(20px); animation: messageAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

@keyframes messageAppear { to { opacity: 1; transform: translateY(0); } }

.bubble {
    max-width: 80%;
    padding: 16px 22px;
    font-size: 0.98rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
}

.user { justify-content: flex-end; }
.user .bubble {
    background: var(--user-bubble);
    color: white;
    border-radius: 25px 25px 5px 25px;
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.15);
}

.assistant { justify-content: flex-start; }
.assistant .bubble {
    background: var(--assistant-bubble);
    color: var(--text-main);
    border-radius: 25px 25px 25px 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
}

/* --- INPUT AREA --- */
.input-container {
    padding: 25px 35px 30px;
    background: rgba(15, 23, 42, 0.4);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(30, 41, 59, 0.5);
    padding: 8px 8px 8px 22px;
    border-radius: 24px;
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15), 0 10px 20px rgba(0,0,0,0.2);
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.8);
}

input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 1rem;
    font-family: inherit;
    color: #fff;
    outline: none;
}

input::placeholder { color: var(--text-muted); }

#send-btn {
    width: 48px; height: 48px;
    background: var(--primary);
    border: none;
    border-radius: 18px;
    color: #0f172a;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

#send-btn:hover { 
    background: var(--primary-light); 
    transform: scale(1.08) rotate(-5deg); 
    box-shadow: 0 6px 15px rgba(56, 189, 248, 0.4);
}

#send-btn svg { width: 22px; height: 22px; }

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 15px;
    font-weight: 500;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .main-wrapper { padding: 10px; }
    .chat-container { border-radius: 20px; }
    .bubble { max-width: 90%; padding: 14px 18px; }
    header { padding: 15px 20px; }
    .input-container { padding: 20px; }
}