:root {
    --bg: #0a0f1c;
    --panel: #0f172a;
    --muted: #94a3b8;
    --accent: #7cafff;
    --line: #1b243a;
    --chip: #0b1220;
    --bot: #10192d;
    --user: #17243f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(124, 175, 255, .12), transparent),
    radial-gradient(900px 500px at 100% 0, rgba(40, 221, 168, .10), transparent),
    var(--bg);
    color: #e6edf3;
    font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, Ubuntu, 'Helvetica Neue', Arial;
}

a {
    color: #9ec1ff;
    text-decoration: none;
}

.container {
    max-width: 85vw;
    margin: 24px auto;
    padding: 0 16px;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(124, 175, 255, .10), transparent 30%, transparent 70%, rgba(40, 221, 168, .08));
}

.brand-logo {
    height: 28px;
    width: auto;
    display: block;
}

.brand-title {
    font-weight: 600;
    letter-spacing: .2px;
}

/* Card & layout */
.card {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
    overflow: hidden;
    background: linear-gradient(180deg, #0e1628, #0b1220);
}

.layout {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    min-height: 72vh;
}

/* Sidebar */
.sidebar {
    border-right: 1px solid var(--line);
    padding: 16px;
    background: linear-gradient(180deg, rgba(124, 175, 255, .06), transparent);
}

.side-title {
    font-size: 14px;
    color: #cfe1ff;
    margin: 0 0 10px;
}

.sidemenu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidemenu button {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    background: #0b1220;
    border: 1px solid #233249;
    color: #e6edf3;
    cursor: pointer;
}

.sidemenu button:hover {
    border-color: #35517a;
}

.sidemenu button.active {
    background: #122039;
    border-color: #4b6aa1;
    box-shadow: 0 0 0 2px rgba(124, 175, 255, .15) inset;
}

/* Chat column */
.chatcol {
    display: flex;
    flex-direction: column;
}

header.page {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

header.page h1 {
    margin: 0;
    font-size: 18px;
    letter-spacing: .2px;
}

header.page .desc {
    margin-top: 6px;
    color: #cbd5e1;
    font-size: 13px;
}

header.page .sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

.chat {
    height: 60vh;
    min-height: 420px;
    overflow: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg, rgba(124, 175, 255, .04), transparent);
}

/* ==========================================================
   MESSAGGI CHAT – VERSIONE FINALE (utente a destra, bot a sinistra)
   ========================================================== */

/* Contenitore messaggi */
.msgWrap {
    max-width: 78%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Utente → destra */
.msgWrap.user {
    align-self: flex-end;
}

/* Bot → sinistra */
.msgWrap.bot {
    align-self: flex-start;
}

/* Bolla base */
.bubble {
    padding: 8px 10px;
    border-radius: 12px;
    line-height: 1.42;
    white-space: pre-wrap;
    font-size: 14px;
    max-width: 100%;
}

/* Bolla utente */
.bubble.user {
    background: var(--user);
    border: 1px solid #223a64;
    margin-left: auto;
}

/* Bolla bot */
.bubble.bot {
    background: var(--bot);
    border: 1px solid #203052;
    margin-right: auto;
}

.info {
    background: #0f172a;
    border: 1px dashed #2a3b55;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--muted);
}

.info strong {
    color: #cfe1ff;
    font-weight: 600;
}

.srcs {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.src, .filepill {
    background: var(--chip);
    border: 1px solid #1f2a44;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    color: #cbd5e1;
}

/* Composer */
.composer {
    border-top: 1px solid var(--line);
    background: #0b1220;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.drop {
    flex: 1;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px dashed #2a3b55;
    border-radius: 12px;
    background: linear-gradient(180deg, #0b1220, #0c1422);
}

.drop.drag {
    border-color: #5aa3ff;
    background: linear-gradient(180deg, #0b1220, #101a2b);
}

.drop input {
    display: none;
}

.drop .hint {
    font-size: 13px;
    color: var(--muted);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.chip {
    background: var(--chip);
    border: 1px solid #1f2a44;
    color: #cbd5e1;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
}

textarea {
    flex: 1;
    min-height: 52px;
    max-height: auto;
    resize: vertical;
    background: #0b1220;
    border: 1px solid #223244;
    border-radius: 12px;
    color: #e6edf3;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

textarea:focus {
    border-color: #335a97;
    box-shadow: 0 0 0 3px rgba(124, 175, 255, .15);
}

.btn {
    appearance: none;
    border: 1px solid #2a3b55;
    background: linear-gradient(180deg, #18233d, #162034);
    color: #e6edf3;
    border-radius: 12px;
    padding: 8px 12px;
    cursor: pointer;
}

.btn[disabled] {
    opacity: .6;
    cursor: not-allowed;
}

.send {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.kbd {
    font-family: ui-monospace, Consolas, monospace;
    background: #0f172a;
    border: 1px solid #26365b;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
    color: #cbd5e1;
}

.typing {
    opacity: .85;
    animation: pulse 1.4s infinite;
}

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

/* Generic cards */
.card-simple {
    border: 1px solid #21304a;
    background: #0f172a;
    border-radius: 12px;
    padding: 14px;
}

label {
    font-size: 12px;
    color: #94a3b8;
}

input, textarea, select {
    width: 100%;
    background: #0b1220;
    border: 1px solid #233249;
    border-radius: 10px;
    color: #e6edf3;
    padding: 10px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 16px;
}

.grid-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.muted {
    color: #94a3b8;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid #233249;
    padding: 8px;
    text-align: left;
    font-size: 14px;
}

.btn-link {
    display: inline-block;
    border: 1px solid #2a3b55;
    padding: 8px 10px;
    border-radius: 10px;
    background: #18233d;
    color: #e6edf3;
}

/* Container varianti */
.container-wide {
    max-width: 1400px;
}

.container-fluid {
    max-width: none;
}

/* Textarea rigata */
.nb-textarea {
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background-image: repeating-linear-gradient(
        to bottom,
        #0f172a 0, #0f172a 1.55em,
        #17233a 1.55em, #17233a 1.6em
    );
    background-attachment: local;
    padding-top: 10px;
}

.nb-preview {
    margin-top: 10px;
    border: 1px dashed #2a3b55;
    border-radius: 10px;
    background: #0f172a;
    padding: 10px;
}

.nb-preview h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #cfe1ff;
}

.nb-preview ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nb-preview li {
    padding: 8px 10px;
    border: 1px solid #1f2a44;
    border-radius: 8px;
    background: #0b1220;
    margin-bottom: 6px;
    font-size: 13px;
    color: #e6edf3;
}

.nb-preview li:last-child {
    margin-bottom: 0;
}

.bubble code {
    background: rgba(255,255,255,0.06);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
}
select option{
    background-color: lightslategray;
}

/* 2) Aggiungi QUESTE regole (in fondo al CSS) */
html, body { height: 100%; }

.layout {
    min-height: 0;
    height: 100%;
}

.chatcol {
    min-height: 0;
    overflow: hidden;
}

.chat {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* 3) Aggiungi lo stile della colonna description */
.model-info{
    border-left: 1px solid var(--line);
    padding: 16px;
    background: linear-gradient(180deg, rgba(40, 221, 168, .06), transparent);
    overflow: auto;
    min-height: 0;
}

.model-info__title{
    font-size: 14px;
    color: #cfe1ff;
    font-weight: 600;
    margin: 0 0 10px;
}

.model-info__desc{
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.45;
    white-space: pre-wrap;
}

/* 4) Responsive: nascondi la colonna a destra */
@media (max-width: 1100px) {
    .layout { grid-template-columns: 240px 1fr; }
    .model-info { display: none; }
}
/* --- INCOLLA IN FONDO AL TUO CSS (override) --- */

/* Composer sempre in basso e non “spinge” la pagina */
.composer{
    flex: 0 0 auto;
}

/* ChatGPT-like: textarea cresce fino a un limite, poi scroll interno */
#sendForm .row{
    align-items: flex-end;
}

#input{
    resize: none;                 /* come ChatGPT */
    overflow-y: hidden;           /* diventa auto via JS quando supera max */
    min-height: 52px;
    max-height: 220px;            /* cambia a piacere */
    line-height: 1.45;
}

/* evita che un testo enorme allarghi layout */
#input{
    word-break: break-word;
}

/* opzionale: scrollbar più “pulita” */
#input::-webkit-scrollbar{ width: 10px; }
#input::-webkit-scrollbar-thumb{
    background: rgba(148,163,184,.25);
    border-radius: 10px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
}
#input::-webkit-scrollbar-track{ background: transparent; }
