/* ============================================================
   Assistente TIMS ("Chiedimi!") — casella nella sidebar, sotto il
   titolo della vista ("Seleziona una query"), sempre visibile; e
   popup risposta. Caricato da includes/layout_app.php dopo styles.css
   (usa le sue variabili CSS).
   ============================================================ */

/* Casella nella sidebar */
.chatbot-kb-side {
    display: flex;
    align-items: stretch;      /* pulsante alto quanto la casella: un blocco solo */
    gap: 6px;
    margin-top: 10px;
    min-width: 0;
}
.chatbot-kb-side textarea {
    flex: 1 1 auto;
    min-width: 0;
    height: 58px;              /* spazio per due righe */
    min-height: 58px;
    max-height: 120px;
    resize: none;
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.45;
    font-family: inherit;
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.chatbot-kb-side textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
/* "Chiedimi!" in grigio */
.chatbot-kb-side textarea::placeholder {
    color: var(--text-muted);
    font-style: italic;
    opacity: 1;
}
.chatbot-kb-send {
    flex: 0 0 auto;
    width: 44px;
    height: auto;              /* segue l'altezza della casella (align-items: stretch) */
    align-self: stretch;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--primary-color);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}
.chatbot-kb-send i { font-size: 15px; margin-left: -2px; }   /* l'aeroplanino pende a destra: lo ricentro otticamente */
.chatbot-kb-send:hover:not(:disabled) { background: var(--primary-hover); }
.chatbot-kb-send:disabled { opacity: 0.6; cursor: default; }

/* Popup risposta */
#chatbotKbModal .modal-content {
    max-width: 780px;
    width: 92%;
}
#chatbotKbModal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}
.chatbot-kb-q {
    background: rgba(59, 130, 246, 0.12);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 10px 0 12px;
    color: var(--text-secondary);
    white-space: pre-wrap;
}
.chatbot-kb-a {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.55;
}
.chatbot-kb-a p { margin: 6px 0; }
.chatbot-kb-a ol, .chatbot-kb-a ul { margin: 6px 0; padding-left: 24px; }
.chatbot-kb-a li { margin: 3px 0; }
.chatbot-kb-a code {
    background: rgba(148, 163, 184, 0.18);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 13px;
}
.chatbot-kb-h {
    font-weight: 600;
    margin: 10px 0 4px;
    color: var(--text-primary);
}
.chatbot-kb-fonti {
    font-size: 12px;
    color: var(--text-muted);
    margin: 10px 0 4px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
}
.chatbot-kb-spinner,
.chatbot-kb-empty {
    text-align: center;
    padding: 22px 0;
    color: var(--text-muted);
}
.chatbot-kb-error {
    color: #f59e0b;
    padding: 8px 0;
}
.chatbot-kb-footer {
    flex-wrap: wrap;
    gap: 8px;
}
.chatbot-kb-followup {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex: 1 1 100%;
}
.chatbot-kb-followup textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 56px;
    resize: vertical;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    outline: none;
    box-sizing: border-box;
}
.chatbot-kb-followup textarea:focus { border-color: var(--primary-color); }
.chatbot-kb-followup textarea::placeholder { color: var(--text-muted); font-style: italic; opacity: 1; }
.chatbot-kb-footer .btn { white-space: nowrap; }
