/* =====================
   FONT
   ===================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* =====================
   RESET BASE
   ===================== */
#accendila-chat-floating *,
#accendila-chat-floating *::before,
#accendila-chat-floating *::after {
    box-sizing: border-box;
}

/* =====================
   FLOATING BUTTON
   ===================== */

#accendila-chat-floating {
    position: fixed;
    bottom: 28px;
    left: 28px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.accendila-chat-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(145deg, #15a060, #0d6b3d);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 2px 6px rgba(0,0,0,0.12),
        0 8px 28px rgba(18, 131, 81, 0.38);
    transition: 2s all;
    color: white;
}

.accendila-chat-button:hover {
   
    transform: scale(1.06);
    box-shadow:
        0 4px 10px rgba(0,0,0,0.14),
        0 14px 36px rgba(18, 131, 81, 0.45);
}

.accendila-chat-button:active {
    transform: scale(0.95);
}

/* =====================
   CHAT WINDOW
   — gradiente lavanda, shadow premium, no header space
   ===================== */

.accendila-chat-window {
    position: absolute;
    bottom: 68px;
    left: 0;
    width: 370px;
    max-height: 620px;
    background: linear-gradient(165deg, #d8dbe8 0%, #e2e5ef 35%, #eceef5 100%);
    border-radius: 22px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.55),
        0 2px 4px rgba(0,0,0,0.04),
        0 10px 24px rgba(0,0,0,0.09),
        0 28px 60px rgba(0,0,0,0.13),
        0 60px 100px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: windowOpen 0.28s cubic-bezier(.34,1.3,.64,1);
}

@keyframes windowOpen {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =====================
   HEADER — sparisce, rimane solo spazio per bottoni fluttuanti
   ===================== */

.accendila-chat-header {
    display: none;
}

/* Bottoni fluttuanti X e Fine — sovrapposti in alto a destra */
.accendila-chat-header-actions {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 50;
}

.accendila-chat-end {
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.7);
    color: #333;
    font-size: 11.5px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.18s ease;
    font-family: inherit;
    letter-spacing: 0.1px;
}

.accendila-chat-end:hover {
    background: rgba(255,255,255,0.78);
}

.accendila-chat-close {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.7);
    color: #333;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease;
    padding: 0;
    flex-shrink: 0;
}

.accendila-chat-close:hover {
    background: rgba(255,255,255,0.78);
    color: #111;
}

/* =====================
   FORM PRE-CHAT
   ===================== */

.accendila-prechat-form {
    padding: 56px 18px 22px;
    overflow-y: auto;
    flex: 1;
    background: transparent;
}

.accendila-prechat-intro p {
    margin: 0 0 18px 0;
    color: #444;
    font-size: 14px;
    line-height: 1.55;
}

.accendila-prechat-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.accendila-prechat-input {
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    color: #222;
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: background 0.18s ease, box-shadow 0.18s ease;
    outline: none;
    font-family: inherit;
}

.accendila-prechat-input::placeholder { color: #aaa; }

.accendila-prechat-input:focus {
    background: rgba(255,255,255,0.88);
    box-shadow: 0 0 0 2px rgba(18,131,81,0.2);
}

.accendila-prechat-error {
    background: rgba(255,59,48,0.1);
    color: #c0392b;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 13px;
}

.accendila-prechat-submit {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #15a060, #0d6b3d);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.18s ease, transform 0.15s ease;
    margin-top: 6px;
    letter-spacing: -0.1px;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(18,131,81,0.28);
}

.accendila-prechat-submit:hover { opacity: 0.9; }
.accendila-prechat-submit:active { transform: scale(0.98); }
.accendila-prechat-submit:disabled {
    background: rgba(0,0,0,0.2);
    box-shadow: none;
    cursor: not-allowed;
}

/* =====================
   PRIVACY CHECKBOX
   ===================== */

.accendila-prechat-privacy-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
}

.accendila-prechat-checkbox {
    margin-top: 2px;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: #128351;
    cursor: pointer;
}

.accendila-prechat-privacy-wrap label {
    font-size: 12px;
    color: #666;
    line-height: 1.45;
    cursor: pointer;
}

.accendila-prechat-privacy-wrap label a {
    color: #128351;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.accendila-prechat-privacy {
    font-size: 11px;
    color: #aaa;
    line-height: 1.4;
    margin: 2px 0 0;
}

/* =====================
   CHAT BODY
   ===================== */

.accendila-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
    background: transparent;
}

/* Fade top */
.accendila-chat-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: linear-gradient(to bottom,
        rgba(236, 237, 243, 0.95) 0%,
        rgba(216,219,232,0) 100%);
    z-index: 10;
    pointer-events: none;
}

/* Fade bottom */
.accendila-chat-body::after {
    content: '';
    position: absolute;
    bottom: 62px;
    left: 0;
    right: 0;
    height: 28px;
    background: linear-gradient(to top,
        rgba(236,238,245,0.95) 0%,
        rgba(236,238,245,0) 100%);
    z-index: 10;
    pointer-events: none;
}

/* =====================
   MESSAGGI AREA
   ===================== */

.accendila-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 52px 14px 14px;
    background: transparent;
    min-height: 350px;
    max-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.accendila-chat-messages::-webkit-scrollbar { width: 0px; }

.accendila-chat-date-separator {
    text-align: center;
    font-size: 11px;
    color: rgba(0,0,0,0.25);
    font-weight: 500;
    margin: 8px 0 4px;
    letter-spacing: 0.3px;
}

/* =====================
   MESSAGGI
   ===================== */

.accendila-chat-message {
    max-width: 80%;
    animation: msgIn 0.2s cubic-bezier(.25,.46,.45,.94);
    display: flex;
    flex-direction: column;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.accendila-chat-bot  { align-self: flex-start; }
.accendila-chat-user { align-self: flex-end; }

/* Bolla bot */
.accendila-chat-bot .accendila-chat-message-content {
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #111;
    border-radius: 18px 18px 18px 4px;
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.58;
    font-weight: 400;
}

/* Bolla utente */
.accendila-chat-user .accendila-chat-message-content {
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #111;
    border-radius: 18px 18px 4px 18px;
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.58;
    font-weight: 400;
}

.accendila-chat-bot + .accendila-chat-bot,
.accendila-chat-user + .accendila-chat-user {
    margin-top: -2px;
}

/* Link */
.accendila-chat-message-content a {
    color: #128351;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(18,131,81,0.4);
    transition: text-decoration-color 0.15s;
}
.accendila-chat-message-content a:hover {
    text-decoration-color: #128351;
}

/* Timestamp */
.accendila-chat-message-time {
    font-size: 10.5px;
    color: rgba(0,0,0,0.3);
    margin-top: 3px;
    padding: 0 4px;
}
.accendila-chat-user .accendila-chat-message-time {
    text-align: right;
}

/* Feedback thumbs */
.accendila-chat-feedback {
    display: flex;
    gap: 4px;
    margin-top: 5px;
    padding: 0 2px;
}

.accendila-chat-feedback button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(0,0,0,0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.18s ease, color 0.18s ease;
    padding: 0;
    font-family: inherit;
}

.accendila-chat-feedback button:hover {
    background: rgba(255,255,255,0.8);
    color: #333;
}

.accendila-chat-feedback button.active {
    background: #111;
    color: #fff;
}

/* =====================
   PRODUCT CARD
   ===================== */

.product-card-wrapper {
    margin: 4px 0;
    max-width: 100%;
}

.product-card {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    box-shadow:
        0 1px 3px rgba(0,0,0,0.05),
        0 4px 12px rgba(0,0,0,0.07);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    text-decoration: none;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow:
        0 2px 6px rgba(0,0,0,0.07),
        0 10px 28px rgba(0,0,0,0.11);
}

.product-card img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    flex-shrink: 0;
}

.product-card .product-info {
    padding: 11px 13px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.product-card h4 {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 700;
    color: #111;
    line-height: 1.35;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-card .product-category {
    font-size: 10px;
    color: rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 0.9px;
    font-weight: 600;
    margin-bottom: 4px;
}

.product-card .product-price {
    font-size: 16px;
    font-weight: 800;
    color: #128351;
    letter-spacing: -0.4px;
    line-height: 1;
}

.product-card .product-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 9px;
    color: white;
    background: #128351;
    text-decoration: none;
    font-weight: 600;
    font-size: 11.5px;
    padding: 6px 13px;
    border-radius: 20px;
    transition: background 0.18s ease, box-shadow 0.18s ease;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(18,131,81,0.28);
    letter-spacing: 0.1px;
}

.product-card .product-link:hover {
    background: #0f6e44;
    box-shadow: 0 4px 12px rgba(18,131,81,0.35);
    text-decoration: none;
}

/* =====================
   TYPING INDICATOR
   ===================== */

.accendila-chat-typing {
    padding: 4px 14px 10px;
    background: transparent;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.accendila-chat-typing-bubble {
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 18px 18px 18px 4px;
    padding: 10px 15px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.accendila-chat-typing span {
    width: 6px;
    height: 6px;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    animation: typingBounce 1.3s infinite ease-in-out;
}

.accendila-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.accendila-chat-typing span:nth-child(3) { animation-delay: 0.30s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* =====================
   INPUT AREA
   ===================== */

.accendila-chat-input-container {
    display: flex;
    gap: 8px;
    padding: 10px 12px 14px;
    background: transparent;
    align-items: flex-end;
    flex-shrink: 0;
}

.accendila-chat-input {
    flex: 1;
    padding: 11px 16px;
    border: none;
    border-radius: 22px;
    resize: none;
    font-size: 14px;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    outline: none;
    transition: background 0.18s ease, box-shadow 0.18s ease;
    font-family: inherit;
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #111;
}

.accendila-chat-input:focus {
    background: rgba(255,255,255,0.88);
    box-shadow: 0 0 0 2px rgba(18,131,81,0.2);
}

.accendila-chat-input::placeholder {
    color: rgba(0,0,0,0.3);
}

.accendila-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #128351;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 2px 10px rgba(18,131,81,0.35);
}

.accendila-chat-send:hover {
    opacity: 0.88;
    transform: scale(1.06);
}

.accendila-chat-send:active {
    transform: scale(0.92);
}

.accendila-chat-send:disabled {
    background: rgba(0,0,0,0.15);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* =====================
   RESPONSIVE MOBILE
   ===================== */

@media (max-width: 480px) {
    #accendila-chat-floating {
        bottom: 16px;
        left: 16px;
    }

    .accendila-chat-window {
        width: calc(100vw - 32px);
        left: 0;
        bottom: 68px;
        max-height: 75vh;
        border-radius: 18px;
    }
}