/**
 * Stili per il chatbot XRCopilotLab
 */

/* Fix per Safari/iOS - Assicura compatibilità cross-browser */
@supports (-webkit-appearance: none) {
    /* Safari specific fixes */
}

/* Fix per viewport su mobile */
@viewport {
    width: device-width;
    initial-scale: 1.0;
}

/* FONT SIZE UNIFORME - Tutti gli elementi nel chatbot usano la stessa dimensione font */
/* NOTA: #xrcopilot-chatbot-window viene spostato in body al momento dell'apertura,
   quindi le regole devono coprire ENTRAMBI i selettori */
html body #xrcopilot-chatbot-container,
html body #xrcopilot-chatbot-container *,
html body #xrcopilot-chatbot-container p,
html body #xrcopilot-chatbot-container li,
html body #xrcopilot-chatbot-container ul,
html body #xrcopilot-chatbot-container ol,
html body #xrcopilot-chatbot-container h1,
html body #xrcopilot-chatbot-container h2,
html body #xrcopilot-chatbot-container h3,
html body #xrcopilot-chatbot-container h4,
html body #xrcopilot-chatbot-container h5,
html body #xrcopilot-chatbot-container h6,
html body #xrcopilot-chatbot-container strong,
html body #xrcopilot-chatbot-container em,
html body #xrcopilot-chatbot-container span,
html body #xrcopilot-chatbot-container a,
html body #xrcopilot-chatbot-container div,
html body #xrcopilot-chatbot-window,
html body #xrcopilot-chatbot-window *,
html body #xrcopilot-chatbot-window p,
html body #xrcopilot-chatbot-window li,
html body #xrcopilot-chatbot-window ul,
html body #xrcopilot-chatbot-window ol,
html body #xrcopilot-chatbot-window h1,
html body #xrcopilot-chatbot-window h2,
html body #xrcopilot-chatbot-window h3,
html body #xrcopilot-chatbot-window h4,
html body #xrcopilot-chatbot-window h5,
html body #xrcopilot-chatbot-window h6,
html body #xrcopilot-chatbot-window strong,
html body #xrcopilot-chatbot-window em,
html body #xrcopilot-chatbot-window span,
html body #xrcopilot-chatbot-window a,
html body #xrcopilot-chatbot-window div {
    font-size: 14px !important;
}

/* REGOLE PRIORITARIE - SOVRASCRIVI TUTTI I BORDI ROSSI (#c36) E ALTRI BORDI ESTERNI */
#xrcopilot-chatbot-container button,
#xrcopilot-chatbot-container button *,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input {
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-top-style: none !important;
    border-right-style: none !important;
    border-bottom-style: none !important;
    border-left-style: none !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
}

/* RIMUOVI TUTTI GLI OUTLINE, BOX-SHADOW E BORDER DI FOCUS - REGOLE ULTRA AGGRESSIVE */
#xrcopilot-chatbot-container *,
#xrcopilot-chatbot-container *::before,
#xrcopilot-chatbot-container *::after,
#xrcopilot-chatbot-container *:focus,
#xrcopilot-chatbot-container *:focus-visible,
#xrcopilot-chatbot-container *:focus-within,
#xrcopilot-chatbot-container *:active,
#xrcopilot-chatbot-container *:hover,
#xrcopilot-chatbot-container *:hover:focus,
#xrcopilot-chatbot-container button,
#xrcopilot-chatbot-container button:focus,
#xrcopilot-chatbot-container button:focus-visible,
#xrcopilot-chatbot-container button:focus-within,
#xrcopilot-chatbot-container button:active,
#xrcopilot-chatbot-container button:hover,
#xrcopilot-chatbot-container button:hover:focus,
#xrcopilot-chatbot-container input,
#xrcopilot-chatbot-container input:focus,
#xrcopilot-chatbot-container input:focus-visible,
#xrcopilot-chatbot-container input:focus-within,
#xrcopilot-chatbot-container input:active,
#xrcopilot-chatbot-container input:hover,
#xrcopilot-chatbot-container textarea,
#xrcopilot-chatbot-container textarea:focus,
#xrcopilot-chatbot-container textarea:focus-visible,
#xrcopilot-chatbot-container textarea:focus-within,
#xrcopilot-chatbot-container textarea:active,
#xrcopilot-chatbot-container textarea:hover {
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-focus-ring-color: transparent !important;
    -moz-outline: none !important;
    -moz-outline-width: 0 !important;
    -moz-outline-style: none !important;
    -moz-outline-color: transparent !important;
}

/* Regole specifiche per i pulsanti di controllo - RIMUOVI TUTTI I BORDI (ROSSI, VERDI, ECC.) */
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:focus-visible,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:focus-within,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:hover,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:hover:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-control-btn:hover:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:focus-visible,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:focus-within,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:hover,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:hover:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-header-btn:hover:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:focus-visible,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:focus-within,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:hover,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:hover:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-attach:hover:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:focus-visible,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:focus-within,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:active,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:hover,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:hover:focus,
#xrcopilot-chatbot-container .xrcopilot-chatbot-voice-input:hover:active {
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-top-style: none !important;
    border-right-style: none !important;
    border-bottom-style: none !important;
    border-left-style: none !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
    /* Rimuovi anche eventuali bordi aggiunti da estensioni o strumenti di sviluppo */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

:root {
    --xrcopilot-primary: var(--primary-color, #ff6b35);
    --xrcopilot-primary-dark: var(--primary-color-dark, #e55a2b);
    --xrcopilot-primary-light: #ff8c5a;
    --xrcopilot-bg: #ffffff;
    --xrcopilot-text: #1f2937;
    --xrcopilot-text-light: #6b7280;
    --xrcopilot-border: #e5e7eb;
    --xrcopilot-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --xrcopilot-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --xrcopilot-hover: #f3f4f6;
    --xrcopilot-header-bg: var(--header-color, var(--primary-color, #ff6b35));
}

/* Container principale - Isolamento per prevenire interferenze */
#xrcopilot-chatbot-container {
    position: fixed;
    -webkit-position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    isolation: isolate;
    /* Rimuoviamo contain per permettere al toggle di espandersi */
    contain: none;
    /* Fix per Safari iOS - assicura che position fixed funzioni correttamente */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-perspective: 1000;
    perspective: 1000;
    /* Fix per viewport su mobile */
    -webkit-overflow-scrolling: touch;
    /* Permetti al toggle di espandersi durante l'hover */
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
}

/* Assicura che il container sia posizionato correttamente */
.xrcopilot-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
    padding: 10px !important; /* Spazio per permettere al toggle di espandersi */
    min-width: 68px !important; /* 48px + 20px di padding per hover */
    min-height: 68px !important;
}

.xrcopilot-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
    padding: 10px !important; /* Spazio per permettere al toggle di espandersi */
    min-width: 68px !important; /* 48px + 20px di padding per hover */
    min-height: 68px !important;
}

/* Previeni interferenze con estensioni del browser */
#xrcopilot-chatbot-container * {
    box-sizing: border-box;
}

#xrcopilot-chatbot-container input,
#xrcopilot-chatbot-container textarea,
#xrcopilot-chatbot-container button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Posizionamento - già definito sopra nel container */

/* Pulsante toggle */
.xrcopilot-chatbot-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--toggle-color, var(--header-color, var(--primary-color, #ff6b35))) 0%, var(--toggle-color-dark, var(--header-color-dark, var(--primary-color-dark, #e55a2b))) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    overflow: visible !important;
    z-index: 1000000 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

.xrcopilot-chatbot-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
    overflow: visible !important;
    /* Assicura che durante l'hover non venga tagliato */
    position: relative !important;
    z-index: 1000001 !important;
}

.xrcopilot-chatbot-toggle:focus,
.xrcopilot-chatbot-toggle:focus-visible,
.xrcopilot-chatbot-toggle:active {
    outline: none !important;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3) !important;
}

.xrcopilot-chatbot-toggle.active {
    background: var(--toggle-color-dark, var(--header-color-dark, var(--primary-color-dark, #e55a2b)));
}

.xrcopilot-chatbot-toggle svg {
    width: 22px;
    height: 22px;
}

/* Finestra chat - usa absolute relativo al container */
.xrcopilot-chatbot-window {
    position: absolute !important;
    bottom: 80px !important;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-width: -webkit-calc(100vw - 40px);
    max-width: -moz-calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    max-height: -webkit-calc(100vh - 120px);
    max-height: -moz-calc(100vh - 120px);
    background: var(--xrcopilot-bg);
    background-color: #ffffff;
    border-radius: 24px;
    -webkit-border-radius: 24px;
    -moz-border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    -webkit-box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    -moz-box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    border: none;
    display: none; /* Inizialmente nascosta, verrà mostrata via JS */
    display: -webkit-flex;
    display: -moz-flex;
    display: flex;
    -webkit-flex-direction: column;
    -moz-flex-direction: column;
    flex-direction: column;
    overflow: hidden;
    /* Permetti ai figli flex di scrollare correttamente su mobile */
    min-height: 0;
    z-index: 999999 !important;
    opacity: 1;
    -webkit-opacity: 1;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -moz-transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), -moz-transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Assicura che top non sia impostato */
    top: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Fix per Safari iOS - assicura che position fixed funzioni correttamente */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-perspective: 1000;
    perspective: 1000;
    /* Fix per viewport su mobile */
    -webkit-overflow-scrolling: touch;
}

.xrcopilot-chatbot-bottom-left .xrcopilot-chatbot-window {
    left: 0 !important;
    right: auto !important;
}

.xrcopilot-chatbot-bottom-right .xrcopilot-chatbot-window {
    right: 0 !important;
    left: auto !important;
}

/* Header */
.xrcopilot-chatbot-header {
    background: linear-gradient(135deg, var(--header-color, var(--primary-color, #ff6b35)) 0%, var(--header-color-dark, var(--primary-color-dark, #e55a2b)) 100%) !important;
    background-color: var(--header-color, var(--primary-color, #ff6b35)) !important;
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Barra controlli sotto l'header */
.xrcopilot-chatbot-controls-bar {
    background: #fafafa;
    padding: 12px 16px;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
    position: relative;
}

/* Assicura che ogni pulsante sia separato */
.xrcopilot-chatbot-controls-bar > * {
    margin: 0 !important;
    flex-shrink: 0 !important;
    display: flex !important;
}

.xrcopilot-chatbot-controls-bar::-webkit-scrollbar {
    display: none;
}

.xrcopilot-chatbot-controls-bar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.xrcopilot-chatbot-control-btn {
    background: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-top-style: none !important;
    border-right-style: none !important;
    border-bottom-style: none !important;
    border-left-style: none !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
    color: #111827 !important;
    cursor: pointer;
    padding: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 8px !important;
    min-width: 32px !important;
    width: auto !important;
    height: 32px !important;
    flex-shrink: 0;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    font-size: 14px !important;
    font-weight: inherit !important;
    text-align: center !important;
    white-space: nowrap !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    margin: 0 !important;
    line-height: 1 !important;
    position: relative !important;
}

.xrcopilot-chatbot-control-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #111827;
    transform: translateY(-1px);
}

.xrcopilot-chatbot-control-btn svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    vertical-align: middle !important;
}

.xrcopilot-chatbot-control-btn img {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    vertical-align: middle !important;
}

/* Rimuovi contorni/ring predefiniti sui focus */
.xrcopilot-chatbot-window button:focus,
.xrcopilot-chatbot-window button:focus-visible,
.xrcopilot-chatbot-window input:focus,
.xrcopilot-chatbot-window textarea:focus,
.xrcopilot-chatbot-window input:focus-visible,
.xrcopilot-chatbot-window textarea:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border-color: inherit;
}
.xrcopilot-chatbot-control-btn:focus,
.xrcopilot-chatbot-control-btn:focus-visible,
.xrcopilot-chatbot-control-btn:focus-within,
.xrcopilot-chatbot-control-btn:active,
.xrcopilot-chatbot-attach:focus,
.xrcopilot-chatbot-attach:focus-visible,
.xrcopilot-chatbot-attach:focus-within,
.xrcopilot-chatbot-attach:active,
.xrcopilot-chatbot-voice-input:focus,
.xrcopilot-chatbot-voice-input:focus-visible,
.xrcopilot-chatbot-voice-input:focus-within,
.xrcopilot-chatbot-voice-input:active {
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    border: none !important;
}

/* Icone */
.xrcopilot-icon-img {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    object-fit: contain !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    vertical-align: middle !important;
}

/* Assicura che solo un'icona audio sia visibile alla volta */
.xrcopilot-chatbot-audio-toggle {
    position: relative !important;
}

.xrcopilot-chatbot-audio-toggle .audio-icon {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    z-index: 1 !important;
}

.xrcopilot-chatbot-audio-toggle .audio-icon[style*="display: none"],
.xrcopilot-chatbot-audio-toggle .audio-icon[style*="display:none"] {
    display: none !important;
    z-index: 0 !important;
}

/* Le icone normali (non audio) usano flexbox normale e non si sovrappongono */
.xrcopilot-chatbot-control-btn .xrcopilot-icon-img:not(.audio-icon) {
    position: static !important;
    transform: none !important;
    margin: 0 !important;
    display: block !important;
    flex-shrink: 0 !important;
}

.xrcopilot-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    overflow: visible;
}

.xrcopilot-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.xrcopilot-chatbot-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: white;
    letter-spacing: -0.01em;
}

.xrcopilot-chatbot-header-btn {
    background: transparent;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    color: white;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    min-width: 28px;
    height: 28px;
    flex-shrink: 0;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
}

.xrcopilot-chatbot-header-btn:focus,
.xrcopilot-chatbot-header-btn:focus-visible,
.xrcopilot-chatbot-header-btn:focus-within,
.xrcopilot-chatbot-header-btn:active,
.xrcopilot-chatbot-header-btn:hover {
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
}

.xrcopilot-chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.xrcopilot-chatbot-header-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.xrcopilot-chatbot-language-selector {
    position: relative;
    display: flex !important;
    flex-shrink: 0 !important;
}

.xrcopilot-language-label {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    margin: 0 4px 0 0 !important;
    display: inline-block !important;
}

.xrcopilot-chatbot-controls-bar .xrcopilot-language-label {
    color: #6b7280;
}

.xrcopilot-chatbot-language-selector .dropdown-arrow {
    width: 10px;
    height: 10px;
    margin-left: 2px;
    flex-shrink: 0;
    display: block !important;
}

/* Il pulsante language selector può essere più largo */
.xrcopilot-chatbot-language-selector .xrcopilot-chatbot-control-btn {
    width: auto !important;
    min-width: 32px !important;
    padding: 6px 8px !important;
}

.xrcopilot-chatbot-audio-toggle.active {
    color: #374151;
    background: rgba(255, 107, 53, 0.1);
}

/* Regole duplicate rimosse - già definite sopra */

/* Area messaggi */
.xrcopilot-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
    /* Fix scroll su mobile/iOS */
    min-height: 0;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.xrcopilot-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.xrcopilot-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.xrcopilot-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--xrcopilot-border);
    border-radius: 3px;
}

.xrcopilot-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Messaggi */
.xrcopilot-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xrcopilot-message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}

.xrcopilot-message-error {
    align-self: center;
    max-width: 90%;
    margin: 8px auto;
}

.xrcopilot-message-error .xrcopilot-message-content {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.xrcopilot-message.bot-message {
    align-self: flex-start;
}

.xrcopilot-message-bot-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 8px;
}

.xrcopilot-message-bot-icon svg {
    width: 24px;
    height: 24px;
}

.xrcopilot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--avatar-color, var(--primary-color, #ff6b35)) !important;
    background-color: var(--avatar-color, var(--primary-color, #ff6b35)) !important;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.xrcopilot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.xrcopilot-message-avatar svg {
    width: 18px;
    height: 18px;
}

.xrcopilot-message-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    border: none;
}

.user-message .xrcopilot-message-content {
    background: linear-gradient(135deg, var(--xrcopilot-header-bg) 0%, var(--xrcopilot-primary-dark) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    margin-left: auto;
}

.error-message .xrcopilot-message-content {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.xrcopilot-message-content p {
    margin: 0 0 8px 0;
}

.xrcopilot-message-content p:last-child {
    margin-bottom: 0;
}

.xrcopilot-message-content h1,
.xrcopilot-message-content h2,
.xrcopilot-message-content h3,
.xrcopilot-message-content h4,
.xrcopilot-message-content h5,
.xrcopilot-message-content h6 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    margin: 4px 0;
}

.xrcopilot-message-time {
    font-size: 14px;
    color: var(--xrcopilot-text-light);
    margin-top: 4px;
    align-self: flex-end;
}

.user-message .xrcopilot-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Immagini */
.xrcopilot-message-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 8px;
}

.xrcopilot-image-caption {
    margin-top: 8px;
    font-size: 14px;
    color: var(--xrcopilot-text-light);
}

/* Documenti */
.xrcopilot-document-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--xrcopilot-primary);
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid var(--xrcopilot-border);
    border-radius: 6px;
    transition: all 0.2s;
}

.xrcopilot-document-link:hover {
    background: #f5f5f5;
    border-color: var(--xrcopilot-primary);
}

/* Indicatore di digitazione */
.typing-indicator .xrcopilot-message-content {
    padding: 12px 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--xrcopilot-text-light);
    animation: typingDot 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input container */
.xrcopilot-chatbot-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.xrcopilot-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    width: 100%;
}

.xrcopilot-chatbot-attach {
    position: absolute;
    left: 12px;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 5;
    background: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-top-style: none !important;
    border-right-style: none !important;
    border-bottom-style: none !important;
    border-left-style: none !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
    color: #111827 !important;
    cursor: pointer;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    z-index: 10;
    pointer-events: auto;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    font-size: 14px !important;
    font-weight: inherit !important;
    text-align: center !important;
    white-space: nowrap !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
}

.xrcopilot-chatbot-voice-input {
    position: absolute;
    right: 12px;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    border-top: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-top-width: 0 !important;
    border-right-width: 0 !important;
    border-bottom-width: 0 !important;
    border-left-width: 0 !important;
    border-top-style: none !important;
    border-right-style: none !important;
    border-bottom-style: none !important;
    border-left-style: none !important;
    border-top-color: transparent !important;
    border-right-color: transparent !important;
    border-bottom-color: transparent !important;
    border-left-color: transparent !important;
    color: #111827 !important;
    cursor: pointer;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 20px !important;
    height: 20px !important;
    z-index: 10;
    pointer-events: auto;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    font-size: 14px !important;
    font-weight: inherit !important;
    text-align: center !important;
    white-space: nowrap !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    margin: 0 !important;
    border-radius: 0;
    transition: all 0.2s ease;
}

.xrcopilot-chatbot-attach:hover {
    opacity: 0.7;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

.xrcopilot-chatbot-attach:focus,
.xrcopilot-chatbot-attach:focus-visible,
.xrcopilot-chatbot-attach:focus-within,
.xrcopilot-chatbot-attach:active {
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    outline: none !important;
    outline-width: 0 !important;
    outline-style: none !important;
    outline-color: transparent !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
}

.xrcopilot-chatbot-voice-input:hover {
    opacity: 0.7;
    transform: none;
}

.xrcopilot-chatbot-voice-input.recording {
    color: #ef4444 !important;
    animation: pulse-recording 1.5s ease-in-out infinite;
    background: rgba(239, 68, 68, 0.1) !important;
    border-radius: 50% !important;
}

@keyframes pulse-recording {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Indicatore registrazione nella chat */
.recording-indicator {
    animation: slideInRecording 0.3s ease-out;
}

.recording-indicator .xrcopilot-message-content {
    background: #fef3c7 !important;
    border-left: 3px solid #f59e0b;
}

@keyframes slideInRecording {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xrcopilot-chatbot-attach svg {
    width: 20px;
    height: 20px;
}

.xrcopilot-chatbot-voice-input svg {
    width: 18px;
    height: 18px;
}

.xrcopilot-chatbot-voice-input .voice-icon,
.xrcopilot-chatbot-voice-input .send-icon {
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: none !important;
    flex-shrink: 0 !important;
}

.xrcopilot-chatbot-voice-input .voice-icon.show,
.xrcopilot-chatbot-voice-input .send-icon.show {
    display: block !important;
}

.xrcopilot-chatbot-voice-input .send-icon {
    color: var(--primary-color, #ff6b35);
}

.xrcopilot-chatbot-input {
    flex: 1;
    border: 1px solid #dce6ff;
    border-radius: 24px;
    padding: 14px 40px 14px 40px;
}

/* Se il pulsante attach non è presente, riduci il padding sinistro */
.xrcopilot-input-wrapper:not(:has(.xrcopilot-chatbot-attach)) .xrcopilot-chatbot-input {
    padding-left: 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: all 0.2s ease;
    background: white;
    color: var(--xrcopilot-text);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
    background-clip: padding-box;
    border-image: none;
    /* Nascondi scrollbar */
    overflow: hidden !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    /* Previeni interferenze con estensioni */
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
    width: 100%;
}

/* Nascondi scrollbar webkit per textarea */
.xrcopilot-chatbot-input::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

.xrcopilot-chatbot-input:focus {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    outline: none;
}

.xrcopilot-chatbot-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.xrcopilot-chatbot-send {
    display: none; /* Nascosto perché usiamo il microfono */
}

/* Pannello cronologia */
.xrcopilot-history-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 10;
    display: none;
    flex-direction: column;
    border-radius: 16px;
    min-height: 0;
    overflow: hidden;
}

.xrcopilot-history-header {
    padding: 16px;
    border-bottom: 1px solid var(--xrcopilot-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.xrcopilot-history-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--xrcopilot-text);
}

.xrcopilot-history-close {
    background: transparent;
    border: none;
    color: var(--xrcopilot-text-light);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.xrcopilot-history-close:hover {
    background: var(--xrcopilot-hover);
    color: var(--xrcopilot-text);
}

.xrcopilot-history-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 0;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.xrcopilot-history-loading {
    text-align: center;
    color: var(--xrcopilot-text-light);
    padding: 32px 20px;
    font-size: 14px;
}

.xrcopilot-history-empty {
    text-align: center;
    color: var(--xrcopilot-text-light);
    padding: 40px 20px;
    margin: 0;
}

.xrcopilot-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.xrcopilot-history-message {
    border: 1px solid var(--xrcopilot-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.xrcopilot-history-message.xrcopilot-history-user {
    background: var(--xrcopilot-hover);
    border-color: transparent;
}

.xrcopilot-history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--xrcopilot-text-light);
    margin-bottom: 6px;
}

.xrcopilot-history-sender {
    font-weight: 600;
    color: var(--xrcopilot-text);
}

.xrcopilot-history-text {
    font-size: 14px;
    color: var(--xrcopilot-text);
    line-height: 1.4;
    word-break: break-word;
}

/* Dropdown lingua */
.xrcopilot-chatbot-language-selector {
    position: relative;
}

.xrcopilot-language-dropdown {
    position: fixed;
    background: white;
    border: 1px solid var(--xrcopilot-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000000 !important;
    min-width: 160px;
    display: none;
    overflow: hidden;
}

.xrcopilot-lang-option {
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--xrcopilot-text);
    font-size: 14px;
}

.xrcopilot-lang-option:hover {
    background: var(--xrcopilot-hover);
}

.xrcopilot-lang-option.selected {
    background: rgba(255, 107, 53, 0.1);
    color: var(--xrcopilot-header-bg);
    font-weight: 500;
}

/* Shortcode button */
.xrcopilot-chatbot-shortcode-btn {
    background: var(--xrcopilot-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.xrcopilot-chatbot-shortcode-btn:hover {
    background: var(--xrcopilot-primary-dark);
}

/* Indicatore speech */
.xrcopilot-speech-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #e3f2fd;
    border-left: 3px solid var(--xrcopilot-primary);
    border-radius: 8px;
    margin: 8px 0;
    animation: speechIndicatorPulse 2s ease-in-out infinite;
}

@keyframes speechIndicatorPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.xrcopilot-speech-indicator-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.xrcopilot-speech-indicator-icon {
    font-size: 14px;
    animation: speechIconBounce 1s ease-in-out infinite;
}

@keyframes speechIconBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.xrcopilot-speech-indicator-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.xrcopilot-speech-indicator-text strong {
    font-size: 14px;
    color: var(--xrcopilot-primary);
    font-weight: 600;
}

.xrcopilot-speech-indicator-text small {
    font-size: 14px;
    color: var(--xrcopilot-text-light);
}

/* Responsive - Mobile e Tablet */
@media (max-width: 768px) {
    .xrcopilot-chatbot-window {
        width: calc(100vw - 20px) !important;
        width: -webkit-calc(100vw - 20px) !important;
        width: -moz-calc(100vw - 20px) !important;
        height: calc(100vh - 100px) !important;
        height: -webkit-calc(100vh - 100px) !important;
        height: -moz-calc(100vh - 100px) !important;
        max-width: calc(100vw - 20px) !important;
        max-width: -webkit-calc(100vw - 20px) !important;
        max-width: -moz-calc(100vw - 20px) !important;
        max-height: calc(100vh - 100px) !important;
        max-height: -webkit-calc(100vh - 100px) !important;
        max-height: -moz-calc(100vh - 100px) !important;
        bottom: 80px !important;
        left: 10px !important;
        right: 10px !important;
        position: fixed !important;
        -webkit-position: fixed !important;
    }
    
    .xrcopilot-message {
        max-width: 85%;
    }
    
    .xrcopilot-chatbot-container {
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
    }
}

/* Usa dvh quando disponibile per evitare problemi di barra indirizzi mobile */
@supports (height: 100dvh) {
    @media (max-width: 768px) {
        .xrcopilot-chatbot-window {
            height: calc(100dvh - 100px) !important;
            max-height: calc(100dvh - 100px) !important;
        }
    }
}

/* Fix specifici per Safari iOS */
@supports (-webkit-touch-callout: none) {
    .xrcopilot-chatbot-window {
        position: fixed !important;
        -webkit-position: fixed !important;
        -webkit-transform: none !important;
        transform: none !important;
    }
    
    #xrcopilot-chatbot-container {
        position: fixed !important;
        -webkit-position: fixed !important;
        -webkit-transform: none !important;
        transform: none !important;
    }

    .xrcopilot-chatbot-messages {
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
}

/* Fix per Firefox */
@-moz-document url-prefix() {
    .xrcopilot-chatbot-window {
        position: fixed !important;
    }
}


/* === FIX: Nuvolette bot larghe quanto la chat === */
.xrcopilot-message.bot-message {
    max-width: 100% !important;
    width: 100% !important;
    align-self: stretch !important;
}

/* Il contenuto del bot occupa tutto lo spazio disponibile dopo avatar e timestamp */
.bot-message .xrcopilot-message-content {
    flex: 1 1 0% !important;
    width: 0 !important;          /* trick flex: forza espansione corretta */
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Rimuovi il max-width solo per i messaggi bot */
.xrcopilot-message.bot-message > .xrcopilot-message-content {
    max-width: none !important;
}