.luna-chat-widget {
    bottom: 24px;
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    position: fixed;
    right: 24px;
    z-index: 1080;
}

.luna-chat-widget,
.luna-chat-widget * { box-sizing: border-box; }

.luna-chat-widget button,
.luna-chat-widget textarea,
.luna-chat-widget a { font: inherit; }

.store-back-to-top {
    bottom: 94px;
    right: 26px;
}

.luna-chat-trigger {
    align-items: center;
    background: linear-gradient(135deg, var(--store-primary, #2b1b22), var(--store-accent, #de9da8));
    border: 0;
    border-radius: 50%;
    box-shadow: 0 10px 28px rgba(43, 27, 34, .30);
    color: #fff;
    cursor: pointer;
    display: flex;
    height: 56px;
    justify-content: center;
    padding: 0;
    position: relative;
    transition: transform .2s ease, box-shadow .2s ease;
    width: 56px;
}

.luna-chat-trigger:hover,
.luna-chat-trigger:focus-visible {
    box-shadow: 0 13px 34px rgba(43, 27, 34, .38);
    outline: 3px solid color-mix(in srgb, var(--store-accent, #de9da8) 38%, transparent);
    transform: translateY(-2px);
}

.luna-chat-trigger > i { font-size: 1.55rem; }

.luna-chat-trigger > img {
    border: 2px solid #fff;
    border-radius: 50%;
    height: 56px;
    object-fit: cover;
    width: 56px;
}

.luna-chat-status {
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
    bottom: 1px;
    height: 13px;
    position: absolute;
    right: 1px;
    width: 13px;
}

.luna-chat-hint {
    background: #fff;
    border: 1px solid rgba(43, 27, 34, .08);
    border-radius: 13px;
    box-shadow: 0 8px 26px rgba(32, 21, 28, .14);
    color: var(--store-primary, #2b1b22);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.25;
    max-width: 270px;
    opacity: 0;
    padding: 11px 14px;
    pointer-events: none;
    position: absolute;
    right: 70px;
    top: 7px;
    transform: translateX(12px);
    transition: opacity .25s ease, transform .25s ease;
    white-space: nowrap;
}

.luna-chat-hint::after {
    border-color: transparent transparent transparent #fff;
    border-style: solid;
    border-width: 6px 0 6px 7px;
    content: '';
    position: absolute;
    right: -7px;
    top: calc(50% - 6px);
}

.luna-chat-hint.is-visible { opacity: 1; transform: translateX(0); }

.luna-chat-panel {
    background: #fff;
    border: 1px solid rgba(43, 27, 34, .10);
    border-radius: 20px;
    bottom: 70px;
    box-shadow: 0 22px 60px rgba(32, 21, 28, .24);
    display: flex;
    flex-direction: column;
    height: min(620px, calc(100vh - 125px));
    overflow: hidden;
    position: absolute;
    right: 0;
    transform-origin: right bottom;
    width: min(390px, calc(100vw - 32px));
}

.luna-chat-panel[hidden] { display: none; }

.luna-chat-header {
    align-items: center;
    background: linear-gradient(135deg, var(--store-primary, #2b1b22), #4a2f3a);
    color: #fff;
    display: flex;
    gap: 10px;
    min-height: 70px;
    padding: 12px 14px;
}

.luna-chat-avatar {
    align-items: center;
    background: rgba(255,255,255,.13);
    border-radius: 50%;
    display: flex;
    flex: 0 0 42px;
    height: 42px;
    justify-content: center;
    overflow: hidden;
}

.luna-chat-avatar img { height: 42px; object-fit: cover; width: 42px; }
.luna-chat-avatar i { font-size: 1.15rem; }
.luna-chat-heading { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.luna-chat-heading strong { font-size: .98rem; }
.luna-chat-heading small { color: rgba(255,255,255,.78); font-size: .72rem; }
.luna-chat-heading small span { background: #22c55e; border-radius: 50%; display: inline-block; height: 7px; margin-right: 3px; width: 7px; }

.luna-chat-human,
.luna-chat-clear,
.luna-chat-close {
    align-items: center;
    background: rgba(255,255,255,.11);
    border: 0;
    border-radius: 50%;
    color: #fff !important;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 36px;
    height: 36px;
    justify-content: center;
    text-decoration: none;
    width: 36px;
}

.luna-chat-human:hover,
.luna-chat-clear:hover,
.luna-chat-close:hover { background: rgba(255,255,255,.22); }
.luna-chat-human { background: #16a766; }

.luna-chat-clear svg,
.luna-chat-form button svg {
    display: block;
    height: 18px;
    width: 18px;
}

.luna-chat-messages {
    background: #f8f5f6;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px;
    scrollbar-width: thin;
}

.luna-message { display: flex; flex-direction: column; max-width: 88%; }
.luna-message--assistant { align-self: flex-start; }
.luna-message--user { align-self: flex-end; }

.luna-message-bubble {
    background: #fff;
    border: 1px solid rgba(43, 27, 34, .08);
    border-radius: 6px 16px 16px 16px;
    color: #31252b;
    font-size: .86rem;
    line-height: 1.48;
    padding: 10px 12px;
    white-space: pre-line;
}

.luna-message--user .luna-message-bubble {
    background: var(--store-primary, #2b1b22);
    border: 0;
    border-radius: 16px 6px 16px 16px;
    color: #fff;
}

.luna-message-time { color: #91848b; font-size: .63rem; margin: 3px 5px 0; }
.luna-message--user .luna-message-time { text-align: right; }

.luna-products { display: grid; gap: 8px; margin-top: 8px; width: 100%; }
.luna-product {
    align-items: center;
    background: #fff;
    border: 1px solid rgba(43, 27, 34, .09);
    border-radius: 13px;
    display: grid;
    gap: 9px;
    grid-template-columns: 62px minmax(0,1fr);
    padding: 8px;
}
.luna-product img { background: #f5f5f5; border-radius: 9px; height: 62px; object-fit: cover; width: 62px; }
.luna-product-info { min-width: 0; }
.luna-product-info strong { color: #291d23; display: -webkit-box; font-size: .78rem; line-height: 1.25; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.luna-product-info small { color: #75676e; display: block; font-size: .68rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.luna-product-price { color: var(--store-primary, #2b1b22); display: block; font-size: .8rem; font-weight: 800; margin-top: 4px; }
.luna-product-actions { display: flex; gap: 6px; grid-column: 1 / -1; }
.luna-product-actions a,
.luna-product-actions button,
.luna-action-link {
    align-items: center;
    background: var(--store-primary, #2b1b22);
    border: 1px solid var(--store-primary, #2b1b22);
    border-radius: 999px;
    color: #fff !important;
    cursor: pointer;
    display: inline-flex;
    flex: 1;
    font-size: .7rem;
    font-weight: 700;
    justify-content: center;
    min-height: 32px;
    padding: 5px 10px;
    text-decoration: none;
}
.luna-product-actions button { background: #fff; color: var(--store-primary, #2b1b22) !important; }
.luna-product-actions button:disabled { cursor: wait; opacity: .65; }
.luna-action-link { align-self: flex-start; flex: none; margin-top: 8px; padding-inline: 14px; }
.luna-action-link--whatsapp { background: #16a766; border-color: #16a766; }

.luna-chat-quick {
    background: #fff;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 12px 4px;
    scrollbar-width: none;
}
.luna-chat-quick::-webkit-scrollbar { display: none; }
.luna-chat-quick button {
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--store-primary, #2b1b22) 20%, #fff);
    border-radius: 999px;
    color: var(--store-primary, #2b1b22);
    cursor: pointer;
    flex: 0 0 auto;
    font-size: .68rem;
    font-weight: 700;
    padding: 6px 10px;
}

.luna-chat-typing { align-items: center; background: #fff; color: #8a7b82; display: flex; gap: 3px; padding: 5px 14px 0; }
.luna-chat-typing[hidden] { display: none; }
.luna-chat-typing span { animation: luna-dot 1.1s infinite; background: #b4a5ac; border-radius: 50%; height: 5px; width: 5px; }
.luna-chat-typing span:nth-child(2) { animation-delay: .15s; }
.luna-chat-typing span:nth-child(3) { animation-delay: .3s; }
.luna-chat-typing small { font-size: .65rem; margin-left: 4px; }
@keyframes luna-dot { 0%,60%,100% { opacity:.35; transform:translateY(0); } 30% { opacity:1; transform:translateY(-3px); } }

.luna-chat-form { align-items: flex-end; background: #fff; display: flex; gap: 8px; padding: 8px 10px 6px; }
.luna-chat-form textarea {
    border: 1px solid #ded5d9;
    border-radius: 18px;
    color: #31252b;
    flex: 1;
    font-size: .82rem;
    line-height: 1.35;
    max-height: 92px;
    min-height: 40px;
    outline: 0;
    overflow-y: auto;
    padding: 10px 13px;
    resize: none;
}
.luna-chat-form textarea:focus { border-color: var(--store-accent, #de9da8); box-shadow: 0 0 0 3px rgba(222,157,168,.16); }
.luna-chat-form button {
    align-items: center;
    background: var(--store-primary, #2b1b22);
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex: 0 0 40px;
    height: 40px;
    justify-content: center;
    width: 40px;
}
.luna-chat-form button:disabled { opacity: .6; }
.luna-chat-disclaimer { background: #fff; color: #91848b; display: block; font-size: .6rem; padding: 0 12px 8px; text-align: center; }

@media (max-width: 576px), (max-height: 576px) and (hover: none) and (pointer: coarse) {
    body.luna-chat-open { overflow: hidden; }
    .luna-chat-widget { bottom: 16px; right: 16px; }
    .store-back-to-top { bottom: 86px; right: 18px; }
    .luna-chat-widget.is-open {
        bottom: auto;
        left: calc(var(--luna-viewport-left, 0px) + 8px);
        right: auto;
        top: calc(var(--luna-viewport-top, 0px) + 8px);
    }
    .luna-chat-widget.is-open .luna-chat-panel {
        bottom: auto;
        height: calc(var(--luna-viewport-height, 100dvh) - 16px);
        max-height: none;
        min-height: 0;
        position: relative;
        right: auto;
        width: calc(var(--luna-viewport-width, 100vw) - 16px);
    }
    .luna-chat-widget.is-open .luna-chat-trigger,
    .luna-chat-widget.is-open .luna-chat-hint { display: none; }
    .luna-chat-hint { max-width: calc(100vw - 100px); overflow: hidden; right: 68px; text-overflow: ellipsis; }
    /* O Safari amplia automaticamente campos com fonte abaixo de 16px. */
    .luna-chat-form textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .luna-chat-trigger,
    .luna-chat-hint,
    .luna-chat-typing span { animation: none; transition: none; }
}
