/* ==========================================================
   WP CHAT — STILI COMPLETI
   ========================================================== */

/* ----------------------------------------------------------
   CHAT BOX
   ---------------------------------------------------------- */
#chat-box {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px;
    gap: 5px;
}

/* ----------------------------------------------------------
   RIGHE MESSAGGI
   ---------------------------------------------------------- */
.chat-message-row {
    display: flex;
    align-items: flex-end;
    margin: 10px 0;
    width: 100%;
}
.chat-message-row.user      { flex-direction: row-reverse; }
.chat-message-row.assistant { flex-direction: row; }

/* ----------------------------------------------------------
   AVATAR
   ---------------------------------------------------------- */
.chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-message-row.user      .chat-avatar { margin-left: 8px; }
.chat-message-row.assistant .chat-avatar { margin-right: 8px; }

/* ----------------------------------------------------------
   FUMETTI
   ---------------------------------------------------------- */
.chat-bubble {
    max-width: 85%;
    word-wrap: break-word;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    display: inline-block;
    line-height: 1.4;
    font-size: 14px;
}
.chat-message-row.user .chat-bubble {
    background: #2a3d8f;
    color: #ffffff;
    border-radius: 15px 15px 0 15px;
}
.chat-message-row.assistant .chat-bubble {
    background: #f1f0f0;
    color: #000000;
    border-radius: 15px 15px 15px 0;
}

/* Link nei fumetti */
#chat-box a {
    color: #007bff;
    text-decoration: underline;
    word-break: break-all;
}

/* Codice inline nei fumetti */
#chat-box code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
}

/* ----------------------------------------------------------
   LOGO CENTRATO — animato come #character-container
   ---------------------------------------------------------- */
.chat-logo-row {
    display: flex;
    justify-content: center;
    margin: 40px 0 8px 0;
    width: 100%;
}
.chat-logo-animated {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    cursor: default;
}
.chat-logo-animated img {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: auto;
    object-fit: contain;
}

/* Blink idle */
#chat-blink {
    opacity: 0;
    z-index: 2;
    animation: blink-anim 4s infinite;
}

/* Hover — nascosti di default */
#chat-arcy-hover,
#chat-arcy-hover-blink {
    opacity: 0;
    z-index: 10;
}
#chat-arcy-hover-blink { z-index: 11; }

/* Azioni al mouseover */
.chat-logo-animated:hover #chat-eye-base,
.chat-logo-animated:hover #chat-blink {
    opacity: 0;
    animation: none;
}
.chat-logo-animated:hover #chat-arcy-hover {
    opacity: 1;
}
.chat-logo-animated:hover #chat-arcy-hover-blink {
    animation: blink-anim 4s infinite;
}

/* ----------------------------------------------------------
   BANNER DISCLAIMER AI
   ---------------------------------------------------------- */
#ai-disclaimer-banner {
    background: #e8f4fd;
    border: 1px solid #3a9ad9;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 16px 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    text-align: center;
}
#ai-disclaimer-banner p { margin: 0 0 8px 0; }
#ai-disclaimer-banner p:last-child { margin-bottom: 0; }
#ai-disclaimer-banner strong { font-weight: 600; }

/* ----------------------------------------------------------
   SUGGERIMENTI RAPIDI
   ---------------------------------------------------------- */
#chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 38px;
    animation: fadeIn 0.5s;
}
#chat-suggestions button {
    background: white;
    border: 1px solid #2a3d8f;
    color: #2a3d8f;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
#chat-suggestions button:hover {
    background: #2a3d8f;
    color: #ffffff;
}

/* ----------------------------------------------------------
   TYPING INDICATOR
   ---------------------------------------------------------- */
.typing-indicator {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: #f1f0f0;
    padding: 12px 18px;
    border-radius: 15px 15px 15px 0;
    min-width: 50px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1.2); opacity: 1; }
}

/* ----------------------------------------------------------
   CONTAINER CHAT (stato nascosto / visibile)
   ---------------------------------------------------------- */
#chat-container {
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    z-index: 9999;
}
#chat-container.chat-animated-visible {
    display: flex !important;
    flex-direction: column;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

/* ----------------------------------------------------------
   SIDEBAR
   ---------------------------------------------------------- */
#chatbot-sidebar {
    width: 390px;
    position: fixed;
    left: -390px;
    top: 0;
    height: 100dvh;
    transition: all 0.3s ease-in-out;
    z-index: 9999;
    background: #fff;
    border-right: 1px solid #ddd;
    visibility: hidden;
}
#brx-content, header, footer {
    transition: all 0.3s ease-in-out;
}
body.chatbot-active #chatbot-sidebar {
    left: 0;
    visibility: visible;
}
body.chatbot-active #brx-content,
body.chatbot-active header,
body.chatbot-active footer {
    margin-left: 390px;
    width: calc(100% - 390px);
}

/* ----------------------------------------------------------
   OVERLAY DI CHIUSURA
   ---------------------------------------------------------- */
#chatbot-closer-overlay {
    position: fixed;
    top: 0;
    left: 400px;
    width: calc(100% - 400px);
    height: 100dvh;
    z-index: 9998;
    display: none;
    cursor: pointer;
}
body.chatbot-active #chatbot-closer-overlay {
    display: block;
}

/* ----------------------------------------------------------
   BOTTONE ARCY (glow pulsante)
   ---------------------------------------------------------- */
.glow-pulse-blue-light {
    width: 200px;
    height: 60px;
    background-color: #ffffff;
    border: 2px solid #0071b3;
    border-radius: 50px;
    color: #0071b3;
    font-weight: bold;
    cursor: pointer;
    animation: pulse-blue-light 2s infinite;
}
@keyframes pulse-blue-light {
    0%   { box-shadow: 0 0 0 0   rgba(0,113,179,0.7); }
    70%  { box-shadow: 0 0 0 15px rgba(0,113,179,0);   }
    100% { box-shadow: 0 0 0 0   rgba(0,113,179,0);   }
}

/* ----------------------------------------------------------
   TYPEWRITER
   ---------------------------------------------------------- */
.typewriter-container {
    min-height: 1.2em;
}
.cursor {
    font-weight: bold;
    animation: blink 0.7s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ----------------------------------------------------------
   ICONA ARCY — stati hover / blink
   ---------------------------------------------------------- */
#character-container img {
    transition: opacity 0s ease;
}

/* Stato normale */
#blink {
    opacity: 0;
    z-index: 2;
    animation: blink-anim 4s infinite;
}

/* Stato hover — nascosti di default */
#arcy-hover,
#arcy-hover-blink {
    opacity: 0;
    z-index: 10;
}
#arcy-hover-blink { z-index: 11; }

/* Azioni al mouseover */
#character-container:hover #eye-base,
#character-container:hover #blink {
    opacity: 0;
    animation: none;
}
#character-container:hover #arcy-hover {
    opacity: 1;
}
#character-container:hover #arcy-hover-blink {
    animation: blink-anim 4s infinite;
}

@keyframes blink-anim {
    0%, 47%, 53%, 100% { opacity: 0; }
    50%                { opacity: 1; }
}

/* ----------------------------------------------------------
   ANIMAZIONE FADE IN (usata dai suggerimenti)
   ---------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------------
   MOBILE
   ---------------------------------------------------------- */
@media (max-width: 767px) {
    #chatbot-sidebar {
        width: 100%;
        left: -100%;
        border-right: none;
    }
    body.chatbot-active #chatbot-sidebar {
        left: 0;
    }
    body.chatbot-active #brx-content,
    body.chatbot-active header,
    body.chatbot-active footer {
        margin-left: 0 !important;
        width: 100% !important;
    }
    #chatbot-closer-overlay {
        display: none !important;
    }
    #arcy-icon-and-msg {
        bottom: 16px;
        left: 16px;
    }
    /* Blocca lo scroll della pagina quando la chat è aperta su mobile */
    body.chatbot-active {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }
}

/* ----------------------------------------------------------
   MODAL COOKIE REQUIRED
   ---------------------------------------------------------- */
#arcy-cookie-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#arcy-cookie-modal.visible {
    display: flex;
}
#arcy-cookie-modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 24px 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    text-align: center;
}
#arcy-cookie-modal-box .acm-icon {
    margin-bottom: 12px;
}
#mcc-banner {
    display: inline-block;
    cursor: default;
}
#arcy-cookie-img-wrap {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}
#mcc-cookie-anim {
    width: 80px !important;
    height: 80px !important;
    object-fit: contain !important;
    display: block !important;
}
#arcy-cookie-modal-box h3 {
    margin: 0 0 10px 0;
    font-size: 17px;
    font-weight: 700;
    color: #0f1729;
}
#arcy-cookie-modal-box p {
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #444;
}
.acm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.acm-btn-primary {
    flex: 1;
    padding: 11px 16px;
    background: #0f1729;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.acm-btn-primary:hover { opacity: 0.85; }
.acm-btn-secondary {
    flex: 1;
    padding: 11px 16px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.acm-btn-secondary:hover { background: #e0e0e0; }

/* ----------------------------------------------------------
   ICONA ARCY — posizione fissa
   ---------------------------------------------------------- */
#arcy-icon-and-msg {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 9997;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}
#character-container {
    cursor: pointer;
    position: relative;
    display: inline-block;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: visible;
}
#character-container img {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: auto;
    object-fit: contain;
}
#typewriter-container {
    display: none;
    position: relative;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px 16px 16px 4px;
    padding: 12px 14px 12px 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.14);
    max-width: 200px;
    min-width: 160px;
    min-height: 44px;
    font-size: 13px;
    line-height: 1.4;
}

/* Testo dinamico */
#typewriter-text {
    padding-right: 18px;
}

/* Tasto chiudi */
#arcy-close-msg {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #bbb;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    transition: color 0.15s;
}
#arcy-close-msg:hover {
    color: #666;
}

/* ----------------------------------------------------------
   HEADER CHAT
   ---------------------------------------------------------- */
.wp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: none;
    background: #0f1729;
    flex-shrink: 0;
}
.wp-chat-title {
    font-weight: 600;
    font-size: 15px;
    color: #ffffff;
}
.wp-chat-header-actions {
    display: flex;
    gap: 8px;
}
.wp-chat-header button,
.wp-chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.15);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s;
}
.wp-chat-header button:hover,
.wp-chat-back-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* ----------------------------------------------------------
   LAYOUT INTERNO SIDEBAR
   ---------------------------------------------------------- */
#wp-chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #dcebfe;
}
#chat-box {
    flex: 1;
    overflow-y: auto;
    background: transparent;
}

/* ----------------------------------------------------------
   INPUT ROW
   ---------------------------------------------------------- */
#wp-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: none;
    background: transparent;
    flex-shrink: 0;
}
#chat-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
#chat-input:focus {
    border-color: #2a3d8f;
}
#chat-send-btn {
    background: #29A8E0;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
    padding: 0;
}
#chat-send-btn:hover    { opacity: 0.75; }
#chat-send-btn:disabled { background: #aaa; cursor: default; opacity: 1; }
#chat-send-btn .arcy-send-icon {
    transform: translateX(-2px);
}

/* ----------------------------------------------------------
   SCHERMATA PRIVACY / AUTH
   ---------------------------------------------------------- */
#arcy-privacy-check {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}
#auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    font-family: 'Segoe UI', sans-serif;
    background: #dcebfe;
}

#auth-inner {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
}
.intro-text, .end-text {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}
.intro-text { margin-bottom: 20px; }
.end-text   { margin-top: 16px; margin-bottom: 16px; }
.wp-chat-label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}
.date-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.checkbox-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.checkbox-control input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.checkbox-control label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
    user-select: none;
}
#privacy-text {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    font-size: 13px;
    resize: none;
    box-sizing: border-box;
    margin-bottom: 4px;
}
#submit-btn {
    width: 100%;
    padding: 13px;
    background: var(--color-primary, #2a3d8f);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    margin-top: 14px;
    transition: background 0.2s, opacity 0.2s;
}
#submit-btn:hover { opacity: 0.85; }
#error-msg {
    color: #d93025;
    font-size: 14px;
    margin-top: 10px;
    display: none;
}

/* ----------------------------------------------------------
   ICONA ARCY — dimensioni mobile
   ---------------------------------------------------------- */
@media screen and (max-width: 991px) {
  #chat-input {
    font-size: 16px !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
}

@media (max-width: 767px) {
    #character-container {
        width: 55px;
        height: 55px;
    }
    #character-container img {
        width: 84px;
    }
    #typewriter-container {
        display: none !important;
    }
}

/* ----------------------------------------------------------
   BRICKS MENU — forza modalità mobile quando la sidebar
   chat è aperta (il viewport non cambia ma il layout sì)
   ---------------------------------------------------------- */

@media (max-width: 1680px) {
/* Nasconde il menu desktop */
body.chatbot-active #brxe-cpzqjd {
    display: none !important;
}

/* Mostra il pulsante hamburger */
body.chatbot-active #mobile-menu-toggle {
    display: flex !important;
}
}

/* ----------------------------------------------------------
   FORM DI CONTATTO IN CHAT
   ---------------------------------------------------------- */
.chat-contact-form {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    margin: 4px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
}
.chat-contact-form .ccf-title {
    font-weight: 700;
    font-size: 14px;
    color: #0f1729;
    margin-bottom: 12px;
}
.chat-contact-form .ccf-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.chat-contact-form .ccf-field {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.chat-contact-form .ccf-field label {
    font-size: 11px;
    color: #666;
    margin-bottom: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.chat-contact-form input[type="text"],
.chat-contact-form input[type="email"],
.chat-contact-form input[type="tel"],
.chat-contact-form select,
.chat-contact-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dde3f0;
    border-radius: 8px;
    font-size: 13px;
    color: #222;
    background: #f8faff;
    box-sizing: border-box;
    transition: border-color 0.2s;
    font-family: inherit;
}
.chat-contact-form input:focus,
.chat-contact-form select:focus,
.chat-contact-form textarea:focus {
    outline: none;
    border-color: #2a3d8f;
    background: #fff;
}
.chat-contact-form textarea {
    resize: none;
    min-height: 72px;
}
.chat-contact-form .ccf-privacy {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0 12px 0;
    font-size: 12px;
    color: #555;
    line-height: 1.4;
}
.chat-contact-form .ccf-privacy input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.chat-contact-form .ccf-submit {
    width: 100%;
    padding: 10px;
    background: #2a3d8f;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.chat-contact-form .ccf-submit:hover  { opacity: 0.85; }
.chat-contact-form .ccf-submit:disabled { opacity: 0.5; cursor: default; }
.chat-contact-form .ccf-error {
    color: #d93025;
    font-size: 12px;
    margin-top: 6px;
    display: none;
}
.chat-contact-form .ccf-success {
    text-align: center;
    padding: 16px 8px;
    color: #1a7f37;
    font-weight: 600;
    font-size: 14px;
}
.chat-contact-form .ccf-success span {
    display: block;
    font-size: 28px;
    margin-bottom: 6px;
}
