/* hsaichat — stile widget. Prefisso .hsai- per non collidere col tema Warehouse. */

.hsai-root {
    position: fixed;
    z-index: 100000; /* sopra whatsappchat (10000) e popup del tema */
    right: 16px;
    bottom: 96px; /* sopra il bottone WhatsApp (bottom ~10px) */
    font-family: inherit;
    line-height: 1.4;
}

/* ---------- bolla ---------- */
.hsai-bubble {
    position: relative;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: #222;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}
.hsai-bubble:hover { transform: scale(1.06); }
.hsai-bubble-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #c59d5f;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

/* ---------- pannello ---------- */
.hsai-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 68px;
    width: 372px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    flex-direction: column;
}
.hsai-open .hsai-panel { display: flex; }

.hsai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #222;
    color: #fff;
    flex: 0 0 auto;
}
.hsai-header-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.hsai-ai-badge {
    background: #c59d5f;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
}
.hsai-header-actions button {
    background: none;
    border: 0;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.85;
}
.hsai-header-actions button:hover { opacity: 1; }

/* ---------- messaggi ---------- */
.hsai-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 12px 6px;
    background: #f7f6f4;
}
.hsai-msg { display: flex; margin-bottom: 8px; }
.hsai-msg-user { justify-content: flex-end; }
.hsai-msg-bubble {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 14px;
    word-wrap: break-word;
    white-space: normal;
}
.hsai-msg-user .hsai-msg-bubble {
    background: #222;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.hsai-msg-assistant .hsai-msg-bubble {
    background: #fff;
    color: #222;
    border: 1px solid #e6e2dc;
    border-bottom-left-radius: 4px;
}

/* typing indicator */
.hsai-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 2px;
    border-radius: 50%;
    background: #b7b1a9;
    animation: hsai-blink 1.2s infinite both;
}
.hsai-typing span:nth-child(2) { animation-delay: 0.2s; }
.hsai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes hsai-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}
.hsai-typing-note { font-size: 12px; color: #8a847c; margin-top: 6px; }

/* ---------- schede prodotto ---------- */
.hsai-products {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    -webkit-overflow-scrolling: touch;
}
.hsai-card {
    flex: 0 0 150px;
    background: #fff;
    border: 1px solid #e6e2dc;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: #222;
    display: flex;
    flex-direction: column;
}
.hsai-card:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12); text-decoration: none; color: #222; }
.hsai-card img { width: 100%; height: 110px; object-fit: contain; background: #fff; }
.hsai-card-info { padding: 8px 9px 9px; display: flex; flex-direction: column; gap: 3px; }
.hsai-card-brand { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: #8a847c; }
.hsai-card-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.hsai-card-price-row { display: flex; align-items: baseline; gap: 6px; }
.hsai-card-price { font-size: 13px; font-weight: 700; }
.hsai-card-regular { font-size: 11px; color: #a09a92; text-decoration: line-through; }

/* ---------- quick replies ---------- */
.hsai-quick {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px;
    background: #f7f6f4;
}
.hsai-quick:not(:empty) { padding-bottom: 8px; }
.hsai-chip {
    border: 1px solid #c59d5f;
    background: #fff;
    color: #8a6d3b;
    font-size: 12px;
    border-radius: 14px;
    padding: 5px 11px;
    cursor: pointer;
}
.hsai-chip:hover { background: #c59d5f; color: #fff; }

/* ---------- input ---------- */
.hsai-input-row {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee9e2;
    margin: 0;
}
.hsai-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.hsai-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #ddd6cc;
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    max-height: 90px;
    outline: none;
}
.hsai-input:focus { border-color: #c59d5f; }
.hsai-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #222;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hsai-send:hover { background: #000; }

.hsai-footer {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: #8a847c;
    text-align: center;
    padding: 6px 10px 8px;
    background: #fff;
}
.hsai-footer a { color: #8a6d3b; text-decoration: underline; }

/* ---------- mobile ---------- */
@media (max-width: 768px) {
    .hsai-root { right: 12px; bottom: 88px; }
    .hsai-open .hsai-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0;
    }
    .hsai-hide-mobile { display: none; }
    .hsai-lock, .hsai-lock body { overflow: hidden; }
}
