/* Scudo anti-Kit (Elementor & simili): azzera gli stili globali del tema sui controlli del widget.
   :where() = specificità zero: ogni regola nostra successiva (tutte !important) ri-vince per ordine. */
.bwf-chat :where(button,input,textarea,select){text-transform:none !important;letter-spacing:normal !important;min-width:0 !important;width:auto !important;margin:0 !important;padding:0 !important;background:transparent !important;border:0 !important;border-radius:0 !important;box-shadow:none !important;color:inherit !important;font:inherit !important}
/**
 * BWF LiveChat Widget — Styles
 * Design moderno tipo WhatsApp/Intercom. Dark mode auto.
 */

:root {
    --bwf-accent: #4f46e5;
    --bwf-accent-hover: #4338ca;
    /* Gradiente brand: identico all'icona dell'app (indigo→violet) */
    --bwf-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #7c3aed 100%);
    --bwf-bubble-size: 56px;
    --bwf-window-w: 380px;
    --bwf-window-h: 560px;
    --bwf-radius: 16px;
    --bwf-radius-sm: 10px;
    --bwf-radius-msg: 18px;
    --bwf-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    --bwf-shadow-bubble: 0 4px 20px rgba(0, 0, 0, 0.15);
    --bwf-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --bwf-bg: #ffffff;
    --bwf-bg-secondary: #f7f7f8;
    --bwf-text: #1a1a2e;
    --bwf-text-muted: #6b7280;
    --bwf-border: #e5e7eb;
    --bwf-msg-visitor-bg: var(--bwf-accent);
    --bwf-msg-visitor-text: #ffffff;
    --bwf-msg-ai-bg: #f0f0f5;
    --bwf-msg-ai-text: #1a1a2e;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bwf-bg: #1e1e2e;
        --bwf-bg-secondary: #2a2a3d;
        --bwf-text: #e4e4e8;
        --bwf-text-muted: #9ca3af;
        --bwf-border: #3f3f5a;
        --bwf-msg-ai-bg: #2a2a3d;
        --bwf-msg-ai-text: #e4e4e8;
        --bwf-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    }
}

/* ━━━ CONTAINER ━━━ */
.bwf-chat {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: var(--bwf-font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.bwf-chat--right {
    right: 20px;
}

.bwf-chat--left {
    left: 20px;
}

/* ━━━ BUBBLE ━━━ */
.bwf-chat__bubble {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: var(--bwf-gradient) !important;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4), 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none !important;
    outline: none !important;
    position: relative;
    animation: bwf-bounce-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

.bwf-chat__bubble svg {
    width: 28px !important;
    height: 28px !important;
}

.bwf-chat__bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(79, 70, 229, 0.5), 0 2px 12px rgba(0, 0, 0, 0.15) !important;
}

.bwf-chat__bubble:active {
    transform: scale(0.92);
}

/* Pulse ring */
.bwf-chat__bubble::before {
    content: '';
    position: absolute;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    background: var(--bwf-accent) !important;
    opacity: 0;
    animation: bwf-pulse 2.5s ease-out infinite 2s;
    z-index: -1;
}

/* Greeting tooltip */
.bwf-chat__greeting {
    position: absolute;
    bottom: 8px;
    right: 76px;
    background: var(--bwf-bg);
    color: var(--bwf-text);
    padding: 10px 16px;
    border-radius: 12px 12px 4px 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateX(10px) scale(0.95);
    animation: bwf-greeting-in 0.4s ease-out 4s forwards;
    pointer-events: none;
    max-width: 260px;
}

.bwf-chat--left .bwf-chat__greeting {
    right: auto;
    left: 76px;
    border-radius: 12px 12px 12px 4px;
    transform: translateX(-10px) scale(0.95);
}

.bwf-chat__greeting-close {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bwf-text-muted);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    line-height: 1;
}

.bwf-chat__greeting.bwf-hidden {
    display: none;
}

/* Animations */
@keyframes bwf-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

@keyframes bwf-bounce-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.15);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bwf-greeting-in {
    0% {
        opacity: 0;
        transform: translateX(10px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.bwf-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: bwf-badge-bounce 2s infinite;
}

@keyframes bwf-badge-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ━━━ WINDOW ━━━ */
.bwf-chat__window {
    width: var(--bwf-window-w);
    height: var(--bwf-window-h);
    max-height: calc(100vh - 100px);
    background: var(--bwf-bg);
    border-radius: var(--bwf-radius);
    box-shadow: var(--bwf-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--bwf-border);
    animation: bwf-slide-up 0.25s ease;
}

@keyframes bwf-slide-up {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ━━━ HEADER ━━━ */
.bwf-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bwf-gradient);
    color: #ffffff;
    flex-shrink: 0;
}

.bwf-chat__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bwf-chat__header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.bwf-chat__header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.bwf-chat__header-subtitle {
    font-size: 12px;
    opacity: 0.85;
}

.bwf-chat__close {
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer;
    padding: 4px !important;
    border-radius: 6px !important;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.bwf-chat__close:hover {
    opacity: 1;
}

/* ━━━ MESSAGES ━━━ */
.bwf-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bwf-bg-secondary);
    scroll-behavior: smooth;
}

.bwf-chat__messages::-webkit-scrollbar {
    width: 4px;
}

.bwf-chat__messages::-webkit-scrollbar-track {
    background: transparent;
}

.bwf-chat__messages::-webkit-scrollbar-thumb {
    background: var(--bwf-border);
    border-radius: 4px;
}

.bwf-chat__welcome {
    text-align: center;
    padding: 20px 10px;
    color: var(--bwf-text-muted);
    font-size: 13px;
}

/* ━━━ MESSAGE BUBBLES ━━━ */
.bwf-chat__msg {
    display: flex;
    max-width: 85%;
}

.bwf-chat__msg--visitor {
    align-self: flex-end;
}

.bwf-chat__msg--ai {
    align-self: flex-start;
}

.bwf-chat__msg--system {
    align-self: center;
    max-width: 100%;
}

.bwf-chat__msg-bubble {
    padding: 10px 14px;
    border-radius: var(--bwf-radius-msg);
    word-break: break-word;
}

.bwf-chat__msg--visitor .bwf-chat__msg-bubble {
    background: var(--bwf-msg-visitor-bg);
    color: var(--bwf-msg-visitor-text);
    border-bottom-right-radius: 4px;
}

.bwf-chat__msg--ai .bwf-chat__msg-bubble {
    background: var(--bwf-msg-ai-bg);
    color: var(--bwf-msg-ai-text);
    border-bottom-left-radius: 4px;
}

.bwf-chat__msg-text {
    font-size: 14px;
    line-height: 1.5;
}

.bwf-chat__msg-text a {
    color: inherit;
    text-decoration: underline;
}

.bwf-chat__msg-time {
    font-size: 10px;
    opacity: 0.6;
    text-align: right;
    margin-top: 4px;
}

.bwf-chat__msg-system {
    font-size: 12px;
    color: var(--bwf-text-muted);
    background: var(--bwf-bg);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--bwf-border);
}

/* ━━━ TYPING INDICATOR ━━━ */
.bwf-chat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    background: var(--bwf-bg-secondary);
}

.bwf-chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bwf-text-muted);
    animation: bwf-typing 1.2s infinite;
}

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

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

@keyframes bwf-typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ━━━ INPUT ━━━ */
.bwf-chat__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px !important;
    background: var(--bwf-bg) !important;
    border-top: 1px solid var(--bwf-border) !important;
    flex-shrink: 0;
}

.bwf-chat__input {
    flex: 1;
    border: 1px solid var(--bwf-border) !important;
    border-radius: var(--bwf-radius-sm) !important;
    padding: 10px 14px !important;
    font-family: var(--bwf-font) !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: var(--bwf-text) !important;
    background: var(--bwf-bg-secondary) !important;
    resize: none;
    outline: none !important;
    min-height: 40px !important;
    max-height: 120px;
    transition: border-color 0.15s;
}

.bwf-chat__input:focus {
    border-color: var(--bwf-accent) !important;
}

.bwf-chat__input::placeholder {
    color: var(--bwf-text-muted) !important;
}

.bwf-chat__send {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: var(--bwf-gradient) !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: filter 0.15s, transform 0.1s, opacity 0.15s;
}

.bwf-chat__send:hover:not(:disabled) {
    filter: brightness(1.08);
}

.bwf-chat__send:active:not(:disabled) {
    transform: scale(0.92);
}

.bwf-chat__send:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ━━━ POWERED BY ━━━ */
.bwf-chat__powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--bwf-text-muted);
    background: var(--bwf-bg);
}

.bwf-chat__powered a {
    color: var(--bwf-accent);
    text-decoration: none;
    font-weight: 600;
}

/* ━━━ MOBILE ━━━ */
@media (max-width: 480px) {
    .bwf-chat__window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }

    .bwf-chat {
        bottom: 16px;
    }

    .bwf-chat--right {
        right: 16px;
    }

    .bwf-chat--left {
        left: 16px;
    }
}

/* ━━━ PRE-CHAT FORM ━━━ */
.bwf-chat__prechat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px 24px;
    flex: 1;
    overflow-y: auto;
    background: var(--bwf-bg);
}

.bwf-prechat__icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bwf-accent), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    opacity: 0.9;
}

.bwf-prechat__icon svg {
    stroke: #fff;
}

.bwf-prechat__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--bwf-text);
    margin: 0 0 6px;
    text-align: center;
}

.bwf-prechat__subtitle {
    font-size: 13px;
    color: var(--bwf-text-muted);
    margin: 0 0 24px;
    text-align: center;
    line-height: 1.5;
}

.bwf-prechat__form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bwf-prechat__field {
    width: 100%;
}

.bwf-prechat__input {
    width: 100% !important;
    padding: 12px 14px !important;
    border: 1px solid var(--bwf-border) !important;
    border-radius: var(--bwf-radius-sm) !important;
    font-family: var(--bwf-font) !important;
    font-size: 14px !important;
    color: var(--bwf-text) !important;
    background: var(--bwf-bg-secondary) !important;
    outline: none !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.bwf-prechat__input:focus {
    border-color: var(--bwf-accent) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

.bwf-prechat__input::placeholder {
    color: var(--bwf-text-muted) !important;
}

.bwf-prechat__input--error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
    animation: bwf-shake 0.4s ease;
}

@keyframes bwf-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.bwf-prechat__submit {
    width: 100%;
    padding: 13px 20px;
    margin-top: 6px;
    background: var(--bwf-accent);
    color: #fff;
    border: none;
    border-radius: var(--bwf-radius-sm);
    font-family: var(--bwf-font);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, transform 0.1s;
}

.bwf-prechat__submit:hover:not(:disabled) {
    background: var(--bwf-accent-hover);
}

.bwf-prechat__submit:active:not(:disabled) {
    transform: scale(0.98);
}

.bwf-prechat__submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.bwf-prechat__privacy {
    text-align: center;
    font-size: 11px;
    color: var(--bwf-text-muted);
    margin: 12px 0 0;
    line-height: 1.5;
}

.bwf-prechat__privacy a {
    color: var(--bwf-accent);
    text-decoration: none;
}
/* ━━━ Card prodotto in chat (BWF 2.10) ━━━ */
.bwf-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.bwf-card {
    display: flex; gap: 10px; align-items: center;
    background: #ffffff; border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px; padding: 8px; max-width: 100%;
}
.bwf-card__img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: 0 0 56px; }
.bwf-card__body { flex: 1; min-width: 0; }
.bwf-card__name { font-size: 13px; font-weight: 700; color: #1a1a2e; line-height: 1.25; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bwf-card__price { font-size: 13px; font-weight: 800; color: var(--bwf-accent); margin-bottom: 6px; }
.bwf-card__btn {
    display: inline-block; appearance: none; border: 0; cursor: pointer;
    background: var(--bwf-accent); color: #fff; text-decoration: none;
    font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: 999px;
}
.bwf-card__btn:disabled { opacity: .6; cursor: wait; }
.bwf-card__btn--link { background: transparent; color: var(--bwf-accent); border: 1px solid var(--bwf-accent); }
.bwf-card__btn--ok { background: #10b981; }
@media (prefers-color-scheme: dark) {
    .bwf-card { background: #2a2a3d; border-color: rgba(255,255,255,.08); }
    .bwf-card__name { color: #e4e4e8; }
}

/* ━━━ Chat multimediale (BWF 2.11): allegati, vocali, trascrizioni ━━━ */
.bwf-chat__tool {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    color: #9ca3af; padding: 8px 6px; border-radius: 8px; flex: 0 0 auto;
    display: inline-flex; align-items: center;
}
.bwf-chat__tool:hover { color: var(--bwf-accent); background: rgba(0,0,0,.04); }
.bwf-chat__tool:disabled { opacity: .5; cursor: wait; }
.bwf-chat__rec {
    display: flex; align-items: center; gap: 8px; flex: 1;
    padding: 6px 8px; border-radius: 10px; background: rgba(239,68,68,.08);
    font-size: 13px; font-weight: 700; color: #ef4444;
}
.bwf-chat__rec[hidden] { display: none; }
.bwf-chat__rec-dot {
    width: 10px; height: 10px; border-radius: 50%; background: #ef4444;
    animation: bwfPulse 1s infinite;
}
@keyframes bwfPulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.bwf-chat__rec-btn {
    appearance: none; border: 0; cursor: pointer; border-radius: 999px;
    font-size: 12px; font-weight: 700; padding: 6px 12px;
    background: transparent; color: #6b7280;
}
.bwf-chat__rec-btn--send { background: var(--bwf-accent); color: #fff; margin-left: auto; }
.bwf-msg-img {
    max-width: 200px; max-height: 220px; border-radius: 12px; display: block;
    margin-bottom: 6px; object-fit: cover;
}
.bwf-msg-audio { width: 215px; height: 38px; margin-bottom: 4px; display: block; }
.bwf-msg-file {
    display: inline-block; font-size: 13px; font-weight: 600;
    color: var(--bwf-accent); text-decoration: none; padding: 6px 0;
}
.bwf-chat__transcript {
    font-size: 12px; font-style: italic; opacity: .75; margin-top: 4px; line-height: 1.4;
}

/* ━━━ Priming permesso microfono (BWF 2.11.2) ━━━ */
.bwf-mic-primer {
    margin: 8px 12px; padding: 12px 14px;
    background: rgba(79,70,229,.06); border: 1px solid rgba(79,70,229,.18);
    border-radius: 12px;
}
.bwf-mic-primer__txt { font-size: 13px; line-height: 1.45; color: #374151; margin-bottom: 8px; }
.bwf-mic-primer__row { display: flex; gap: 8px; justify-content: flex-end; }
.bwf-mic-primer__go, .bwf-mic-primer__cancel {
    appearance: none; border: 0; cursor: pointer; border-radius: 999px;
    font-size: 13px; font-weight: 700; padding: 8px 14px;
}
.bwf-mic-primer__go { background: var(--bwf-accent); color: #fff; }
.bwf-mic-primer__cancel { background: transparent; color: #6b7280; }
@media (prefers-color-scheme: dark) {
    .bwf-mic-primer { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.3); }
    .bwf-mic-primer__txt { color: #d1d5db; }
}

/* ━━━ bPay pay-by-chat ━━━ */
.bwf-pay { margin-top: 8px; border: 1px solid #1f4fe6; border-radius: 12px; overflow: hidden; }
.bwf-pay__head { background: rgba(31,79,230,0.08); padding: 10px 12px; font-size: 14px; color: #1f4fe6; }
.bwf-pay__desc { padding: 6px 12px; font-size: 12px; color: #5a6478; }
.bwf-pay__btn { display: block; background: #1f4fe6; color: #fff !important; text-align: center; padding: 11px; font-weight: 700; text-decoration: none; }
.bwf-pay__btn:hover { filter: brightness(1.08); }
.bwf-pay--paid { border-color: #12b886; }
.bwf-pay__badge { display: block; background: rgba(18,184,134,0.1); color: #0f9d74; padding: 10px 12px; font-weight: 700; font-size: 14px; }
