/* ═══════════════════════════════════════════════════════════════════════════
   MazzoniNews RAG — Chat Widget CSS
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Reset base ──────────────────────────────────────────────────────────── */
#mnews-rag-widget,
#mnews-rag-widget * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════════════════════
   MODALITÀ COMPACT — floating bottom-right
   ════════════════════════════════════════════════════════════════════════════ */

.mnews-rag-compact {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Pulsante toggle */
.mnews-rag-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: #216778;
    color: #fff;
    border: none;
    border-radius: 32px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transition: background 0.2s, transform 0.15s;
}
.mnews-rag-toggle:hover {
    background: #1a5260;
    transform: translateY(-2px);
}
.mnews-rag-toggle .mnews-rag-icon { font-size: 18px; }

/* Pannello compact */
.mnews-rag-compact .mnews-rag-panel {
    width: 360px;
    max-height: 520px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden;
    animation: mnewsSlideUp 0.2s ease;
}
.mnews-rag-compact .mnews-rag-panel[hidden] {
    display: none;
}

@keyframes mnewsSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════════════════════
   MODALITÀ FULL — pagina intera
   ════════════════════════════════════════════════════════════════════════════ */

.mnews-rag-full {
    max-width: 780px;
    margin: 32px auto;
}
.mnews-rag-full .mnews-rag-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    overflow: hidden;
    min-height: 520px;
}

/* ════════════════════════════════════════════════════════════════════════════
   PARTI COMUNI
   ════════════════════════════════════════════════════════════════════════════ */

/* Header */
.mnews-rag-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #216778;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}
.mnews-rag-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}
.mnews-rag-close:hover { opacity: 1; }

/* Area messaggi */
.mnews-rag-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 180px;
    max-height: 340px;
    background: #fafafa;
}
.mnews-rag-full .mnews-rag-messages {
    max-height: 400px;
}

/* Benvenuto */
.mnews-rag-welcome {
    font-size: 13px;
    color: #666;
    text-align: center;
    padding: 8px;
}

/* Messaggi singoli */
.mnews-rag-msg {
    max-width: 92%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
}
.mnews-rag-msg.user {
    background: #216778;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.mnews-rag-msg.assistant {
    background: #fff;
    color: #222;
    border: 1px solid #e8e8e8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Risposta loading */
.mnews-rag-msg.loading {
    background: #f0f0f0;
    color: #999;
    font-style: italic;
    align-self: flex-start;
}

/* Fonti */
.mnews-rag-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e8e8e8;
    font-size: 12px;
    color: #666;
}
.mnews-rag-sources strong { display: block; margin-bottom: 4px; }
.mnews-rag-sources a {
    display: block;
    color: #216778;
    text-decoration: none;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mnews-rag-sources a:hover { text-decoration: underline; }

/* Errore */
.mnews-rag-msg.error {
    background: #fef2f2;
    color: #216778;
    border: 1px solid #fca5a5;
    align-self: stretch;
    font-size: 13px;
}

/* Input row */
.mnews-rag-input-row {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
}
.mnews-rag-input {
    flex: 1;
    padding: 9px 13px 9px 20px !important;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.mnews-rag-input:focus { border-color: #216778; }
.mnews-rag-submit {
    padding: 9px 18px;
    background: #216778;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.mnews-rag-submit:hover { background: #1a5260; }
.mnews-rag-submit:disabled { background: #ccc; cursor: default; }

/* Link pagina completa */
.mnews-rag-footer-link {
    padding: 8px 14px;
    text-align: right;
    font-size: 12px;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
}
.mnews-rag-footer-link a {
    color: #216778;
    text-decoration: none;
    font-weight: 600;
}
.mnews-rag-footer-link a:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .mnews-rag-compact {
        bottom: 12px;
        right: 12px;
    }
    .mnews-rag-compact .mnews-rag-panel {
        width: calc(100vw - 24px);
        right: 0;
    }
    .mnews-rag-toggle .mnews-rag-label { display: none; }
    .mnews-rag-toggle { padding: 14px; border-radius: 50%; }
}
