/*
 * IN.LEAP Chatbot — Widget Styles v1.2.7 — ECO21 theme
 * Brand: ECO21 Srl — Lato font, green palette teal-based + orange accent
 */

/* ── Design tokens ──────────────────────────────────────────────────────── */
#inleap-chat-root {
    /* Palette ECO21 */
    --eco-green:       #009B8F;   /* verde principale — primario */
    --eco-green-mid:   #008270;   /* verde medio — sfondi sezioni */
    --eco-green-dark:  #007065;   /* verde scuro — sfondi profondi, header */
    --eco-green-lime:  #AFCA0A;   /* verde lime — contrasto secondario */
    --eco-green-light: #51AE32;   /* verde chiaro — dettagli piccoli */
    --eco-orange:      #F39325;   /* arancione — CTA primario, evidenze */
    --eco-orange-dim:  rgba(243, 147, 37, 0.12);
    --eco-orange-hover:#d97f18;   /* arancione scurito hover */
    --eco-green-dim:   rgba(0, 155, 143, 0.10); /* sfondo bubble utente */
    --eco-green-glow:  rgba(0, 155, 143, 0.20);

    /* Neutri */
    --eco-bg:          #FFFFFF;
    --eco-bg-alt:      #F2F2F2;
    --eco-bg-bubble:   #F7FAF9;   /* bubble bot — bianco con tocco verde */
    --eco-border:      #DEE2E6;
    --eco-border-green:rgba(0, 155, 143, 0.25);
    --eco-text:        #575756;   /* grigio scuro testi normali */
    --eco-text-muted:  #888887;
    --eco-text-light:  #AAAAAA;

    /* Struttura */
    --r:               6px;
    --rl:              12px;
    --ease:            cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans:       'Lato', sans-serif;
    --font-display:    'Lato', sans-serif;
    --font-mono:       SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --chat-w:          380px;
    --chat-h:          570px;
    --launcher-size:   48px;
    --offset-right:    24px;
    --offset-bottom:   80px;  /* sopra banner Iubenda */
    --z:               9998;  /* sotto Iubenda che usa 9999 */
}

/* ── Reset isolato ──────────────────────────────────────────────────────── */
#inleap-chat-root *,
#inleap-chat-root *::before,
#inleap-chat-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#inleap-chat-root {
    position: fixed;
    right: var(--offset-right);
    bottom: var(--offset-bottom);
    z-index: var(--z);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--eco-text);
}

/* ── Launcher ───────────────────────────────────────────────────────────── */
.inleap-launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--launcher-size);
    height: var(--launcher-size);
    padding: 0;
    background: var(--eco-orange);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 4px 20px rgba(243, 147, 37, 0.40),
        0 2px 8px rgba(0, 0, 0, 0.15);
    transition:
        transform 0.2s var(--ease),
        box-shadow 0.2s var(--ease),
        background 0.2s var(--ease);
}
.inleap-launcher:hover {
    background: var(--eco-orange-hover);
    transform: translateY(-2px);
    box-shadow:
        0 6px 28px rgba(243, 147, 37, 0.50),
        0 3px 12px rgba(0, 0, 0, 0.15);
}
.inleap-launcher:focus-visible {
    outline: 2px solid var(--eco-orange);
    outline-offset: 3px;
}

.inleap-launcher__icon {
    flex-shrink: 0;
    transition: opacity 0.2s var(--ease), transform 0.25s var(--ease);
}
.inleap-launcher__icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}
.inleap-launcher[aria-expanded="true"] .inleap-launcher__icon--chat {
    opacity: 0;
    transform: rotate(90deg);
}
.inleap-launcher[aria-expanded="true"] .inleap-launcher__icon--close {
    opacity: 1;
    transform: rotate(0);
}

.inleap-launcher__label { display: none; }

/* Unread badge */
.inleap-launcher__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--eco-green);
    border: 2px solid #ffffff;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.2s;
}
.inleap-launcher__badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
.inleap-panel {
    position: absolute;
    bottom: calc(var(--launcher-size) + 12px);
    right: 0;
    width: var(--chat-w);
    max-height: var(--chat-h);
    display: flex;
    flex-direction: column;
    background: var(--eco-bg);
    border: 1px solid var(--eco-border);
    border-radius: var(--rl);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 155, 143, 0.08);
    overflow: hidden;
    transform-origin: bottom right;
    transition:
        opacity 0.22s var(--ease),
        transform 0.22s var(--ease);
    opacity: 0;
    transform: scale(0.94) translateY(10px);
    pointer-events: none;
}
.inleap-panel.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* ── Panel header ───────────────────────────────────────────────────────── */
.inleap-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px !important;
    flex-shrink: 0;
    background: var(--eco-green-dark);
    color: #ffffff;
}
.inleap-panel__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.inleap-panel__avatar {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Logo ECO21 nell'header — contenitore rettangolare senza sfondo */
.inleap-panel__logo {
    position: relative;
    width: 72px;
    height: 44px;
    min-width: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.inleap-panel__logo-svg {
    width: 72px;
    height: 44px;
    display: block;
}

.inleap-panel__pip {
    position: absolute;
    bottom: 2px;
    right: -3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--eco-green-lime);
    border: 2px solid var(--eco-green-dark);
    animation: inleap-pip 2.5s ease infinite;
    z-index: 1;
}
@keyframes inleap-pip {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(1.3); }
}
.inleap-panel__title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}
.inleap-panel__subtitle {
    font-family: var(--font-sans);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.02em;
    margin-top: 2px;
}
.inleap-panel__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.70);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--r);
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.inleap-panel__close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.12); }
.inleap-panel__close:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

/* ── Messages area ──────────────────────────────────────────────────────── */
.inleap-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--eco-border) transparent;
    background: var(--eco-bg);
}
.inleap-messages::-webkit-scrollbar { width: 4px; }
.inleap-messages::-webkit-scrollbar-track { background: transparent; }
.inleap-messages::-webkit-scrollbar-thumb { background: var(--eco-border); border-radius: 2px; }

.inleap-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: inleap-msg-in 0.2s var(--ease) both;
}
@keyframes inleap-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Bubble bot — sfondo verde tenue, bordo sinistro verde */
.inleap-msg--bot { align-self: flex-start; }
.inleap-msg--bot .inleap-msg__bubble {
    background: #F2F9F8 !important;
    border: 0.5px solid #b2d8d5 !important;
    border-left: 3px solid var(--eco-green) !important;
    color: var(--eco-text) !important;
    border-radius: 2px var(--rl) var(--rl) var(--rl) !important;
    padding: 10px 13px !important;
    font-size: 13px !important;
    line-height: 1.6 !important;
    word-break: break-word !important;
    white-space: pre-wrap !important;
}
.inleap-msg--bot .inleap-msg__bubble::before { display: none; }

/* Bubble utente — sfondo verde tenue, testo verde scuro */
.inleap-msg--user { align-self: flex-end; }
.inleap-msg--user .inleap-msg__bubble {
    background: var(--eco-green-dim) !important;
    border: 1px solid var(--eco-border-green) !important;
    color: var(--eco-green-dark) !important;
    border-radius: var(--rl) 2px var(--rl) var(--rl) !important;
    padding: 10px 16px !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    word-break: break-word !important;
    font-weight: 500;
}

.inleap-msg__time {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--eco-text-muted);
    letter-spacing: 0.04em;
    margin-top: 4px;
    padding: 0 4px;
}
.inleap-msg--user .inleap-msg__time { text-align: right; }

/* ── Typing indicator ───────────────────────────────────────────────────── */
.inleap-typing {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 0 16px 10px !important;
    flex-shrink: 0;
    background: var(--eco-bg);
}
.inleap-typing.visible { display: flex; }
.inleap-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--eco-green);
    animation: inleap-bounce 1.2s ease infinite;
}
.inleap-typing span:nth-child(2) { animation-delay: 0.15s; }
.inleap-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes inleap-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick replies ──────────────────────────────────────────────────────── */
.inleap-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 10px !important;
    flex-shrink: 0;
    background: var(--eco-bg);
}
.inleap-quick-replies:empty { display: none; }

/* Default: outline verde, pill arrotondato */
.inleap-qr {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px !important;
    background: var(--eco-bg);
    border: 1px solid var(--eco-green);
    border-radius: 50px;
    color: var(--eco-green-dark);
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.inleap-qr:hover {
    border-color: var(--eco-green-dark);
    color: var(--eco-green-dark);
    background: var(--eco-green-dim);
}
.inleap-qr:focus-visible { outline: 2px solid var(--eco-green); outline-offset: 2px; }

/* CTA principale — arancione pieno */
.inleap-qr--cta-call {
    background: var(--eco-orange);
    border-color: var(--eco-orange);
    color: #ffffff;
    font-weight: 700;
}
.inleap-qr--cta-call:hover {
    background: var(--eco-orange-hover);
    border-color: var(--eco-orange-hover);
    color: #ffffff;
}

/* CTA form — outline arancione */
.inleap-qr--cta-form {
    border-color: var(--eco-orange);
    color: var(--eco-orange);
    font-weight: 600;
}
.inleap-qr--cta-form:hover {
    background: var(--eco-orange-dim);
    color: var(--eco-orange-hover);
}

/* Calendar — verde principale evidenziato */
.inleap-qr--calendar {
    border: 1.5px solid var(--eco-green);
    color: var(--eco-green-dark);
    font-weight: 700;
    box-shadow: 0 0 6px var(--eco-green-glow);
}
.inleap-qr--calendar:hover {
    background: var(--eco-green-dim);
    border-color: var(--eco-green-dark);
    box-shadow: 0 0 10px var(--eco-green-glow);
}

/* ── Privacy notice ─────────────────────────────────────────────────────── */
.inleap-privacy {
    margin: 0 16px 10px !important;
    padding: 16px !important;
    background: var(--eco-bg-alt);
    border: 1px solid var(--eco-border);
    border-radius: var(--r);
    flex-shrink: 0;
}
.inleap-privacy p { font-size: 12px; color: var(--eco-text-muted); line-height: 1.55; margin-bottom: 10px; }
.inleap-privacy__title { font-weight: 700; color: var(--eco-text) !important; }
.inleap-privacy a { color: var(--eco-green); text-decoration: none; }
.inleap-privacy a:hover { color: var(--eco-green-dark); text-decoration: underline; }
.inleap-privacy__consent { font-size: 11px; color: var(--eco-text-muted); }
.inleap-privacy__actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.inleap-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 50px;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity 0.15s, transform 0.15s, background 0.15s;
}
.inleap-btn:focus-visible { outline: 2px solid var(--eco-green); outline-offset: 2px; }
/* Acconsento → arancione */
.inleap-btn--primary {
    background: var(--eco-orange);
    color: #ffffff;
    border-color: var(--eco-orange);
}
.inleap-btn--primary:hover { background: var(--eco-orange-hover); transform: translateY(-1px); }
/* Non acconsento → ghost */
.inleap-btn--ghost {
    background: transparent;
    color: var(--eco-text-muted);
    border-color: var(--eco-border);
}
.inleap-btn--ghost:hover { color: var(--eco-text); border-color: var(--eco-text-muted); }
.inleap-btn--decline {
    background: transparent;
    color: var(--eco-text-muted);
    border: none;
    font-weight: 400;
    padding: 9px 10px;
}
.inleap-btn--decline:hover { color: #dc3545; }

/* ── Input area ─────────────────────────────────────────────────────────── */
.inleap-input-area {
    border-top: 1px solid var(--eco-border);
    padding: 10px 16px !important;
    background: var(--eco-bg-alt);
    flex-shrink: 0;
}
.inleap-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--eco-bg);
    border: 1px solid var(--eco-border);
    border-radius: var(--r);
    padding: 9px 10px 9px 14px !important;
    transition: border-color 0.15s var(--ease);
}
.inleap-input-wrap:focus-within { border-color: var(--eco-green); }

.inleap-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--eco-text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--eco-border) transparent;
}
.inleap-input::placeholder { color: var(--eco-text-muted); }

/* Tasto invio — arancione (CTA principale) */
.inleap-send-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--eco-orange);
    color: #ffffff;
    border: none;
    border-radius: var(--r);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s, transform 0.15s;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    font-family: var(--font-sans);
}
.inleap-send-btn:disabled {
    background: var(--eco-orange);
    color: rgba(255, 255, 255, 0.45);
    cursor: default;
    opacity: 0.6;
}
.inleap-send-btn:not(:disabled):hover {
    background: var(--eco-orange-hover);
    transform: translateY(-1px);
}
.inleap-send-btn:focus-visible { outline: 2px solid var(--eco-orange); outline-offset: 2px; }

.inleap-input-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 6px;
    padding: 0 2px;
}
.inleap-input-footer__brand {
    font-family: var(--font-sans);
    font-size: 9px;
    color: var(--eco-text-light);
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.8;
}
.inleap-input-footer__brand a {
    color: var(--eco-green);
    text-decoration: none;
}
.inleap-input-footer__brand a:hover {
    text-decoration: underline;
}

/* ── Error ──────────────────────────────────────────────────────────────── */
.inleap-msg--error .inleap-msg__bubble {
    background: rgba(220, 53, 69, 0.06) !important;
    border-color: #dc3545 !important;
    color: #dc3545 !important;
}
.inleap-msg--error .inleap-msg__bubble::before { background: #dc3545; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #inleap-chat-root {
        --chat-w:        calc(100vw - 16px);
        --offset-right:  8px;
        --offset-bottom: 70px;
    }
    .inleap-panel { right: 0; left: 0; width: 100%; max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
    .inleap-panel, .inleap-launcher, .inleap-msg,
    .inleap-typing span, .inleap-panel__pip, .inleap-launcher--pulse {
        animation: none;
        transition: opacity 0.1s;
    }
}

/* ── Scroll trigger — pulse launcher (mobile) ───────────────────────────── */
@keyframes inleap-pulse {
    0%   { box-shadow: 0 0 0 0  rgba(243, 147, 37, 0.50); }
    70%  { box-shadow: 0 0 0 14px rgba(243, 147, 37, 0); }
    100% { box-shadow: 0 0 0 0  rgba(243, 147, 37, 0); }
}
.inleap-launcher--pulse {
    animation: inleap-pulse 0.9s ease-out 3;
}
