/* ======================================================= */

/* ==          STYLES FOR PUBLIC FACING CHATBOT         == */

/* ======================================================= */



/* --- Base Styles (Desktop) --- */

#chatbox {

    position: fixed;

    bottom: -800px; /* Initially hidden */

    width: 400px;

    height: var(--chatbot-window-height, 600px);

    background-color: var(--chatbot-chatbox-bg-color, #fff);

    border: none;

    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

    transition: bottom 0.3s ease;

    display: flex;

    flex-direction: column;

    z-index: 9999;

    border-radius: 10px;

    box-sizing: border-box;

}



#chatbox.chatbox-closed {

    bottom: -800px;

}



#chatbox-header {

    background-color: var(--chatbot-header-bg-color, #038AF9);

    color: var(--chatbot-header-text-color, #fff);

    padding: 10px;

    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;    

    font-size: 18px;

    text-align: center;

    position: relative;

    min-height: 40px;

    box-sizing: border-box;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 10px 10px 0 0;

    overflow: hidden;

}



#chatbox-header #chatbox-close {

    position: absolute;

    top: 5px;

    right: 10px;

    font-size: 20px;

    cursor: pointer;

    color: var(--chatbot-header-text-color, #fff);

}



#chatbox-content {

    flex: 1;

    padding: 10px;

    overflow-y: auto;

    box-sizing: border-box;

}



/* =================================== */

/* == RESTORED FUNCTIONAL HACK      == */

/* =================================== */



.chat-message {

    margin-bottom: 10px;

    display: flex;

    align-items: flex-start; /* Allinea in alto */

    max-width: 100%;

}



.chat-message.user {

    flex-direction: row-reverse;

    margin-right: -10px; /* L'hack per tirare a destra */

}



.chat-message.bot {

    justify-content: flex-start;

}



.chat-message img {

    width: 40px;

    height: 40px;

    border-radius: 50%;

    flex-shrink: 0;

}



.chat-message .chat-bubble {

    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

    font-size: 15px;

    padding: 10px;

    border-radius: 10px;

    max-width: 90%;

    word-wrap: break-word;

    box-sizing: border-box;

    line-height: 1.4;

}



.chat-message.user .chat-bubble {

    background-color: var(--chatbot-user-message-bg-color, #add8e6);

    color: var(--chatbot-user-message-text-color, #000);

    margin-right: 10px; /* L'hack per creare lo spazio */

}



.chat-message.bot .chat-bubble {

    background-color: var(--chatbot-bot-message-bg-color, #ffc0cb);

    color: var(--chatbot-bot-message-text-color, #000);

    margin-left: 10px;

}



#chatbox .chat-message .chat-bubble p {

    margin: 0;

    padding: 0;

    font-size: inherit;

    line-height: inherit;

}



.chat-message.loading img {

    width: 40px;

    height: 20px;

}



#chatbox-controls {

    display: flex;

    padding: 10px;

    border-top: 1px solid #ccc;

    box-sizing: border-box;

    height: 60px !important;

    min-height: 60px !important;

    max-height: 60px !important;

}



#chatbox-input {

    flex: 1;

    padding: 10px;

    border: 1px solid #ccc;

    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

    font-size: 15px !important;

    color: #4a4a4a;

    border-radius: 5px;

    margin-right: 10px;

    box-sizing: border-box;

    height: 40px !important;

    min-height: 40px !important;

    line-height: normal !important;

}



#chatbox-send {

    padding: 10px 20px;

    border: none;

    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

    font-size: 16px;

    border-radius: 5px;

    cursor: pointer;

    box-sizing: border-box;

    height: 40px !important;

    min-height: 40px !important;

    line-height: 20px !important;

    background-color: var(--chatbot-send-button-bg-color, #dc3232);

    color: var(--chatbot-send-button-text-color, #fff);

}



#chatbox-send:hover {

    background-color: #b91919;

}



#chatbot-container {

    position: fixed;

    bottom: 20px;

    width: 350px;

    height: 80px;

    z-index: 2147483647;

    pointer-events: none;

    display: flex;

    align-items: flex-end;

}



#chatbox-button {

    position: relative;

    width: 60px;

    height: 60px;

    border-radius: 50%;

    overflow: hidden;

    cursor: pointer;

    pointer-events: all;

    box-shadow: 0 2px 6px rgba(0,0,0,0.3);

    flex-shrink: 0;

}



#chatbox-button img {

    display: block;

    width: 100%;

    height: 110%;

    object-fit: cover;

    transform: translate(-0%, -2.5%);

    border-radius: 50%;

}



#chatbox-footer {

    padding: 5px 10px;

    text-align: center;

    font-size: 0.8em;

    color: #808080;

    border-top: 1px solid #ccc;

    box-sizing: border-box;

}



#chatbox-powered {

  text-align: center;

  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;  

  font-size: 14px !important;

  color: #808080 !important;

}



#chatbox-powered a {

    color: #808080 !important;

    text-decoration: none;

}



#chatbox-powered a:hover {

    text-decoration: underline;

}



/* --- Positioning Rules --- */

#chatbox.chatbot-position-right,

#chatbot-container.chatbot-position-right {

    right: 20px;

    left: auto;

    justify-content: flex-end;

}



#chatbox.chatbot-position-left,

#chatbot-container.chatbot-position-left {

    left: 20px;

    right: auto;

    justify-content: flex-start;

}



/* --- Pre-Chat Form --- */

#prechat-form {

    padding: 20px;

    text-align: center;

}

#prechat-form h3 {

    margin-top: 0;

    font-size: 1.2em;

}

#prechat-form .form-field {

    margin-bottom: 15px;

    text-align: left;

}

#prechat-form label {

    display: block;

    margin-bottom: 5px;

    font-weight: bold;

    font-size: 0.9em;

}

#prechat-form input[type="text"],

#prechat-form input[type="email"] {

    width: 100%;

    padding: 8px;

    border: 1px solid #ccc;

    border-radius: 4px;

    box-sizing: border-box;

}

#prechat-start-btn {

    background-color: var(--chatbot-header-bg-color, #038AF9);

    color: var(--chatbot-header-text-color, #fff);

    border: none;

    padding: 10px 20px;

    border-radius: 5px;

    cursor: pointer;

    font-size: 1em;

    width: 100%;

}



/* --- Proactive Message Bubble --- */

#chatbot-proactive-bubble {

    position: fixed;

    bottom: 25px;

    z-index: 9998;

    background-color: var(--chatbot-header-bg-color, #038AF9);

    color: var(--chatbot-header-text-color, #fff);

    padding: 12px 18px;

    padding-right: 30px;

    border-radius: 8px;

    box-shadow: 0 4px 8px rgba(0,0,0,0.15);

    opacity: 0;

    transform: translateY(10px);

    transition: opacity 0.3s ease, transform 0.3s ease;

    pointer-events: none;

    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;

    font-size: 14px;

    max-width: 300px;

    line-height: 1.4;

    text-align: left;

    word-wrap: break-word;

}



#chatbot-proactive-bubble.visible {

    opacity: 1;

    transform: translateY(0);

    pointer-events: all;

}



#chatbot-proactive-bubble::after {

    content: '';

    position: absolute;

    top: 50%;

    transform: translateY(-50%);

    width: 0; 

    height: 0; 

    border-top: 8px solid transparent;

    border-bottom: 8px solid transparent;

}



#chatbot-proactive-bubble.chatbot-position-right {

    right: 95px;

    left: auto;

}

#chatbot-proactive-bubble.chatbot-position-right::after {

    right: -8px;

    left: auto;

    border-left: 8px solid var(--chatbot-header-bg-color, #038AF9);

}



#chatbot-proactive-bubble.chatbot-position-left {

    left: 95px;

    right: auto;

}

#chatbot-proactive-bubble.chatbot-position-left::after {

    left: -8px;

    right: auto;

    border-right: 8px solid var(--chatbot-header-bg-color, #038AF9);

}



.chatbot-proactive-close {

    position: absolute;

    top: 5px;

    right: 8px;

    font-size: 22px;

    cursor: pointer;

    font-weight: bold;

    line-height: 1;

    color: var(--chatbot-header-text-color, #fff);

    opacity: 0.7;

    transition: opacity 0.2s;

}



.chatbot-proactive-close:hover {

    opacity: 1;

}



/* --- Embedded Shortcode Styles --- */

.chatbot-shortcode-wrapper {

    position: relative;

    height: 600px;

    width: 100%; 

    max-width: 1100px; 

    margin: 40px auto;

    border: 1px solid #e0e0e0;

    border-radius: 10px;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

    overflow: hidden;

}



.chatbot-shortcode-wrapper #chatbox {

    border-radius: 0;

    box-shadow: none;

}



/* --- Mobile Responsive Styles --- */

@media (max-width: 768px) {

    #chatbox {

        width: 100%;

        height: calc(100% - 60px);

        bottom: -100vh;

        left: 0;

        right: 0;

        border-radius: 0;

    }

    

    #chatbox-header {

        height: 55px;

        border-radius: 0;

    }

    

    #chatbot-container {

        bottom: 5px;

    }

    

    #chatbot-container.chatbot-position-right { right: 5px; }

    #chatbot-container.chatbot-position-left { left: 5px; }

    

    #chatbox-button {

        width: 50px;

        height: 50px;

    }



    #chatbot-proactive-bubble {

        bottom: 20px;

        max-width: calc(100vw - 80px);

    }

    #chatbot-proactive-bubble.chatbot-position-right { right: 65px; }

    #chatbot-proactive-bubble.chatbot-position-left { left: 65px; }    

}



/* ============================================= */

/* STILI SPECIFICI PER LO SHORTCODE EMBEDDED     */

/* ============================================= */



body .chatbot-shortcode-wrapper {

    position: relative !important;

    height: 600px !important;

    width: 100% !important; 

    max-width: 100% !important;

    margin: 40px 0 !important;

    border: 1px solid #e0e0e0 !important;

    overflow: hidden !important;

    border-radius: 8px !important; /* Ripristiniamo gli angoli arrotondati desiderati */

    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;

}



body .chatbot-shortcode-wrapper #chatbox {

    border-radius: 0 !important;

    box-shadow: none !important;

}



body .chatbot-shortcode-wrapper #chatbox-header {

    border-radius: 0 !important;

    min-height: 50px !important;

    font-size: 20px !important;

}



body .chatbot-shortcode-wrapper #chatbox-controls {

    height: 80px !important;

    padding: 20px !important;

    align-items: center !important;

}



body .chatbot-shortcode-wrapper #chatbox-input {

    height: 50px !important;

    font-size: 16px !important;

}



body .chatbot-shortcode-wrapper #chatbox-send {

    height: 50px !important;

    padding: 10px 25px !important;

}


/* ==========================================================================
   ANONIX AI - PREMIUM CUSTOM REDESIGN OVERRIDES (APPENDED)
   ========================================================================== */

/* --- Main Chat Window Wrapper --- */
#chatbox,
body .chatbot-shortcode-wrapper #chatbox {
    background-color: rgba(15, 23, 42, 0.45) !important; /* Translucent slate */
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4), 
                0 0 40px rgba(159, 111, 255, 0.03) !important; /* Ambient purple aura */
    border-radius: 16px !important;
}

body .chatbot-shortcode-wrapper {
    background-color: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4) !important;
}

/* --- Header Bar (Replacing the turquoise) --- */
#chatbox-header,
body .chatbot-shortcode-wrapper #chatbox-header {
    background: linear-gradient(90deg, rgba(159, 111, 255, 0.15) 0%, rgba(76, 111, 255, 0.15) 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-weight: 700 !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3) !important;
}

/* --- Message Content Scrolling View (Replacing the gray area) --- */
#chatbox-content {
    background: transparent !important; /* Pulls native background view wallpaper */
    padding: 20px !important;
}

/* --- Chat Message Bubbles --- */
.chat-message .chat-bubble {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 14px !important;
    border-radius: 12px !important;
    line-height: 1.5 !important;
    padding: 12px 16px !important;
}

/* User Message Bubble */
.chat-message.user .chat-bubble {
    background-color: rgba(159, 111, 255, 0.2) !important; /* Signature Anonix Purple Blur */
    color: #ffffff !important;
    border: 1px solid rgba(159, 111, 255, 0.35) !important;
    box-shadow: 0 4px 15px rgba(159, 111, 255, 0.1) !important;
    border-bottom-right-radius: 2px !important;
}

/* AI Bot Message Bubble */
.chat-message.bot .chat-bubble {
    background-color: rgba(255, 255, 255, 0.05) !important; /* Clean Translucent Neutral */
    color: #cbd5e1 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-bottom-left-radius: 2px !important;
}

#chatbox .chat-message .chat-bubble p {
    color: inherit !important;
}

.chat-message img {
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* --- Bottom Control Fields --- */
#chatbox-controls,
body .chatbot-shortcode-wrapper #chatbox-controls {
    background-color: rgba(15, 23, 42, 0.8) !important; /* Darker mask layout for footer */
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Input Box Field */
#chatbox-input,
body .chatbot-shortcode-wrapper #chatbox-input {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    padding: 12px 16px !important;
    transition: all 0.2s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

#chatbox-input:focus,
body .chatbot-shortcode-wrapper #chatbox-input:focus {
    border-color: #9f6fff !important;
    box-shadow: 0 0 10px rgba(159, 111, 255, 0.25) !important;
    outline: none !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Send Button (Changing Red to Glowing Purple) */
#chatbox-send,
body .chatbot-shortcode-wrapper #chatbox-send {
    background-color: #9f6fff !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(159, 111, 255, 0.2) !important;
}

#chatbox-send:hover,
body .chatbot-shortcode-wrapper #chatbox-send:hover {
    background-color: #4c6fff !important; /* Shifting to blue accent color on hover */
    box-shadow: 0 4px 15px rgba(76, 111, 255, 0.4) !important;
}

/* --- Clean Up Credits Footer Link --- */
#chatbox-footer,
#chatbox-powered {
    background-color: rgba(15, 23, 42, 0.9) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #475569 !important;
    font-size: 11px !important;
}

#chatbox-powered a {
    color: #64748b !important;
}

#chatbox-powered a:hover {
    color: #9f6fff !important;
}