:root{
--bg: #0b0e14;
--panel: #151a22;
--ink: #e7ecf3;
--ink-dim: #aab3c2;
--brand: #2f80ed;
--accent: #6ee7b7;
--success: #10b981;
--warning: #f59e0b;
--error: #ef4444;
}
*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
margin:0; font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
background: var(--bg); color: var(--ink);
display:flex; flex-direction:column;
}

.welcome-logo {
  width: 200px !important;
}

/* Header */
.topbar{
height:60px; display:flex; align-items:center; justify-content:space-between;
padding: 0 20px; background: #0f131b; border-bottom: 1px solid #202736;
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.topbar .brand{ 
display:flex; align-items:center; gap:12px; font-weight:700; font-size:18px; 
color: var(--brand);
}

/* Sistema di autenticazione */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.auth-content {
    background: #1a1f2c;
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    border: 1px solid #263144;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 80px;
    height: auto;
    margin-bottom: 1rem;
}

.auth-header h2 {
    color: #f5f5f5;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.auth-header p {
    color: #8b8b8b;
    font-size: 0.9rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    color: #f5f5f5;
    font-weight: 500;
    font-size: 0.9rem;
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid #263144;
    border-radius: 8px;
    background: #0f1419;
    color: #f5f5f5;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.2);
}

#loginBtn {
    padding: 0.75rem;
    background: var(--brand);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

#loginBtn:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
}

#loginBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-error {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Logo styling */
.brand-logo{
height: 32px; 
width: auto; 
object-fit: contain;
}

.topbar .model{ 
display:flex; align-items:center; gap:10px;
}
.topbar .model small{ 
color: var(--ink-dim); 
background: rgba(47, 128, 237, 0.1);
padding: 6px 10px;
border-radius: 6px;
font-size: 12px;
}
.status-indicator{
width: 8px; height: 8px; border-radius: 50%;
background: var(--success);
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}

/* Chat */
.chat{ 
flex:1; display:flex; flex-direction:column; max-width:1000px; 
margin:0 auto; width:100%; position: relative;
}
.messages{
flex:1; padding: 20px; overflow:auto; display:flex; flex-direction:column; gap:16px;
    /* Aggiungi spazio inferiore per evitare che l'ultima risposta venga coperta dalla barra di composizione */
    padding-bottom: 200px;
scroll-behavior: smooth;
}
.bubble{ 
max-width: 80%; padding: 14px 16px; border-radius: 16px; 
line-height: 1.5; white-space: pre-wrap; position: relative;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.bubble.user{ 
align-self: flex-end; background: #1f2633; border:1px solid #2a3447;
}
.bubble.assistant{ 
align-self: flex-start; background: #10151d; border:1px solid #1b2433;
}
.bubble.system{
align-self: center; background: rgba(47, 128, 237, 0.1); 
border: 1px solid rgba(47, 128, 237, 0.3);
font-size: 14px; color: var(--brand); text-align: center;
max-width: 70%;
}

/* Styling for lists inside message bubbles to improve readability */
.bubble ul, .bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}
.bubble li {
    margin-bottom: 4px;
}

/* Link styling nei messaggi */
.bubble a {
color: var(--accent);
text-decoration: underline;
}
.bubble a:hover {
color: #ffffff;
background-color: var(--accent);
padding: 2px 4px;
border-radius: 4px;
text-decoration: none;
}

/* Composer con tools integrati */
.composer-container{
background: var(--panel); border-top:1px solid #202736;
padding: 16px; display: flex; flex-direction: column; gap: 12px;
}

.tools-row{
display: flex; gap: 10px; justify-content: flex-start;
flex-wrap: wrap;
}

.tool-btn{
padding: 8px 16px; border-radius: 10px; border: 1px solid #263144;
background: #0e131a; color: var(--ink-dim); font-size: 13px;
cursor: pointer; display: flex; align-items: center; gap: 8px;
transition: all 0.2s ease; font-weight: 500;
}
.tool-btn:hover{
background: #1a1f2a; border-color: var(--brand);
color: var(--ink);
}
.tool-btn.active{
background: var(--brand); color: white; border-color: var(--brand);
}

/* Knowledge base nascosta per ora */
.tool-btn.knowledge-hidden{
display: none;
}

.composer{
display:flex; gap:12px; align-items: flex-end;
}
.input-container{
flex: 1; position: relative;
}
.composer textarea{
width: 100%; resize:none; border-radius: 12px; border:1px solid #263144; 
background:#0e131a; color:var(--ink); padding:14px 18px; outline: none;
min-height: 52px; max-height: 120px; font-family: inherit;
transition: border-color 0.2s ease; font-size: 15px;
}
.composer textarea:focus{
border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.2);
}
.composer textarea::placeholder{
color: var(--ink-dim); font-size: 15px;
}
.send-btn{
border:0; background: var(--brand); color:white; font-weight:600; 
padding: 14px 24px; border-radius: 12px; cursor:pointer;
height: 52px; display: flex; align-items: center; gap: 8px;
transition: all 0.2s ease; font-size: 14px;
}
.send-btn:hover:not(:disabled){ 
background: #2563eb; transform: translateY(-1px);
}
.send-btn:disabled{
opacity: 0.5; cursor: not-allowed; transform: none;
}

/* File upload area */
.file-upload-area{
display: none; padding: 20px; background: rgba(21, 26, 34, 0.9);
border: 2px dashed #263144; border-radius: 12px; text-align: center;
margin: 0 0 12px 0; color: var(--ink-dim);
transition: all 0.3s ease; cursor: pointer;
}
.file-upload-area.active{
display: block;
}
.file-upload-area:hover{
border-color: var(--brand);
background: rgba(47, 128, 237, 0.05);
}
.file-upload-area p{
margin: 0; font-size: 14px;
}

/* File preview */
.file-preview{
background: rgba(47, 128, 237, 0.1); border: 1px solid rgba(47, 128, 237, 0.3);
border-radius: 8px; padding: 10px; margin: 8px 0; font-size: 12px;
display: flex; justify-content: space-between; align-items: center;
}
.file-preview .remove-file{
background: var(--error); color: white; border: none;
width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
display: flex; align-items: center; justify-content: center;
font-size: 12px; line-height: 1;
transition: background 0.2s ease;
}
.file-preview .remove-file:hover{
background: #dc2626;
}

/* Loading */
.typing-indicator{
display: flex; align-items: center; gap: 8px;
color: var(--ink-dim); font-style: italic;
}
.typing-dots{
display: flex; gap: 3px;
}
.typing-dots span{
width: 4px; height: 4px; background: var(--brand);
border-radius: 50%; animation: typing 1.4s infinite both;
}
.typing-dots span:nth-child(2){ animation-delay: 0.2s; }
.typing-dots span:nth-child(3){ animation-delay: 0.4s; }
@keyframes typing {
0%, 60%, 100% { transform: translateY(0); }
30% { transform: translateY(-10px); }
}

/* Scrollbar personalizzata */
.messages::-webkit-scrollbar {
width: 6px;
}
.messages::-webkit-scrollbar-track {
background: var(--bg);
}
.messages::-webkit-scrollbar-thumb {
background: #263144;
border-radius: 3px;
}
.messages::-webkit-scrollbar-thumb:hover {
background: var(--brand);
}

/* Responsive */
@media (max-width: 768px) {
.bubble{ max-width: 95%; }
.composer-container{ padding: 12px; }
.topbar{ padding: 0 12px; }
.topbar .brand{ font-size: 16px; }
.brand-logo{ height: 28px; }
.tools-row{ gap: 8px; }
.tool-btn{ padding: 6px 12px; font-size: 12px; }
.chat{ max-width: 100%; }
.messages{ padding: 12px; gap: 12px; }
.composer textarea{ font-size: 16px; padding: 12px 16px; }
.send-btn{ padding: 12px 20px; }
}

@media (max-width: 480px) {
.topbar .model small{
display: none;
}
.tools-row{
flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.tools-row::-webkit-scrollbar{
display: none;
}
.composer{
flex-direction: column; gap: 8px;
}
.send-btn{
width: 100%; justify-content: center;
}
}

