:root {
    /* palette */
    --bg-1: rgba(0, 0, 0, 0.8);
    /* light tint */
    --bg-2: rgba(0, 0, 0, 0.9);
    /* darker tint */
    --glass: rgba(255, 255, 255, 0.1);
    /* translucent white */
    --thumb: #666;
    --user-bg: rgba(255, 255, 255, 0.2);
    --user-color: #fff;
    --bot-bg: none;
    --widget-bg: transparent;
    --messageTime: 4s;
    --colorError: #d14217;
    --colorInfo: #FDF3AA;
}

html,
body {
    margin: 0;
    height: 100%;
}

html,
body {
    direction: rtl;
    font-family: "Assistant", Helvetica, sans-serif;
    color: #fff;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

#chatReset {
    cursor: pointer;
    position: fixed;
    z-index: 10;
    top: 1.2rem;
    left: 4rem;
    height: 1.2rem;
    width: 1.2rem;
    padding: 0;
    margin: 0;
    appearance: none;
    background: none;
    border: none;
    transition: top 0.3s ease;
}

#chat {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#composer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    transition: padding-bottom 0.3s ease, bottom 0.3s ease;
    box-shadow: 0 0 2rem 0 rgba(0, 0, 0, .5);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(18px) saturate(120%);
}

#chatInput::placeholder {
    color: 666;
}

body.isMobile #composer {
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 1rem 1rem 0 0;
}

body.isMobile #chatInput {
    padding-bottom: 1rem;
}

body:not(.isMobile) #composer {
    border-radius: 1rem;
    width: calc(min(95vw, 900px) - 4rem);
    margin: 2rem auto;
}

#chatSubmit {
    position: absolute;
    left: 0;
    top: 0;
    height: 1.2rem;
    width: 1.2rem;
    padding: 1rem 1rem 2rem;
}

body.initializing #chat,
body.initializing #splash {
    opacity: 0;
    visibility: hidden
}

body.isThinking #chatSubmit {
    animation: blink 1.5s infinite;
    opacity: .5;
}

#chatWrap {
    position: fixed;
    flex: 1;
    inset: 0;
    padding-bottom: 5rem;
    box-sizing: border-box;
    overflow: auto;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;

    background: linear-gradient(0deg, var(--bg-1) 0%, var(--bg-2) 100%);
    backdrop-filter: blur(10px) saturate(120%);

    -webkit-overflow-scrolling: touch;
    /* native momentum */
    overscroll-behavior: contain;
    /* no bounce-through to body */
    scrollbar-width: thin;
    scrollbar-color: var(--thumb) transparent;
}

#chatWrap::-webkit-scrollbar {
    width: 8px;
}

#chatWrap::-webkit-scrollbar-thumb {
    background: var(--thumb);
    border-radius: 4px;
    opacity: 0;
}

#chatWrap:hover::-webkit-scrollbar-thumb {
    opacity: 1;
}

body.isMobile.locked #chatWrap {
    padding-top: 40vh;
}

body.isMobile.locked #messages {
    padding-top: 17vh;
}

#messages {
    min-height: calc(100vh - 20rem);
    width: min(95vw, 900px);
    margin: 0 auto;
    padding: 2rem;
    box-sizing: border-box;
}

/* ==== BUBBLES ==== */
.bubble {
    max-width: min(620px, 75%);
    width: fit-content;
    padding: 0.8rem 1rem;
    margin: 4px 0;
    border-radius: 2em;
    white-space: pre-wrap;
    line-height: 1.45;
    word-break: break-word;
    animation: slideIn .25s ease-out both;
}

/* subtle glass on bubbles */
.bubble.user {
    background: var(--user-bg);
    color: var(--user-color);
    margin-left: auto;
    backdrop-filter: blur(10px) saturate(120%);
}

.bubble.model {
    background: var(--bot-bg);
}

.loader {
    opacity: .6;
    font-style: italic;
    animation: pulse 1s infinite;
}

.bubble:last-child {
    margin-bottom: 10rem;
}

/* ==== WIDGETS ==== */
.products-widget {
    margin: 1rem 0;
    padding: 0;
    width: 100vw;
    margin-right: calc((100% - 100vw) / 2);
    box-sizing: border-box;
}

.products-widget-title {
    font-weight: 700;
    width: min(95vw, 900px);
    margin: 0 auto;
    padding: 0 3rem 1rem;
    box-sizing: border-box;
}

.products-widget-rail {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 4px;
}

.products-widget-rail::-webkit-scrollbar {
    height: 6px;
}

.products-widget-rail::-webkit-scrollbar-thumb {
    background: var(--thumb);
    border-radius: 3px;
}

.products-widget-card {
    min-width: 120px;
    max-width: 160px;
    flex: 0 0 auto;
    color: #222;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform .15s ease-out;
}

.products-widget-card:first-child {
    margin-right: calc(((100vw - min(95vw, 900px)) / 2) + 3rem);
}

.products-widget-card:last-child {
    margin-left: 1rem;
}

/*.widget-card:hover{transform:scale(1.05);}*/
.products-widget-card img {
    display: block;
    width: 100%;
    height: fit-content;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.products-widget-card div {
    padding: 2px;
}

.products-widget-card.isLoading {
    animation: blink 0.45s ease-out both infinite;
}

.products-widget-card.has-special-price .card-price {
    text-decoration: line-through;
}

.bubble.loader {
    opacity: .4;
    animation: blink 1.5s infinite;
}

/* ==== SPLASH ==== */
.isSplash #composer {
    bottom: -5.5rem !important;
}

.isSplash #chatReset {
    top: -2rem;
}

#splash {
    position: fixed;
    inset: 0;
    z-index: 999;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity .45s ease-out, visibility .45s ease-out;
}

body:not(.isSplash) #splash {
    display: none;
}

img.disabled {
    opacity: .3;
}

input[type="text"].disabled {
    background: #bfbfbf;
}

#logo {
    width: 250px;
    animation: pop .6s ease-out both;
    text-align: center;
    direction: ltr;
}

#logo img {
    margin-bottom: 10px;
}

.search-input {
    display: block;
    outline: none;
    background: none;
}

#firstInput {
    width: 100%;
    box-sizing: border-box;
    padding: 0.9rem 3rem;
    border-radius: 2em;
    border: none;
    font-size: 18px;
    text-align: center;
    background: var(--glass);
    backdrop-filter: blur(18px) saturate(120%);
    color: #fff;
}

#chatInput {
    flex: 1;
    font-size: 1rem;
    padding: 1rem 1rem 1rem 4rem;
    ;
    border: none;
}

#firstWrap {
    position: relative;
    margin-top: 28px;
    width: min(340px, 80%);
    max-width: 440px;
}

#firstInput::placeholder {
    color: #ccc;
}

#firstSubmit {
    position: absolute;
    left: 0;
    top: 0;
    height: 1.2rem;
    width: 1.2rem;
    padding: 1rem;
    filter: invert(1);
}

.modal-overlay,
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 999;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity .45s ease-out, visibility .45s ease-out;
    opacity: 0;
    visibility: hidden;
    background: var(--bg-1);
}

.page-loader.active {
    opacity: 1;
    visibility: visible;
}

.loader-wrap {
    position: relative;
    border: 2px solid var(--bg-2);
    border-top: 2px solid var(--glass);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    animation: spin 2s linear infinite;
}

.modal-overlay {

    backdrop-filter: blur(18px);
}

body.has-modal .modal-overlay {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: relative;
    transform: scale(0);
    max-width: 100%;
    transition-duration: 250ms;
    transition-property: transform, opacity, visibility;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.modal-content-wrapper {

    background: rgba(0, 0, 0, .1);
    text-align: center;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 0 4px 2px rgba(255, 255, 255, .2);
}

.modal-actions {

    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal-actions .button {
    padding: .5rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.modal-actions .button.primary {
    background: var(--glass);
    color: #fff;
}

.modal-actions .button.secondary {
    background: var(--glass);
    color: #fff;
}

.modal-header:empty,
.modal-body:empty,
.modal-actions:empty {
    display: none;
}

.modal-header {
    margin-bottom: 1rem;

    font-size: 1.2rem;
    font-weight: 700;
}

.modal-body {
    margin-bottom: 1rem;
}

.page-messages {

    position: fixed;
    bottom: 5.5rem;
    left: 50%;

    width: fit-content;
    max-width: calc(100% - 2rem);

    z-index: 20;
    transform: translateX(-50%);
}

.message {
    --box-shadow-color: rgba(255, 255, 255, 0.2)
    position: relative;
    padding: .75rem;
    margin: 1.25rem;
    text-align: center;
    border-radius: 10px;

    background: var(--bg-2);
    box-shadow: 0 0 2px 1px var(--box-shadow-color);
    animation: messageAnimation var(--messageTime);
    animation-fill-mode: forwards;
}

.message.fail {
    color: var(--colorError);
    --box-shadow-color: var(--colorError);
}

.message.info {
    color: var(--colorInfo);
    --box-shadow-color: var(--colorInfo);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes blink {
    0% {
        opacity: .4;
    }

    50% {
        opacity: .6;
    }

    100% {
        opacity: .4;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

@keyframes messageAnimation {
    0% {
        opacity: 0;
        -webkit-transform: translateY(999%);
        transform: translateY(999%);
    }

    6%,
    94% {
        opacity: 1;
        -webkit-transform: translateY(0%);
        transform: translateY(0%);
    }

    100% {
        opacity: 0;
        -webkit-transform: translateY(999%);
        transform: translateY(999%);
    }
}