/* Geco Chatbot widget — stile mutuato dal prodotto "Arianna" (chatbot-wordpress) */

.geco-chatbot-widget {
    --geco-chatbot-primary: #004c93;
    --geco-chatbot-gap: 32px;
    --geco-chatbot-text-on-primary: #fff;
    position: fixed;
    z-index: 10050;
    padding: var(--geco-chatbot-gap);
    font-family: inherit;
    line-height: 1.4;
}

.geco-chatbot-widget--bottom-right { bottom: 0; right: 0; }
.geco-chatbot-widget--bottom-left  { bottom: 0; left: 0; }
.geco-chatbot-widget--top-right    { top: 0; right: 0; }
.geco-chatbot-widget--top-left     { top: 0; left: 0; }

.geco-chatbot-widget * { box-sizing: border-box; }

.geco-chatbot-widget__toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    padding: 14px;
    background-color: var(--geco-chatbot-primary);
    color: var(--geco-chatbot-text-on-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    cursor: pointer;
    transition: transform .15s ease, opacity .15s ease;
}

.geco-chatbot-widget__toggle:hover { transform: scale(1.05); }

.geco-chatbot-widget__toggle .geco-chatbot-widget__icon { fill: currentColor; width: 100%; height: 100%; }

.geco-chatbot-widget.is-open .geco-chatbot-widget__toggle {
    opacity: 0;
    pointer-events: none;
}

.geco-chatbot-widget__icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
    display: inline-block;
}

.geco-chatbot-widget__panel {
    position: absolute;
    width: 480px;
    height: 900px;
    max-width: calc(100vw - (var(--geco-chatbot-gap) * 2));
    max-height: calc(100vh - (var(--geco-chatbot-gap) * 2) - 76px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(.98);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}

.geco-chatbot-widget--bottom-right .geco-chatbot-widget__panel { right: var(--geco-chatbot-gap); bottom: calc(60px + var(--geco-chatbot-gap) + 16px); }
.geco-chatbot-widget--bottom-left  .geco-chatbot-widget__panel { left: var(--geco-chatbot-gap); bottom: calc(60px + var(--geco-chatbot-gap) + 16px); }
.geco-chatbot-widget--top-right    .geco-chatbot-widget__panel { right: var(--geco-chatbot-gap); top: calc(60px + var(--geco-chatbot-gap) + 16px); }
.geco-chatbot-widget--top-left     .geco-chatbot-widget__panel { left: var(--geco-chatbot-gap); top: calc(60px + var(--geco-chatbot-gap) + 16px); }

.geco-chatbot-widget.is-open .geco-chatbot-widget__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.geco-chatbot-widget__header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 10px 14px 16px;
    background-color: var(--geco-chatbot-primary);
    color: var(--geco-chatbot-text-on-primary);
    flex: 0 0 auto;
}

.geco-chatbot-widget__header::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .2) 100%);
    mix-blend-mode: overlay;
    pointer-events: none;
}

.geco-chatbot-widget__header-title { display: flex; align-items: center; gap: 10px; position: relative; }
.geco-chatbot-widget__header-title small { display: block; font-weight: 400; opacity: .85; font-size: .7rem; text-transform: uppercase; }
.geco-chatbot-widget__header-title strong { display: block; font-size: 1.1rem; line-height: 1.1; }

.geco-chatbot-widget__close {
    background: transparent;
    border: 0;
    color: var(--geco-chatbot-text-on-primary);
    cursor: pointer;
    padding: 8px;
    position: relative;
}

.geco-chatbot-widget__body {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: #fff;
    overflow: hidden;
}

.geco-chatbot-widget__messages {
    order: 2;
    padding: 0 16px 16px;
    overflow-y: auto;
    /* La codetta della bolla (bubble::after) sporge di qualche px a sinistra
       per design: senza overflow-x esplicito, il solo overflow-y: auto fa sì
       che lo spec CSS forzi anche overflow-x a "auto" (non "visible"), e quel
       pelo di contenuto negativo basta a far comparire una scrollbar
       orizzontale — visibile soprattutto durante l'indicatore di digitazione. */
    overflow-x: hidden;
}

.geco-chatbot-widget__welcome {
    order: 1;
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    transition: opacity .3s ease;
}

.geco-chatbot-widget.has-messages .geco-chatbot-widget__welcome {
    opacity: 0;
    pointer-events: none;
}

.geco-chatbot-widget__welcome-inner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    background-color: var(--geco-chatbot-primary);
    color: var(--geco-chatbot-text-on-primary);
    border-radius: 0 0 50% 50% / 0 0 40px 40px;
    padding: 32px 24px 56px;
    position: relative;
}

.geco-chatbot-widget__welcome-title { display: block; font-size: 1.6rem; margin-bottom: 6px; }
.geco-chatbot-widget__welcome-subtitle { display: block; font-size: 1.1rem; opacity: .9; margin-bottom: 24px; }
.geco-chatbot-widget__robot { width: 140px; height: 140px; fill: currentColor; opacity: .95; }

/* bottom in positivo (non negativo): il cerchio deve restare interamente
   dentro .geco-chatbot-widget__body, che ha overflow:hidden per gli angoli
   arrotondati del pannello - con un offset negativo la metà inferiore del
   cerchio (e quindi della freccia) veniva tagliata via. */
.geco-chatbot-widget__scroll-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    margin: 0 auto;
    width: 3.2em;
    height: 3.2em;
    border-radius: 50%;
    border: 0;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--geco-chatbot-primary);
    cursor: pointer;
    animation: geco-chatbot-float 1s alternate infinite ease;
}

@keyframes geco-chatbot-float {
    0% { bottom: 8px; }
    100% { bottom: 16px; }
}

.geco-chatbot-widget__post {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: 18px;
    position: relative;
    animation: geco-chatbot-slide-in-bot .4s ease forwards;
}

.geco-chatbot-widget__post--user {
    flex-direction: row-reverse;
    animation-name: geco-chatbot-slide-in-user;
}

@keyframes geco-chatbot-slide-in-bot {
    0% { opacity: 0; transform: translateX(-8px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes geco-chatbot-slide-in-user {
    0% { opacity: 0; transform: translateX(8px); }
    100% { opacity: 1; transform: translateX(0); }
}

.geco-chatbot-widget__avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ebeced;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--geco-chatbot-primary);
}

.geco-chatbot-widget__avatar .geco-chatbot-widget__icon { width: 18px; height: 18px; }

.geco-chatbot-widget__bubble {
    position: relative;
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 10px;
    background-color: var(--geco-chatbot-primary);
    color: var(--geco-chatbot-text-on-primary);
    font-size: .9rem;
}

.geco-chatbot-widget__post--user .geco-chatbot-widget__bubble {
    background-color: #eef1f4;
    color: #333;
}

/* Il testo del bot può contenere markdown renderizzato (liste, link, grassetto):
   overflow-wrap/word-break garantiscono che parole lunghe (URL, termini tecnici)
   restino dentro la bolla invece di spingerne fuori il contenuto o il pannello. */
.geco-chatbot-widget__text {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.geco-chatbot-widget__text p { margin: 0 0 .5em; }
.geco-chatbot-widget__text p:last-child { margin-bottom: 0; }

.geco-chatbot-widget__text ul,
.geco-chatbot-widget__text ol {
    margin: .25em 0 .5em;
    padding-left: 1.25em;
}
.geco-chatbot-widget__text li { margin-bottom: .15em; }

.geco-chatbot-widget__text strong { font-weight: 700; }

.geco-chatbot-widget__text a {
    color: inherit;
    text-decoration: underline;
    overflow-wrap: anywhere;
}
.geco-chatbot-widget__post--user .geco-chatbot-widget__text a { color: var(--geco-chatbot-primary); }

.geco-chatbot-widget__post:not(.geco-chatbot-widget__post--user) .geco-chatbot-widget__bubble::after {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 12px;
    width: 12px;
    height: 12px;
    background-color: inherit;
    transform: rotate(45deg);
    border-radius: 3px 0 0 0;
}

.geco-chatbot-widget__post--user .geco-chatbot-widget__bubble::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 12px;
    height: 12px;
    background-color: inherit;
    transform: rotate(45deg);
    border-radius: 0 3px 0 0;
}

.geco-chatbot-widget__actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    margin: 4px 0 0 42px;
}

.geco-chatbot-widget__action {
    border: 0;
    background: transparent;
    color: #9aa2ab;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: color .15s ease, background-color .15s ease;
}

.geco-chatbot-widget__action .geco-chatbot-widget__icon { width: 16px; height: 16px; }
.geco-chatbot-widget__action:hover { background-color: #f0f1f2; color: #555; }
.geco-chatbot-widget__action--like.is-active { color: #2e8b57; }
.geco-chatbot-widget__action--dislike.is-active { color: #c0392b; }
.geco-chatbot-widget__action:disabled { opacity: .4; cursor: default; pointer-events: none; }

.geco-chatbot-widget__bubble--typing { display: inline-flex; align-items: center; }

.geco-chatbot-widget__typing { display: flex; gap: 4px; }
.geco-chatbot-widget__typing div {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: .3;
    animation: geco-chatbot-blink 1.4s infinite;
}
.geco-chatbot-widget__typing div:nth-child(2) { animation-delay: .25s; }
.geco-chatbot-widget__typing div:nth-child(3) { animation-delay: .5s; }

@keyframes geco-chatbot-blink {
    0%, 100% { opacity: .25; }
    50% { opacity: 1; }
}

.geco-chatbot-widget__footer {
    flex: 0 0 auto;
    border-top: 1px solid #eef1f4;
    padding: 12px 16px;
    background: #fff;
}

.geco-chatbot-widget__form {
    display: flex;
    align-items: center;
    border: 2px solid #e3e4e6;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .15s ease;
}

.geco-chatbot-widget__form:focus-within { border-color: var(--geco-chatbot-primary); }

.geco-chatbot-widget__input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    padding: 10px 14px;
    font-size: 1rem;
}

/* Accanto al pulsante di invio, cliccabile in ogni momento in cui il bot è
   "occupato" (turno in corso o in attesa del valore di uno slot) - non solo
   durante lo slot-filling: interrompe la generazione in corso o annulla lo
   slot in attesa. */
.geco-chatbot-widget__stop {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-left: 1px solid #eef1f4;
    padding: 10px 12px;
    background: #fff;
    color: #c0392b;
    cursor: pointer;
    transition: background-color .15s ease;
}
.geco-chatbot-widget__stop:hover { background-color: #fdecea; }
.geco-chatbot-widget__stop .geco-chatbot-widget__icon { width: 18px; height: 18px; fill: currentColor; }
.geco-chatbot-widget__stop[hidden] { display: none; }

.geco-chatbot-widget__send {
    flex: 0 0 auto;
    border: 0;
    padding: 10px 14px;
    background-color: var(--geco-chatbot-primary);
    color: var(--geco-chatbot-text-on-primary);
    cursor: pointer;
}

.geco-chatbot-widget__credit {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: .7rem;
    text-transform: uppercase;
    color: #9aa2ab;
}

.geco-chatbot-widget__credit-logo { height: 14px; width: auto; }

@media (max-width: 576px) {
    .geco-chatbot-widget { --geco-chatbot-gap: 12px; }
    .geco-chatbot-widget__panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
    }
}
