/* QuiQuoQua — Chat widget flottante (Bootstrap 5 portale). */

#qqq-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    font-family: inherit;
}

#qqq-chat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #b78d5a;
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    transition: transform .2s ease, background .2s ease;
}

#qqq-chat-bubble:hover {
    transform: scale(1.05);
    background: #a17948;
}

#qqq-chat-bubble .qqq-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
    display: none;
}

#qqq-chat-panel {
    display: none;
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    flex-direction: column;
    overflow: hidden;
    transition: width .2s ease, height .2s ease;
}

#qqq-chat-panel.qqq-open {
    display: flex;
}

#qqq-chat-panel.qqq-expanded {
    width: 560px;
    height: 720px;
}

.qqq-chat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.qqq-chat-header .qqq-chat-expand {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
    opacity: .85;
}

.qqq-chat-header .qqq-chat-expand:hover {
    opacity: 1;
}

.qqq-chat-header {
    background: #b78d5a;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.qqq-chat-header h5 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.qqq-chat-header .qqq-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.qqq-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fa;
}

.qqq-chat-msg {
    margin-bottom: 8px;
    display: flex;
}

.qqq-chat-msg.qqq-msg-user     { justify-content: flex-end; }
.qqq-chat-msg.qqq-msg-bot,
.qqq-chat-msg.qqq-msg-operator { justify-content: flex-start; }
.qqq-chat-msg.qqq-msg-system   { justify-content: center; }

.qqq-chat-msg .qqq-msg-bubble {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.qqq-msg-user     .qqq-msg-bubble { background: #b78d5a; color: #fff; border-bottom-right-radius: 2px; }
.qqq-msg-bot      .qqq-msg-bubble { background: #fff;    color: #333; border: 1px solid #e0e0e0; border-bottom-left-radius: 2px; }
.qqq-msg-operator .qqq-msg-bubble { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; border-bottom-left-radius: 2px; }
.qqq-msg-system   .qqq-msg-bubble { background: #fff3cd; color: #856404; font-style: italic; font-size: 12px; }

.qqq-chat-msg .qqq-msg-bubble a { color: inherit; text-decoration: underline; }

.qqq-chat-presets {
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #eee;
    background: #fff;
    max-height: 140px;
    overflow-y: auto;
}

.qqq-chat-preset-btn {
    background: #f8f4ee;
    color: #6b4a26;
    border: 1px solid #d4bd94;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
}

.qqq-chat-preset-btn:hover { background: #ebe2d1; }

.qqq-chat-input-row {
    display: flex;
    padding: 8px;
    border-top: 1px solid #eee;
    background: #fff;
    gap: 6px;
}

.qqq-chat-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    font-size: 14px;
    font-family: inherit;
    max-height: 80px;
}

.qqq-chat-input-row button {
    background: #b78d5a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
}

.qqq-chat-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.qqq-product-card {
    display: flex;
    align-items: stretch;
    margin-top: 8px;
    background: #fff;
    border: 1px solid #e0d5c4;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease, transform .15s ease;
    max-width: 100%;
}

.qqq-product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
    text-decoration: none;
}

.qqq-product-card-img {
    width: 72px;
    height: 96px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f5f5f5;
}

.qqq-product-card-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
}

.qqq-product-card-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
    color: #333;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.qqq-product-card-brand {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.qqq-product-card-price {
    font-size: 13px;
    color: #b78d5a;
    font-weight: 700;
    margin-top: 4px;
}

.qqq-product-card-out {
    color: #a55;
    font-weight: 500;
    font-size: 11px;
}

/* Bubbles con card prodotto: le card devono estendersi anche in messaggi bot
   con poco testo — allarghiamo la max-width per lasciare spazio. */
.qqq-chat-msg.qqq-msg-bot .qqq-msg-bubble:has(.qqq-product-card),
.qqq-chat-msg.qqq-msg-operator .qqq-msg-bubble:has(.qqq-product-card) {
    max-width: 92%;
}

.qqq-typing {
    display: inline-flex;
    gap: 3px;
    padding: 4px 0;
}
.qqq-typing span {
    width: 6px; height: 6px;
    background: #999; border-radius: 50%;
    animation: qqq-blink 1.2s infinite ease-in-out;
}
.qqq-typing span:nth-child(2) { animation-delay: .2s; }
.qqq-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes qqq-blink {
    0%, 80%, 100% { opacity: .3; }
    40% { opacity: 1; }
}
