/* ======================================================= */
/* ==          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;
}

.chat-message {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
    margin-right: -10px;
}

.chat-message.user span {
    background-color: var(--chatbot-user-message-bg-color, #add8e6);
    color: var(--chatbot-user-message-text-color, #000);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px !important;
    padding: 10px !important;
    border-radius: 10px !important;
    max-width: 90% !important;
    word-wrap: break-word;
    margin-right: 10px !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message.bot span {
    background-color: var(--chatbot-bot-message-bg-color, #ffc0cb);
    color: var(--chatbot-bot-message-text-color, #000);
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px !important;
    padding: 10px !important;
    border-radius: 10px !important;
    max-width: 90% !important;
    word-wrap: break-word;
    margin-right: 10px !important;
    box-sizing: border-box !important;
    line-height: 1.4 !important;
}

.chat-message img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

.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: 800px !important;
    margin: 0 auto 40px auto !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;
}