/**
 * WP Chatyllo BaseBot - Stili del Widget Frontend
 * Versione: 1.5.5 (Fix Definitivo Allineamento e Bordo)
 * Descrizione: Stili "blindati" per garantire la coerenza visiva del nuovo design indipendentemente dal tema.
 */

/* --- Reset e Stili di Base Globali per il Widget --- */
#wpcb-chat-container,
#wpcb-chat-toggle-button {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    box-sizing: border-box;
}

#wpcb-chat-container *,
#wpcb-chat-toggle-button * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    /* text-align: left; Rimosso da qui per evitare problemi di allineamento */
}

#wpcb-chat-container button,
#wpcb-chat-toggle-button {
    cursor: pointer;
    text-align: center; /* Imposta center come default per i pulsanti */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
/* Fine Reset */


/* --- Pulsante Principale Toggle --- */
#wpcb-chat-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease-in-out;
    z-index: 99998;
    /* CORREZIONE BORDO (Punto 2): Forza la rimozione di qualsiasi stile del tema */
    border: none !important;
    outline: none !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25) !important;
}
#wpcb-chat-toggle-button:hover { transform: scale(1.1); }

/* Stile del focus per accessibilità, reso più forte per sovrascrivere il tema */
#wpcb-chat-toggle-button:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 0 5px currentColor !important;
}

#wpcb-chat-toggle-button svg {
    width: 32px;
    height: 32px;
    fill: white;
}
.wpcb-hidden { display: none !important; }

/* --- Contenitore Principale Chat --- */
#wpcb-chat-container {
    position: fixed;
    bottom: 95px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: 75vh;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    transition: opacity 0.3s, transform 0.3s;
    transform-origin: bottom right;
}
#wpcb-chat-container.wpcb-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

/* --- Header --- */
#wpcb-chat-container .wpcb-chat-header {
    padding: 15px;
    color: white;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
#wpcb-chat-container .wpcb-header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid rgba(255, 255, 255, 0.5);
}
#wpcb-chat-container .wpcb-header-title { flex-grow: 1; text-align: left; }
#wpcb-chat-container .wpcb-header-title strong { display: block; font-size: 16px; font-weight: bold; }
#wpcb-chat-container .wpcb-header-title .wpcb-status { font-size: 12px; opacity: 0.8; }
#wpcb-chat-container .wpcb-header-title .wpcb-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    margin-right: 5px;
}
#wpcb-chat-container #wpcb-toggle-chat {
    margin-left: auto;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
    transform: rotate(180deg);
}

/* --- Corpo Chat --- */
#wpcb-chat-container .wpcb-chat-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f4f7f9;
}
#wpcb-chat-container .wpcb-message {
    margin-bottom: 10px;
    max-width: 80%;
    clear: both;
    opacity: 0;
    transform: translateY(10px);
    animation: wpcb-fade-in 0.3s forwards;
}
#wpcb-chat-container .wpcb-message p {
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    text-align: left; /* Assicura che il testo nei messaggi sia a sinistra */
}
#wpcb-chat-container .wpcb-bot-message { float: left; }
#wpcb-chat-container .wpcb-bot-message p { background: #E5E5EA; color: #000; border-bottom-left-radius: 5px; }
#wpcb-chat-container .wpcb-user-message { float: right; }
#wpcb-chat-container .wpcb-user-message p { background: #6A4BFF; color: #fff; border-bottom-right-radius: 5px; }

@keyframes wpcb-fade-in {
    to { opacity: 1; transform: translateY(0); }
}

/* --- Footer --- */
#wpcb-chat-container .wpcb-chat-footer { display: flex; align-items: center; padding: 10px; border-top: 1px solid #eee; }
#wpcb-chat-container #wpcb-user-input {
    flex-grow: 1;
    background: #f4f7f9;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 15px;
    color: #333;
    text-align: left;
}
#wpcb-chat-container #wpcb-user-input:focus { outline: none; }
#wpcb-chat-container #wpcb-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    margin-left: 10px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}
#wpcb-chat-container #wpcb-send-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* --- Indicatore Scrittura --- */
#wpcb-chat-container .wpcb-typing-indicator p {
    display: flex;
    align-items: center;
}
#wpcb-chat-container .wpcb-typing-indicator .wpcb-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #aaa;
    margin: 0 2px;
    animation: wpcb-bounce 1.3s infinite ease-in-out both;
}
#wpcb-chat-container .wpcb-typing-indicator .wpcb-dot:nth-child(1) { animation-delay: -0.32s; }
#wpcb-chat-container .wpcb-typing-indicator .wpcb-dot:nth-child(2) { animation-delay: -0.16s; }
#wpcb-chat-container .wpcb-typing-indicator .wpcb-thinking-text {
    font-size: 13px;
    color: #888;
    font-style: italic;
    margin-left: 8px;
}

@keyframes wpcb-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* --- Area Feedback --- */
/* CORREZIONE ALLINEAMENTO (Punto 1) */
#wpcb-chat-container .wpcb-feedback-area {
    padding: 10px 15px;
    text-align: center; /* Allinea tutto il contenuto al centro */
    background: #f4f7f9;
}
#wpcb-chat-container .wpcb-feedback-prompt {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    text-align: center; /* Specifica anche per questo elemento */
}
#wpcb-chat-container .wpcb-feedback-buttons {
    text-align: center; /* Specifica anche per questo elemento */
}
#wpcb-chat-container .wpcb-feedback-buttons .wpcb-feedback-btn {
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    margin: 0 5px;
    transition: all 0.2s;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    background: #fff;
}
#wpcb-chat-container .wpcb-feedback-buttons .wpcb-feedback-btn:hover {
    background: #e5e5ea;
    transform: scale(1.1);
}
#wpcb-chat-container .wpcb-feedback-thanks {
    font-size: 13px;
    color: #28a745;
    font-style: italic;
    padding: 8px 0;
}

/* --- Sezione GDPR --- */
#wpcb-chat-container .wpcb-gdpr-consent {
    padding: 8px 15px;
    font-size: 11px;
    line-height: 1.4;
    color: #888;
    background-color: #fff;
    text-align: center;
    border-top: 1px solid #eee;
}
#wpcb-chat-container .wpcb-gdpr-consent a {
    color: #666;
    text-decoration: underline;
}

/* --- Brand Footer --- */
#wpcb-chat-container .wpcb-footer-brand {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: #aaa;
    background: #fff;
    border-top: 1px solid #eee;
}
#wpcb-chat-container .wpcb-footer-brand a { color: #888; text-decoration: none; }
#wpcb-chat-container .wpcb-footer-brand a:hover { text-decoration: underline; }