/**
 * GeoBot Dify - Frontend styles
 * Basato sul design della Soluzione 2 del pilot M4.
 */

.geobot-container {
    --geobot-primary: #2D5016;
    --geobot-secondary: #4A7C2E;
    --geobot-bg: #FAFAF5;
    --geobot-card-bg: #FFFFFF;
    --geobot-text: #2C2C2C;
    --geobot-muted: #6B6B6B;
    --geobot-border: #E5E5E0;
    --geobot-tag-bg: #E8E1CC;

    /* Avviso chatbot — colori "warning" per la riga dati personali */
    --geobot-warning-bg: #FBF3DF;
    --geobot-warning-border: #C08A18;
    --geobot-warning-text: #6B4E07;

    max-width: 800px;
    margin: 1.5rem auto;
    background: var(--geobot-card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--geobot-text);
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* Header */
.geobot-header {
    background: linear-gradient(135deg, var(--geobot-primary) 0%, var(--geobot-secondary) 100%);
    color: #fff;
    padding: 0.9rem 1.2rem;
}
.geobot-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.geobot-icon {
    font-size: 1.2em;
}

/* Area messaggi */
.geobot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
    background: var(--geobot-bg);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.geobot-messages::-webkit-scrollbar {
    width: 6px;
}
.geobot-messages::-webkit-scrollbar-thumb {
    background: var(--geobot-border);
    border-radius: 3px;
}

.geobot-msg {
    display: flex;
}
.geobot-msg-user {
    justify-content: flex-end;
}
.geobot-msg-bot {
    justify-content: flex-start;
}

.geobot-bubble {
    max-width: 78%;
    padding: 0.7rem 0.95rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
}
.geobot-msg-user .geobot-bubble {
    background: var(--geobot-primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.geobot-msg-bot .geobot-bubble {
    background: var(--geobot-card-bg);
    color: var(--geobot-text);
    border: 1px solid var(--geobot-border);
    border-bottom-left-radius: 3px;
}

/* Citazioni */
.geobot-citations {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--geobot-border);
    font-size: 0.85rem;
}
.geobot-citations-label {
    color: var(--geobot-primary);
    font-weight: 600;
    margin-right: 0.4rem;
    display: inline-block;
    margin-bottom: 0.3rem;
}

/* Riga dei tag testuali (nomi documento) */
.geobot-citations-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

/* Riga delle anteprime immagine (v2.0) */
.geobot-citations-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.geobot-citation-image-link {
    display: block;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--geobot-border);
    transition: border-color 0.15s, transform 0.15s;
    line-height: 0; /* evita gap sotto l'img */
}
.geobot-citation-image-link:hover {
    border-color: var(--geobot-primary);
    transform: scale( 1.02 );
}
.geobot-citation-image {
    display: block;
    width: 160px;
    height: 110px;
    object-fit: cover;
    cursor: pointer;
}
@media ( max-width: 600px ) {
    .geobot-citation-image {
        width: 130px;
        height: 90px;
    }
}

/* Pulsante video (v2.1) */
.geobot-citation-video-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    background: var(--geobot-primary);
    color: #fff !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, transform 0.15s;
    line-height: 1.2;
    border: 2px solid var(--geobot-primary);
}
.geobot-citation-video-btn:hover {
    background: var(--geobot-secondary);
    border-color: var(--geobot-secondary);
    transform: translateY( -1px );
    text-decoration: none;
}
.geobot-citation-video-icon {
    font-size: 1.1em;
    line-height: 1;
}
.geobot-citation-video-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}
@media ( max-width: 600px ) {
    .geobot-citation-video-text {
        max-width: 130px;
        font-size: 0.8rem;
    }
}

.geobot-citation-tag {
    display: inline-block;
    background: var(--geobot-tag-bg);
    color: var(--geobot-text);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    margin: 0.15rem 0.25rem 0.15rem 0;
    font-size: 0.82rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
a.geobot-citation-tag:hover {
    background: var(--geobot-primary);
    color: #fff;
}

/* Indicator "sta scrivendo" */
.geobot-typing {
    font-style: italic;
    color: var(--geobot-muted);
}
.geobot-typing-dots::after {
    content: '...';
    display: inline-block;
    animation: geobot-dots 1.4s infinite;
    width: 1em;
}
@keyframes geobot-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Prompt suggeriti */
.geobot-suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.7rem 1rem;
    background: #F5F1E8;
    border-top: 1px solid var(--geobot-border);
}
.geobot-prompt-btn {
    background: var(--geobot-card-bg);
    border: 1px solid var(--geobot-secondary);
    color: var(--geobot-primary);
    padding: 0.45rem 0.95rem;
    border-radius: 18px;
    font-size: 0.83rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.geobot-prompt-btn:hover {
    background: var(--geobot-secondary);
    color: #fff;
}
.geobot-prompt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Composer */
.geobot-composer {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--geobot-card-bg);
    border-top: 1px solid var(--geobot-border);
}
.geobot-input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 1px solid var(--geobot-border);
    border-radius: 22px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    background: #fff;
    color: var(--geobot-text);
}
.geobot-input:focus {
    border-color: var(--geobot-secondary);
    box-shadow: 0 0 0 3px rgba(74, 124, 46, 0.15);
}
.geobot-send-btn {
    background: var(--geobot-primary);
    color: #fff;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: 22px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}
.geobot-send-btn:hover {
    opacity: 0.9;
}
.geobot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Errore admin (solo per amministratori) */
.geobot-error-admin {
    background: #FFF3CD;
    border: 1px solid #FFE69C;
    color: #664D03;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Mobile */
@media ( max-width: 600px ) {
    .geobot-container {
        height: 70vh;
        margin: 1rem 0;
        border-radius: 8px;
    }
    .geobot-bubble {
        max-width: 88%;
        font-size: 0.9rem;
    }
    .geobot-prompt-btn {
        font-size: 0.78rem;
    }
}

/* ============================================================
   AVVISO CHATBOT (AI Act art. 50) — Componenti A, B, C
   Allineato ai token .geobot-* esistenti. Nessun font esterno.
   ============================================================ */

/* ----- Componente A: avviso/messaggio iniziale ----- */
.geobot-notice {
    max-width: 90%;
    border: 1px solid var(--geobot-border);
    border-left: 4px solid var(--geobot-secondary);
    border-radius: 12px;
    background: var(--geobot-card-bg);
    padding: 0.9rem 1rem;
    line-height: 1.5;
    font-size: 0.92rem;
    color: var(--geobot-text);
}
.geobot-notice__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.geobot-notice__title {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--geobot-primary);
}
.geobot-notice p { margin: 0 0 0.6rem; }
.geobot-notice p:last-child { margin-bottom: 0; }
.geobot-notice a {
    color: var(--geobot-primary);
    font-weight: 600;
    text-underline-offset: 2px;
}
.geobot-notice a:hover { color: var(--geobot-secondary); }
.geobot-notice a:focus-visible {
    outline: 3px solid var(--geobot-secondary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Badge "Assistente IA" — disclosure art. 50 */
.geobot-badge-ia {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--geobot-primary);
    background: var(--geobot-tag-bg);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}
.geobot-badge-ia::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--geobot-secondary);
    flex: none;
}

/* Riga warning "non inserire dati personali" */
.geobot-notice-warning {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    background: var(--geobot-warning-bg);
    border: 1px solid var(--geobot-warning-border);
    color: var(--geobot-warning-text);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ----- Componente B: microcopy persistente (sotto il composer) ----- */
.geobot-microcopy {
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--geobot-muted);
    text-align: center;
    padding: 0.4rem 0.8rem;
    border-top: 1px solid var(--geobot-border);
    background: #F5F1E8;
}
.geobot-microcopy b { color: var(--geobot-primary); font-weight: 700; }
.geobot-microcopy .geobot-sep { opacity: 0.5; margin: 0 0.25rem; }

/* ----- Componente C: disclaimer per risposta ----- */
.geobot-disclaimer {
    margin: 0.5rem 0 0;
    font-size: 0.72rem;
    color: var(--geobot-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.geobot-disclaimer::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--geobot-secondary);
    flex: none;
}
