/*
 * The shopping assistant (Views/Shared/Components/ShopAssistant, js/shop-assistant.js): the button that opens it - wide
 * and black in the middle of the home page, a small white circle in the corner of the other pages that widens while the
 * pointer is over it - and the dark chat panel with the replies and the cards of the products. Every rule starts from
 * the box of the assistant (.shop-assistant), so the styles of the theme for buttons, headings and fields stay out.
 */

@property --shop-assistant-glow-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

/* The button ----------------------------------------------------------------------------------- */

.shop-assistant .shop-assistant-launcher {
    position: fixed;
    left: max(24px, env(safe-area-inset-left, 0px));
    right: auto;
    /* --shop-assistant-lift: how far the script lifts the button while the cookie notice is in sight below it. */
    bottom: calc(24px + var(--shop-assistant-lift, 0px) + env(safe-area-inset-bottom, 0px));
    z-index: 998;
    display: inline-flex;
    align-items: center;
    gap: 16px;
    width: max-content;
    max-width: calc(100vw - 48px);
    height: 64px;
    margin: 0;
    padding: 8px 16px 8px 8px;
    border: 2px solid rgba(255, 255, 255, .55);
    border-radius: 999px;
    background: #000;
    color: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .3);
    font: 400 16px/22px Arial, Helvetica, sans-serif;
    text-align: start;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
}

.shop-assistant .shop-assistant-launcher--home {
    left: 50%;
    transform: translateX(-50%);
}

.shop-assistant .shop-assistant-launcher--compact {
    left: auto;
    right: max(24px, env(safe-area-inset-right, 0px));
    transform: none;
    max-width: calc(100vw - max(24px, env(safe-area-inset-left, 0px)) - max(24px, env(safe-area-inset-right, 0px)));
    gap: 0;
    padding-inline-end: 8px;
    background: #fff;
    border-color: rgba(0, 0, 0, .08);
    transition: gap .3s ease, padding-inline-end .3s ease, background .2s ease, border-color .2s ease;
}

.shop-assistant-launcher--compact .shop-assistant-launcher__label {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width .3s ease, opacity .2s ease;
}

.shop-assistant .shop-assistant-launcher--compact:focus-visible {
    gap: 16px;
    padding-inline-end: 16px;
    background: #000;
    border-color: rgba(255, 255, 255, .55);
}

.shop-assistant-launcher--compact:focus-visible .shop-assistant-launcher__label {
    max-width: 240px;
    opacity: 1;
}

.shop-assistant-launcher::before {
    content: "";
    position: absolute;
    inset: -2px;
    padding: 2px;
    border-radius: inherit;
    background: conic-gradient(from var(--shop-assistant-glow-angle), transparent 0deg 260deg, rgba(255, 255, 255, .2) 295deg, #fff 325deg, transparent 360deg);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.shop-assistant-launcher__icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    color: #000;
}

.shop-assistant-launcher__icon svg {
    display: block;
    width: 24px;
    height: 24px;
    transform-origin: center;
    transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}

.shop-assistant-launcher__label {
    min-width: 0;
    color: #fff;
    white-space: nowrap;
}

.shop-assistant .shop-assistant-launcher:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 4px;
    box-shadow: 0 0 0 6px #000, 0 4px 24px rgba(0, 0, 0, .3);
}

.shop-assistant-launcher:focus-visible::before {
    opacity: 1;
    animation: shop-assistant-border-light 2s linear infinite;
}

.shop-assistant-launcher:focus-visible .shop-assistant-launcher__icon svg {
    transform: rotate(180deg);
}

@media (hover: hover) and (pointer: fine) {
    .shop-assistant-launcher:hover::before {
        opacity: 1;
        animation: shop-assistant-border-light 2s linear infinite;
    }

    .shop-assistant .shop-assistant-launcher--compact:hover {
        gap: 16px;
        padding-inline-end: 16px;
        background: #000;
        border-color: rgba(255, 255, 255, .55);
    }

    .shop-assistant-launcher--compact:hover .shop-assistant-launcher__label {
        max-width: 240px;
        opacity: 1;
    }

    .shop-assistant-launcher:hover .shop-assistant-launcher__icon svg {
        transform: rotate(180deg);
    }
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
    .shop-assistant-launcher:focus-visible .shop-assistant-launcher__label {
        background: linear-gradient(110deg, #aaa 35%, #fff 48%, #fff 52%, #aaa 65%) 100% 0 / 250% 100%;
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
        animation: shop-assistant-text-light 2s linear infinite;
    }

    @media (hover: hover) and (pointer: fine) {
        .shop-assistant-launcher:hover .shop-assistant-launcher__label {
            background: linear-gradient(110deg, #aaa 35%, #fff 48%, #fff 52%, #aaa 65%) 100% 0 / 250% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: shop-assistant-text-light 2s linear infinite;
        }
    }
}

@keyframes shop-assistant-border-light {
    to { --shop-assistant-glow-angle: 360deg; }
}

@keyframes shop-assistant-text-light {
    from { background-position: 100% 0; }
    to { background-position: 0% 0; }
}

@media (max-width: 360px) {
    .shop-assistant .shop-assistant-launcher { font-size: 14px; }
    .shop-assistant .shop-assistant-launcher--home { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .shop-assistant-launcher::before,
    .shop-assistant .shop-assistant-launcher,
    .shop-assistant-launcher__icon,
    .shop-assistant-launcher__icon svg,
    .shop-assistant-launcher .shop-assistant-launcher__label {
        animation: none !important;
        transition: none !important;
    }

    .shop-assistant-launcher:is(:hover, :focus-visible) .shop-assistant-launcher__icon svg { transform: none; }
}

/* While the menu of a phone, a window or a dialog of the site is open, the assistant steps out of the way. */
body.no-overflow .shop-assistant,
body.modal-open .shop-assistant,
body.swal2-shown .shop-assistant {
    visibility: hidden;
}

/* The button to the top of the page stands above the button of the assistant, and leaves while the panel is open. */
body:has(.shop-assistant-launcher:not([hidden])) .scroll-top.show {
    bottom: calc(104px + var(--shop-assistant-lift, 0px));
}

body:has(.shop-assistant-panel:not([hidden])) .scroll-top {
    visibility: hidden;
    opacity: 0;
}

/* The panel ------------------------------------------------------------------------------------ */

.shop-assistant .shop-assistant-panel {
    position: fixed;
    left: auto;
    right: max(24px, env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: min(480px, calc(100vw - max(24px, env(safe-area-inset-left, 0px)) - max(24px, env(safe-area-inset-right, 0px))));
    height: min(720px, calc(100dvh - 48px - env(safe-area-inset-bottom, 0px)));
    overflow: hidden;
    border: 1px solid #ffffff2b;
    border-radius: 24px;
    background: #282828;
    color: #fff;
    box-shadow: 0 8px 32px #0003;
    font: 400 14px/1.5 Arial, Helvetica, sans-serif;
    text-align: start;
    color-scheme: dark;
}

.shop-assistant .shop-assistant-panel[data-expanded="true"] { width: min(720px, calc(100vw - max(24px, env(safe-area-inset-left, 0px)) - max(24px, env(safe-area-inset-right, 0px)))); }
.shop-assistant .shop-assistant-panel[hidden],
.shop-assistant .shop-assistant-launcher[hidden] { display: none; }
.shop-assistant-panel__header { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; padding: 20px; }
.shop-assistant-panel__mark { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 50%; background: #fff; color: #000; }
.shop-assistant-panel__mark svg { width: 24px; height: 24px; }
.shop-assistant .shop-assistant-panel__header h2 { flex: 1 1 auto; margin: 0; min-width: 0; color: #fff; font: 700 14px/20px Arial, Helvetica, sans-serif; letter-spacing: normal; text-transform: none; overflow-wrap: anywhere; }
.shop-assistant-panel__actions { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; margin-inline-start: auto; }
.shop-assistant .shop-assistant-panel__actions :is(a, button, summary) { display: grid; flex: 0 0 auto; place-items: center; width: 32px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; color: #fff; list-style: none; cursor: pointer; }
.shop-assistant .shop-assistant-panel__actions summary::-webkit-details-marker { display: none; }
.shop-assistant-panel__actions :is(a, button, summary):hover { background: #ffffff14; }
.shop-assistant-panel__actions svg { width: 20px; height: 20px; }
.shop-assistant .shop-assistant-panel__actions .shop-assistant-panel__close { width: 44px; height: 44px; margin-inline-start: 4px; border: 1px solid #fff; border-radius: 50%; background: #fff; color: #161616; cursor: pointer; }
.shop-assistant .shop-assistant-panel__actions .shop-assistant-panel__close:hover { background: #e8e8e8; border-color: #e8e8e8; }
.shop-assistant .shop-assistant-panel__actions .shop-assistant-panel__close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.shop-assistant-panel__close svg { display: block; width: 22px; height: 22px; }
.shop-assistant-menu { position: relative; }
.shop-assistant-menu > div { position: absolute; z-index: 2; top: 100%; inset-inline-end: 0; width: max-content; padding: 8px; border: 1px solid #ffffff2b; border-radius: 12px; background: #333; box-shadow: 0 4px 16px #0003; }
.shop-assistant .shop-assistant-menu > div > button { display: block; width: auto; height: auto; padding: 8px 12px; font: inherit; white-space: nowrap; }
.shop-assistant-panel__messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #888 transparent; padding: 8px 24px 16px; }
.shop-assistant-message { margin-bottom: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.shop-assistant-message--user { width: fit-content; max-width: 88%; margin-inline-start: auto; padding: 10px 14px; border-radius: 18px 18px 4px 18px; background: #ffffff14; }
.shop-assistant-message--pending { color: #bbb; }
.shop-assistant-message--error { color: #ffc5c5; }
.shop-assistant-products { display: grid; gap: 8px; margin: 0 0 20px; }
.shop-assistant .shop-assistant-products__more { display: block; width: 100%; padding: 16px; border: 1px solid #ffffff38; border-radius: 24px; background: transparent; color: #fff; font: 700 14px/20px Arial, Helvetica, sans-serif; text-align: start; cursor: pointer; }
.shop-assistant-products__more:hover { background: #ffffff14; }
.shop-assistant-card { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: start; gap: 16px; padding: 12px; border: 1px solid #ffffff24; border-radius: 24px; }
.shop-assistant-card[hidden] { display: none; }
.shop-assistant-card__media { position: relative; overflow: hidden; border-radius: 20px; background: #ffffff0f; aspect-ratio: 1; }
.shop-assistant .shop-assistant-card__media a { display: block; width: 100%; height: 100%; }
.shop-assistant-card__media img { display: block; width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; }
.shop-assistant-card__content { min-width: 0; display: flex; flex-direction: column; align-self: stretch; gap: 8px; }
.shop-assistant .shop-assistant-card__title { display: block; color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-assistant .shop-assistant-card__title:hover { color: #fff; }
.shop-assistant-card__color { color: #bbb; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-assistant-card__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 13px; }
.shop-assistant-card__price del { color: #ccc; font-size: 12px; }
.shop-assistant-card__price strong { color: #8ac675; font-weight: 700; }
.shop-assistant .shop-assistant-card__add { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 40px; margin-top: auto; padding: 8px 12px; border: 0; border-radius: 16px; background: #fff; color: #282828; font: 700 13px/20px Arial, Helvetica, sans-serif; text-decoration: none; cursor: pointer; }
.shop-assistant .shop-assistant-card__add:hover { color: #282828; background: #e8e8e8; }
.shop-assistant .shop-assistant-card__add:disabled { opacity: .6; cursor: default; }
.shop-assistant-card__add svg { width: 18px; height: 18px; }
.shop-assistant-card__stock { color: #bbb; font-size: 13px; }
.shop-assistant-panel__suggestions { display: flex; flex-wrap: wrap; flex: 0 0 auto; gap: 8px; max-height: 144px; overflow-y: auto; padding: 0 24px 16px; }
.shop-assistant .shop-assistant-panel__suggestions button { padding: 8px 16px; border: 1px solid #ffffff45; border-radius: 999px; background: transparent; color: #fff; font: inherit; text-align: start; cursor: pointer; }
.shop-assistant-panel__suggestions button:hover { background: #ffffff14; }
.shop-assistant .shop-assistant-panel__suggestions button:disabled { opacity: .6; cursor: default; }
.shop-assistant .shop-assistant-panel__status { margin: 0; padding: 0 24px 12px; color: #ffc5c5; font-size: 13px; }
.shop-assistant .shop-assistant-panel__status[hidden] { display: none; }
.shop-assistant-panel__composer { display: flex; align-items: flex-end; gap: 8px; flex: 0 0 auto; margin: 0 20px 20px; padding: 10px 12px 10px 18px; border: 1px solid #ffffff38; border-radius: 24px; }
.shop-assistant-panel__composer:focus-within { border-color: #ffffff80; }
.shop-assistant .shop-assistant-panel__composer textarea { flex: 1; min-width: 0; max-height: 100px; margin: 0; padding: 4px 0; resize: none; border: 0; outline: none; border-radius: 0; background: transparent; color: #fff; font: 400 14px/22px Arial, Helvetica, sans-serif; box-shadow: none; }
.shop-assistant .shop-assistant-panel__composer textarea::placeholder { color: #aaa; opacity: 1; }
.shop-assistant .shop-assistant-panel__composer button { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: #fff; color: #282828; cursor: pointer; }
.shop-assistant .shop-assistant-panel__composer button:disabled { opacity: .5; cursor: default; }
.shop-assistant-panel__composer svg { width: 20px; height: 20px; }

@media (max-width: 520px) {
    .shop-assistant .shop-assistant-panel,
    .shop-assistant .shop-assistant-panel[data-expanded="true"] { left: auto; right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - max(12px, env(safe-area-inset-left, 0px)) - max(12px, env(safe-area-inset-right, 0px))); height: min(720px, calc(100dvh - 24px - env(safe-area-inset-bottom, 0px))); border-radius: 20px; }
    .shop-assistant-panel__header { gap: 8px; padding: 16px 12px; }
    .shop-assistant-panel__mark { flex-basis: 36px; height: 36px; }
    .shop-assistant-panel__actions { gap: 0; }
    .shop-assistant .shop-assistant-panel__actions :is(a, button, summary) { width: 28px; }
    .shop-assistant-panel__messages { padding-inline: 16px; }
    .shop-assistant-card { grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 10px; border-radius: 20px; }
    .shop-assistant-panel__suggestions { padding-inline: 16px; }
    .shop-assistant-panel__composer { margin-inline: 12px; }
}
