/*
 * SmartAssist floating chat (templates/launcher.phtml), the same on Hyvä and Luma.
 *
 * Every rule is scoped under .dxa-launcher / .dxa-panel with two classes, so it
 * outranks theme rules such as Luma's `button:hover` (one class + one element),
 * and sized in px so Luma's 62.5% root font size does not shrink it.
 * Colours come from --dx-accent, set from admin config on both elements.
 */
.dxa-launcher, .dxa-panel { --dxa-accent: var(--dx-accent, #e2001a); --dxa-ink: #1f2937; --dxa-muted: #6b7280; }

/* ---- Button + hint ------------------------------------------------------ */
.dxa-launcher { position: fixed; bottom: 20px; z-index: 99990; font-family: inherit; }
.dxa-launcher--left { left: 20px; }
.dxa-launcher--right { right: 20px; }

.dxa-launcher .dxa-fab {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 58px; height: 58px; margin: 0; padding: 0; border: 0; border-radius: 50%;
    background: var(--dxa-accent); color: #fff; cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .12);
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s;
    animation: dxa-fab-in .6s cubic-bezier(.34, 1.56, .64, 1) .3s both;
}
.dxa-launcher .dxa-fab:hover, .dxa-launcher .dxa-fab:focus {
    background: var(--dxa-accent); color: #fff; border: 0;
    transform: scale(1.07); box-shadow: 0 10px 28px rgba(0, 0, 0, .22), 0 3px 8px rgba(0, 0, 0, .14);
}
.dxa-launcher .dxa-fab:focus-visible { outline: 3px solid rgba(0, 0, 0, .25); outline-offset: 3px; }
.dxa-launcher .dxa-fab svg { position: absolute; transition: transform .3s ease, opacity .2s ease; }
.dxa-launcher .dxa-fab__close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.dxa-launcher.is-open .dxa-fab__chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.dxa-launcher.is-open .dxa-fab__close { opacity: 1; transform: none; }

/* A soft ring while the hint is up, so the eye goes from the bubble to the button */
.dxa-launcher .dxa-fab::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%;
    box-shadow: 0 0 0 0 var(--dxa-accent); opacity: 0; pointer-events: none;
}
.dxa-launcher.is-hinting .dxa-fab::after { animation: dxa-ring 1.4s ease-out 2; }

.dxa-launcher .dxa-tip {
    position: absolute; bottom: 70px; display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 16px; white-space: nowrap;
    background: #fff; color: var(--dxa-ink); font-size: 14px; line-height: 20px; font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .08);
    opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(10px) scale(.85);
}
.dxa-launcher--left .dxa-tip { left: 0; transform-origin: 24px 100%; border-bottom-left-radius: 4px; }
.dxa-launcher--right .dxa-tip { right: 0; transform-origin: calc(100% - 24px) 100%; border-bottom-right-radius: 4px; }
.dxa-launcher.is-hinting .dxa-tip {
    visibility: visible; animation: dxa-tip-in .55s cubic-bezier(.34, 1.56, .64, 1) forwards;
}
.dxa-launcher.is-hinting-out .dxa-tip {
    visibility: visible; animation: dxa-tip-out .35s ease-in forwards;
}
.dxa-launcher .dxa-tip__wave { display: inline-block; transform-origin: 70% 70%; }
.dxa-launcher.is-hinting .dxa-tip__wave { animation: dxa-wave 1.2s ease-in-out .35s 2; }

@keyframes dxa-fab-in { from { opacity: 0; transform: scale(.4) translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes dxa-tip-in {
    0% { opacity: 0; transform: translateY(10px) scale(.85); }
    100% { opacity: 1; transform: none; }
}
@keyframes dxa-tip-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px) scale(.92); } }
@keyframes dxa-ring {
    0% { opacity: .55; box-shadow: 0 0 0 0 var(--dxa-accent); }
    100% { opacity: 0; box-shadow: 0 0 0 16px var(--dxa-accent); }
}
@keyframes dxa-wave {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(16deg); } 30% { transform: rotate(-10deg); }
    45% { transform: rotate(14deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(8deg); }
}

/* ---- Panel ---------------------------------------------------------------- */
.dxa-panel {
    position: fixed; bottom: 92px; z-index: 99991;
    display: flex; flex-direction: column;
    width: 400px; max-width: calc(100vw - 40px); height: 640px; max-height: calc(100vh - 112px);
    background: #fff; color: var(--dxa-ink); border-radius: 20px; overflow: hidden;
    font-size: 14px; line-height: 1.5; font-family: inherit;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .2), 0 4px 14px rgba(0, 0, 0, .08);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(16px) scale(.96);
    transition: opacity .22s ease, transform .3s cubic-bezier(.34, 1.3, .64, 1), visibility 0s linear .3s;
}
.dxa-panel--left { left: 20px; transform-origin: 30px 100%; }
.dxa-panel--right { right: 20px; transform-origin: calc(100% - 30px) 100%; }
.dxa-panel.is-open {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity .22s ease, transform .3s cubic-bezier(.34, 1.3, .64, 1), visibility 0s;
}

.dxa-panel .dxa-panel__head {
    display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 18px;
    background: var(--dxa-accent); color: #fff;
}
.dxa-panel .dxa-avatar {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .2); color: #fff;
}
.dxa-panel .dxa-panel__titles { flex: 1 1 auto; min-width: 0; }
.dxa-panel .dxa-panel__title { font-size: 16px; line-height: 22px; font-weight: 700; color: #fff; }
.dxa-panel .dxa-panel__status { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; opacity: .9; }
.dxa-panel .dxa-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #4ade80;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
}
.dxa-panel .dxa-x, .dxa-panel .dxa-x:hover, .dxa-panel .dxa-x:focus {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .15); color: #fff; cursor: pointer; box-shadow: none;
}
.dxa-panel .dxa-x:hover { background: rgba(255, 255, 255, .28); }

.dxa-panel .dxa-product {
    display: flex; align-items: center; gap: 12px; margin: 12px 14px 0; padding: 10px 12px;
    border: 1px solid #eceef1; border-radius: 14px; background: #fff;
}
.dxa-panel .dxa-product__img { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; flex: none; }
.dxa-panel .dxa-product__name {
    font-size: 13px; line-height: 18px; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.dxa-panel .dxa-panel__body {
    flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
    padding: 14px; display: flex; flex-direction: column; gap: 12px; background: #f7f8fa;
    margin-top: 12px;
}
.dxa-panel .dxa-thread { display: flex; flex-direction: column; gap: 12px; }
.dxa-panel .dxa-row { display: flex; justify-content: flex-start; animation: dxa-msg-in .3s ease-out both; }
.dxa-panel .dxa-row--user { justify-content: flex-end; }
.dxa-panel .dxa-bubble {
    max-width: 88%; padding: 10px 14px; border-radius: 16px 16px 16px 4px;
    background: #fff; color: var(--dxa-ink); font-size: 14px; line-height: 21px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06); white-space: pre-line; overflow-wrap: anywhere;
}
.dxa-panel .dxa-bubble--user { border-radius: 16px 16px 4px 16px; background: var(--dxa-accent); color: #fff; box-shadow: none; }
.dxa-panel .dxa-bubble.opacity-60, .dxa-panel .dxa-pending { opacity: .6; }
.dxa-panel .dxa-sources { margin-top: -4px; padding: 0 4px; font-size: 12px; line-height: 17px; color: var(--dxa-muted); }
.dxa-panel .dxa-feedback {
    margin-top: -6px; padding: 0 4px; display: flex; align-items: center; gap: 10px;
    font-size: 12px; line-height: 17px; color: var(--dxa-muted);
}
.dxa-panel .dxa-thumb, .dxa-panel .dxa-thumb:hover, .dxa-panel .dxa-thumb:focus {
    margin: 0; padding: 0; border: 0; background: none; box-shadow: none; cursor: pointer; font-size: 15px; line-height: 1;
}
.dxa-panel .dxa-thumb:hover { opacity: .7; }

.dxa-panel .dxa-panel__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; background: #fff; }
.dxa-panel .dxa-panel__chips:empty { display: none; }
.dxa-panel .dxa-chip, .dxa-panel .dxa-chip:hover, .dxa-panel .dxa-chip:focus {
    margin: 0; padding: 6px 12px; border: 1px solid var(--dxa-accent); border-radius: 999px;
    background: #fff; color: var(--dxa-accent); box-shadow: none;
    font-size: 12px; line-height: 17px; font-weight: 500; text-align: left; cursor: pointer;
    transition: background .15s, color .15s;
}
.dxa-panel .dxa-chip:hover { background: var(--dxa-accent); color: #fff; }

.dxa-panel .dxa-composer {
    display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 14px 14px; background: #fff;
}
.dxa-panel .dxa-input, .dxa-panel .dxa-input:focus {
    flex: 1 1 auto; min-width: 0; height: 44px; margin: 0; padding: 0 16px;
    border: 1.5px solid #d6d9de; border-radius: 999px; background: #fff; color: var(--dxa-ink);
    font-size: 14px; line-height: 20px; box-shadow: none; outline: none;
}
.dxa-panel .dxa-input:focus { border-color: var(--dxa-accent); }
.dxa-panel .dxa-send, .dxa-panel .dxa-send:hover, .dxa-panel .dxa-send:focus {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%;
    background: var(--dxa-accent); color: #fff; cursor: pointer; box-shadow: none;
    transition: transform .15s, opacity .15s;
}
.dxa-panel .dxa-send:hover { transform: scale(1.06); }
.dxa-panel .dxa-send:disabled { opacity: .5; cursor: default; transform: none; }

/* AI disclosure + privacy link under the composer */
.dxa-panel .dxa-legal {
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
    margin-top: -6px; padding: 0 14px 10px; background: #fff; color: var(--dxa-muted);
    font-size: 11px; line-height: 16px; text-align: center;
}
.dxa-panel .dxa-legal__ai { display: inline-flex; align-items: center; gap: 4px; }
.dxa-panel .dxa-legal__ai svg { color: var(--dxa-accent); }
.dxa-panel .dxa-legal__link, .dxa-panel .dxa-legal__link:hover, .dxa-panel .dxa-legal__link:focus {
    margin: 0; padding: 0; border: 0; background: none; box-shadow: none; cursor: pointer;
    color: var(--dxa-muted); font: inherit; font-weight: 600; text-decoration: underline;
}
.dxa-panel .dxa-legal__link:hover { color: var(--dxa-ink); }

/* "Legal information": slides over the conversation, inside the panel */
.dxa-panel .dxa-privacy {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; background: #fff;
    opacity: 0; visibility: hidden; transform: translateY(24px);
    transition: opacity .2s ease, transform .3s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .3s;
}
.dxa-panel .dxa-privacy.is-open {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity .2s ease, transform .3s cubic-bezier(.22, 1, .36, 1), visibility 0s;
}
.dxa-panel .dxa-privacy__head {
    position: relative; display: flex; align-items: center; justify-content: center;
    padding: 18px 56px 12px; border-bottom: 1px solid #eceef1;
}
.dxa-panel .dxa-privacy__title { font-size: 18px; line-height: 24px; font-weight: 700; color: var(--dxa-ink); text-align: center; }
.dxa-panel .dxa-privacy__x, .dxa-panel .dxa-privacy__x:hover, .dxa-panel .dxa-privacy__x:focus {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none;
    color: var(--dxa-ink); cursor: pointer;
}
.dxa-panel .dxa-privacy__x:hover { background: #f1f2f4; }
.dxa-panel .dxa-privacy__body {
    flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 20px;
    font-size: 13px; line-height: 20px; color: #374151;
}
.dxa-panel .dxa-privacy__body p { margin: 0 0 12px; }
.dxa-panel .dxa-privacy__body details { border-top: 1px solid #eceef1; }
.dxa-panel .dxa-privacy__body details:last-of-type { border-bottom: 1px solid #eceef1; }
.dxa-panel .dxa-privacy__body summary {
    display: flex; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; list-style: none;
    font-size: 14px; line-height: 20px; font-weight: 700; color: var(--dxa-ink);
}
.dxa-panel .dxa-privacy__body summary::-webkit-details-marker { display: none; }
.dxa-panel .dxa-privacy__body summary::before {
    content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 0 2px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(-45deg); transition: transform .2s ease;
}
.dxa-panel .dxa-privacy__body details[open] summary::before { transform: rotate(45deg); }
.dxa-panel .dxa-privacy__section { padding: 0 0 4px 24px; animation: dxa-msg-in .25s ease-out both; }
.dxa-panel .dxa-privacy__more { margin-top: 16px; }
.dxa-panel .dxa-privacy__more a { color: var(--dxa-accent); font-weight: 600; text-decoration: underline; }

/* Shopping assistant: product cards in a horizontal strip */
.dxa-panel .dxa-cards { position: relative; margin: 0 -14px; animation: dxa-msg-in .3s ease-out both; }
.dxa-panel .dxa-cards__track {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 14px;
    padding: 2px 14px 6px; scrollbar-width: none; overscroll-behavior-x: contain;
}
.dxa-panel .dxa-cards__track::-webkit-scrollbar { display: none; }
.dxa-panel .dxa-card, .dxa-panel .dxa-card:hover, .dxa-panel .dxa-card:visited {
    flex: 0 0 168px; scroll-snap-align: start; display: flex; flex-direction: column;
    padding: 10px; border: 1px solid #eceef1; border-radius: 14px; background: #fff;
    color: var(--dxa-ink); text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    transition: box-shadow .15s, transform .15s;
}
.dxa-panel .dxa-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .1); transform: translateY(-2px); }
.dxa-panel .dxa-card__img {
    display: flex; align-items: center; justify-content: center; height: 128px; margin-bottom: 8px;
    border-radius: 10px; background: #f7f8fa; overflow: hidden;
}
.dxa-panel .dxa-card__img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dxa-panel .dxa-card__name {
    font-size: 13px; line-height: 18px; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px;
}
.dxa-panel .dxa-card__price { margin-top: 4px; font-size: 14px; line-height: 20px; font-weight: 700; color: var(--dxa-accent); }
.dxa-panel .dxa-card__regular { margin-right: 6px; font-size: 12px; font-weight: 400; color: var(--dxa-muted); }
.dxa-panel .dxa-card__reason {
    margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--dxa-muted);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.dxa-panel .dxa-card__cta {
    display: block; margin-top: auto; padding: 7px 10px; text-align: center;
    border: 1.5px solid var(--dxa-ink); border-radius: 999px;
    font-size: 12px; line-height: 16px; font-weight: 600; transition: background .15s, color .15s;
}
/* The gap above the button, whichever line comes last before it */
.dxa-panel .dxa-card > :nth-last-child(2) { margin-bottom: 10px; }
.dxa-panel .dxa-card:hover .dxa-card__cta { background: var(--dxa-ink); color: #fff; }
.dxa-panel .dxa-cards__nav, .dxa-panel .dxa-cards__nav:hover, .dxa-panel .dxa-cards__nav:focus {
    position: absolute; top: 64px; display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; margin: 0; padding: 0; border: 0; border-radius: 50%;
    background: #fff; color: var(--dxa-ink); cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.dxa-panel .dxa-cards__nav--prev { left: 6px; }
.dxa-panel .dxa-cards__nav--next { right: 6px; }
@media (hover: none) { .dxa-panel .dxa-cards__nav { display: none; } }

.dxa-panel .dxa-hide { display: none; }
.dxa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes dxa-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Phones: the panel takes the screen; the button would only sit on top of the composer */
@media (max-width: 640px) {
    .dxa-panel {
        left: 0; right: 0; bottom: 0; width: 100%; max-width: none;
        height: 100%; max-height: none; border-radius: 0; transform: translateY(24px);
    }
    .dxa-panel--left, .dxa-panel--right { left: 0; right: 0; }
    .dxa-launcher.is-open { display: none; }
    .dxa-launcher { bottom: 16px; }
    .dxa-launcher--left { left: 16px; }
    .dxa-launcher--right { right: 16px; }
    .dxa-launcher .dxa-fab { width: 52px; height: 52px; }
    .dxa-launcher .dxa-tip { bottom: 62px; }
    .dxa-panel .dxa-input, .dxa-panel .dxa-input:focus { font-size: 16px; } /* no iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
    .dxa-launcher *, .dxa-launcher *::after, .dxa-panel, .dxa-panel * {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important;
    }
}
