/*-------------------------\*
  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);
}

#sg-chat-shell.sg-open {
    display: block;
}

/*-------------------------\*
  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-close {
    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-close: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-user .sg-message-content {
    background: var(--sg-main-color, #0073aa);
    color: var(--sg-text-color, #ffffff);
    border-bottom-right-radius: 4px;
}

.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-input-area textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

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

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

/* 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: #888;
    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;
    }
}