/**
 * 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;

    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;
    }
}
