/*-------------------------\*
  Pulsante apertura chatbot
\*-------------------------*/

#sg-chat-toggle {
    padding: 8px;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--sg-main-color, #0073aa);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-repeat: no-repeat;
}

#sg-chat-toggle img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/*-------------------------\*
  Contenitore
\*-------------------------*/

#sg-chat-shell {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 9999;
    width: 400px;
    max-width: calc(100vw - 48px);
    transition: all 200ms ease-in-out;
}

#sg-chat-shell.sg-ready.sg-open, body.sg-chatbot-full-screen-mode #sg-chat-shell.sg-ready {
    display: block;
}

#sg-chat-shell.expanded, body.sg-chatbot-full-screen-mode #sg-chat-shell {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
}

#sg-chat-shell.expanded #sg-chat-modal, body.sg-chatbot-full-screen-mode #sg-chat-modal {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
}

#sg-chat-shell.expanded #sg-chat-header {
    border-radius: 0;
}

#sg-chat-shell.expanded .expand-img, #sg-chat-shell:not(.expanded) .collapse-img {
    display: none;
}

body.sg-chatbot-full-screen-mode #sg-chat-btn-wrap {
    display: none;
}

/*-------------------------\*
  Sottocontenitore
\*-------------------------*/

#sg-chat-modal {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 400px;
    height: 700px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}

/*-------------------------\*
  Header fixed
\*-------------------------*/

#sg-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--sg-main-color, #1a4bbf);
    border-radius: 12px 12px 0 0;
}

#sg-chat-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--sg-text-color, #ffffff);
    line-height: 1.2;
}

#sg-chat-btn-wrap {
    display: flex;
    column-gap: .3rem;
}

#sg-chat-header button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: var(--sg-text-color, #ffffff);
    padding: 4px 8px;
    border-radius: 4px;
}

#sg-chat-header button img {
    height: 16px;
    width: 16px;
}

#sg-chat-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

#sg-chat-shell strong {
    font-weight: 800;
}


/*----------------------------\*
  Contenitore form scrollabile
\*----------------------------*/

#sg-ai-chatbot-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/*----------------------------------\*
  Contenitore form di autenticazione
\*----------------------------------*/

#sg-auth-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    row-gap: 1rem;
    padding-top: 1rem;
}

#sg-auth-header,
.sg-auth-header {
    text-align: center;
    font-size: 15px;
    color: #666;
    font-weight: 700;
}

#sg-signin-form,
#sg-signup-form,
#sg-lostpassword-form,
#sg-resetpassword-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 28px 24px 20px;
    flex: 1;
}

.sg-login-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 8px;
}

.sg-login-field label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.sg-login-field input {
    padding: 13px 14px;
    border: 1.5px solid #e2e6ea;
    border-radius: 8px;
    font-size: 14px;
    color: #101828;
    background: #f9fafb;
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.sg-login-field input:hover {
    border-color: #b0b8c4;
    background: #fff;
}

.sg-login-field input:focus {
    border-color: var(--sg-main-color, #0073aa);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.12);
}

#sg-chat-notice {
    padding: 16px 20px;
    font-size: 14px;
    color: #555;
}

.sg-form-feedback {
    font-size: 13px;
    border-radius: 6px;
    padding: 10px 12px;
}

.sg-form-feedback.error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.sg-form-feedback.success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

#sg-login-submit,
#sg-signup-submit,
#sg-lostpassword-submit,
#sg-resetpassword-submit {
    padding: 9px 14px;
    background: var(--sg-main-color, #0073aa);
    color: var(--sg-text-color, #ffffff);
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

#sg-login-submit:hover:not(:disabled),
#sg-signup-submit:hover:not(:disabled),
#sg-lostpassword-submit:hover:not(:disabled),
#sg-resetpassword-submit:hover:not(:disabled) {
    opacity: 0.88;
}

#sg-login-submit:disabled,
#sg-signup-submit:disabled,
#sg-lostpassword-submit:disabled,
#sg-resetpassword-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.sg-auth-meta {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-top: 2px;
}

.sg-auth-meta a,
a.toggle-signin-signup-form {
    color: var(--sg-main-color, #0073aa);
    text-decoration: none;
    font-weight: 500;
}

.sg-auth-meta a:hover,
a.toggle-signin-signup-form:hover {
    text-decoration: underline;
}

/* Chat widget */
#sg-chat-widget {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.sg-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.sg-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    word-break: break-word;
}

.sg-user {
    align-self: flex-end;
    align-items: flex-end;
}

.sg-assistant,
.sg-error {
    align-self: flex-start;
    align-items: flex-start;
}

.sg-message-content {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.sg-assistant .sg-message-content {
    background: #f1f3f5;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.sg-error .sg-message-content {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-bottom-left-radius: 4px;
}

.sg-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.sg-copy {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0.6;
}

.sg-copy:hover {
    opacity: 1;
    background: none;
}

.sg-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    align-items: flex-end;
}



.sg-btn-send {
    padding: 8px 16px;
    background: var(--sg-main-color, #0073aa);
    color: var(--sg-text-color, #ffffff);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.sg-btn-send:hover {
    opacity: 0.88;
}

.sg-actions {
    padding: 6px 12px 10px;
    display: flex;
    justify-content: center;
}

.sg-btn-clear {
    background: none;
    border: none;
    font-size: 12px;
    color: #999;
    cursor: pointer;
    width: 100%;
}

.sg-btn-clear:hover {
    color: var(--sg-text-color);
    background-color: var(--sg-main-color);
}

.sg-message-content a {
    color: var(--sg-main-color, #0073aa);
    font-weight: 600;
    border-radius: 3px;
    text-decoration: none;
}

.sg-message-content a:hover {
    opacity: 0.85;
    text-decoration: underline;
}

/* Typing indicator */
.sg-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
}

.sg-typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: darkolivegreen;
    /* background: var(--sg-assistant-text-color); */
    animation: sg-typing-bounce 1.2s infinite ease-in-out;
}

.sg-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.sg-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.sg-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes sg-typing-bounce {

    0%,
    60%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    30% {
        transform: scale(1.5);
        opacity: 1;
    }
}

/*-------------------------\*
  Formattazione contenuto KB Markdown
\*-------------------------*/

.sg-message-content p {
    margin: 0 0 10px 0;
}

.sg-message-content p:last-child {
    margin-bottom: 0;
}

.sg-message-content h1,
.sg-message-content h2,
.sg-message-content h3,
.sg-message-content h4,
.sg-message-content h5,
.sg-message-content h6 {
    margin: 0 0 10px 0;
    line-height: 1.3;
    color: #1a1a1a;
}

.sg-message-content h1 {
    font-size: 18px;
}

.sg-message-content h2 {
    font-size: 16px;
}

.sg-message-content h3 {
    font-size: 15px;
}

.sg-message-content h4,
.sg-message-content h5,
.sg-message-content h6 {
    font-size: 14px;
}

.sg-message-content .sg-list {
    margin: 0 0 10px 0;
}

.sg-message-content .sg-list li {
    margin-bottom: 6px;
}

.sg-message-content .sg-list li:last-child {
    margin-bottom: 0;
}



/*-------------------------\*
  Aree Interazione
\*-------------------------*/


.sg-messages {
    background: hsla(0, 0%, 95%, 1);
}

    .sg-user .sg-message-content {
        background: hsla(0, 0%, 90%, 1);
        color: hsla(0, 0%, 20%, 1);
        border: 1px solid hsla(0, 0%, 85%, 1);
        border-bottom-right-radius: 0;
    }



.sg-input-area {
    background: hsla(0, 0%, 100%, 1);
}

    .sg-input-area textarea {
        flex: 1;
        padding: .5em;
        font-size: 16px;
        min-height: 80px;
        color: hsla(0,0%,5%,1);
        border: 1px solid hsl(0, 0%, 67%);
        border-radius: 8px;
        resize: none;
        outline: none;
        font-family: inherit;
        transition: border-color 0.15s;
    }

    .sg-input-area textarea:hover {
        color: hsla(0,0%,5%,1);
    }

    .sg-input-area textarea:focus {
        border-color: var(--sg-main-color, #0073aa);
        box-shadow: 0 0 0 1px var(--sg-main-color);
    }



.sg-message.sg-assistant .sg-message-content {
    color: hsla(0, 0%, 20%, 1);
    background-color: transparent;
}

    .sg-message.sg-assistant .sg-message-content a {
        color: var(--sg-assistant-link-color);
    }

    .sg-message.sg-assistant .sg-message-content a.sample-message {
        display: inline-block;
        margin-bottom: .25em;
        padding: 1em 1.25em;
        color: hsla(0, 0%, 20%, 1);
        background: hsla(0,0%,98%,1);
        border: 1px solid #eaeaea;
        line-height: 1.4;
    }
    








/* Elenchi puntati e numerati */
.sg-message-content ul,
.sg-message-content ol {
    display: inline-block;
    margin-top: 12px;
    margin-bottom: 0;
    padding-left: 16px;
}
