/* Chat assistant widget — resources/views/frontend/includes/chat-widget.blade.php + assets/js/chat.js.
   Palette follows the shop overlay: indigo→red gradient, gold accent, white text. */

/* The site's own Noto fonts: Georgian glyphs from Noto Sans Georgian (fetched only when
   Georgian text appears), Latin + Cyrillic from Noto Sans. */
@font-face {
    font-family: 'UsaChatGeorgian';
    src: url("../fonts/NotoSansGeorgianRegular.woff2") format("woff2"),
         url("../fonts/NotoSansGeorgianRegular.woff") format("woff");
    unicode-range: U+10A0-10FF, U+1C90-1CBF, U+2D00-2D2F;
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'UsaChatSans';
    src: url("../fonts/NotoSansRegular.woff2") format("woff2"),
         url("../fonts/NotoSansRegular.woff") format("woff");
    font-weight: normal; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'UsaChatSans';
    src: url("../fonts/NotoSansBold.woff2") format("woff2"),
         url("../fonts/NotoSansBold.woff") format("woff");
    font-weight: bold; font-style: normal; font-display: swap;
}

.usa-chat {
    --uc-gradient: linear-gradient(146deg, #443cd6, #c72a2a);
    --uc-gold: #f3d27a;
    --uc-gold-ink: #5a2410;
    --uc-panel: #17141f;
    --uc-line: rgba(255,255,255,.12);
    --uc-soft: rgba(255,255,255,.08);
    --uc-muted: rgba(255,255,255,.6);

    position: fixed; right: 24px; bottom: 24px;
    z-index: 150;                 /* above page content (#shop 100), below the menu (160) and shop overlay (200) */
    font-family: 'UsaChatGeorgian', 'UsaChatSans', system-ui, sans-serif;
    color: #fff; line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
.usa-chat *, .usa-chat *::before, .usa-chat *::after { box-sizing: border-box; }

/* Out of the way while the menu drawer or the shop is open. */
body.hide-overflow .usa-chat,
body.shop-overlay-lock .usa-chat { display: none; }

/* --- Launcher --- */
.usa-chat-toggle {
    width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0;
    background: var(--uc-gradient); color: #fff; cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 10px 28px -8px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.18) inset;
    transition: transform .2s ease, box-shadow .2s ease;
}
.usa-chat-toggle:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -8px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.3) inset; }
.usa-chat-toggle:focus-visible { outline: 2px solid var(--uc-gold); outline-offset: 3px; }
.usa-chat-toggle svg { width: 26px; height: 26px; display: block; }
.usa-chat.usa-chat-open .usa-chat-toggle { display: none; }

/* --- Panel --- */
.usa-chat-panel {
    position: absolute; right: 0; bottom: 0;
    width: 370px; height: 560px;
    max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--uc-panel); border-radius: 18px;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.75), 0 0 0 1px var(--uc-line);
    transform-origin: bottom right;
    animation: usa-chat-in .22s cubic-bezier(.165,.84,.44,1);
}
.usa-chat-panel[hidden] { display: none; }
@keyframes usa-chat-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.usa-chat-head {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
    padding: 14px 12px 14px 18px; background: var(--uc-gradient);
}
.usa-chat-title { flex: 1 1 auto; min-width: 0; }
.usa-chat-title strong { display: block; font-family: "abril_fatfaceregular", "UsaChatGeorgian", serif; font-weight: 400; font-size: 19px; letter-spacing: .02em; line-height: 1.2; }
.usa-chat-title span { display: block; font-size: 12.5px; color: rgba(255,255,255,.78); }
.usa-chat-icon-btn {
    flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 50%;
    background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center;
    transition: background .15s ease;
}
.usa-chat-icon-btn:hover { background: rgba(255,255,255,.16); }
.usa-chat-icon-btn:focus-visible { outline: 2px solid var(--uc-gold); outline-offset: 1px; }
.usa-chat-icon-btn svg { width: 18px; height: 18px; display: block; }

.usa-chat-log {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    padding: 18px 16px; display: flex; flex-direction: column; gap: 10px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
}
.usa-msg {
    max-width: 86%; padding: 9px 13px; border-radius: 14px;
    font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.usa-msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.usa-msg-bot { align-self: flex-start; background: var(--uc-soft); border-bottom-left-radius: 4px; }
.usa-msg-user { align-self: flex-end; background: var(--uc-gold); color: var(--uc-gold-ink); border-bottom-right-radius: 4px; }
.usa-msg-notice { align-self: center; max-width: 92%; background: transparent; border: 1px solid var(--uc-line); color: var(--uc-muted); font-size: 13.5px; text-align: center; }
.usa-msg-typing { color: var(--uc-muted); }
.usa-msg-typing::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: usa-chat-dots 1.2s steps(4) infinite; }
@keyframes usa-chat-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* --- Replies that list wines: text + product cards --- */
.usa-msg-rich { max-width: 94%; display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.usa-msg-text { white-space: pre-wrap; padding: 0 1px; }
.usa-products { display: flex; flex-direction: column; gap: 10px; white-space: normal; }
.usa-product {
    display: flex; align-items: center; gap: 14px;
    padding: 8px 14px 8px 10px;
    background: rgba(255,255,255,.05); border: 1px solid var(--uc-line); border-radius: 12px;
}
.usa-product-img {
    flex: 0 0 auto; width: 36px; height: 76px; object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,.45));
}
.usa-product-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.usa-product-name { font-weight: bold; font-size: 16.5px; line-height: 1.25; color: #fff; }
.usa-product-note { font-size: 13px; line-height: 1.4; color: var(--uc-muted); }
.usa-product-price { flex: 0 0 auto; font-weight: bold; font-size: 18px; color: var(--uc-gold); white-space: nowrap; }
.usa-product-off .usa-product-img { opacity: .45; filter: grayscale(.7); }
.usa-product-off .usa-product-price { font-weight: normal; font-size: 12.5px; color: var(--uc-muted); }

/* --- Suggested questions: outlined gold chips, clearly not messages --- */
.usa-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 0; }
.usa-suggestion {
    border: 1px solid rgba(243,210,122,.6); border-radius: 999px; background: transparent;
    color: var(--uc-gold); font: inherit; font-size: 13.5px; line-height: 1.3;
    padding: 7px 14px; cursor: pointer; text-align: left;
    transition: background .15s ease, border-color .15s ease;
}
.usa-suggestion:hover { background: rgba(243,210,122,.12); border-color: var(--uc-gold); }
.usa-suggestion:focus-visible { outline: 2px solid var(--uc-gold); outline-offset: 2px; }

.usa-chat-form {
    flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
    margin: 0 12px 12px; padding: 8px 8px 8px 14px;
    background: var(--uc-soft); border-radius: 14px; border: 1px solid transparent;
    transition: border-color .15s ease;
}
.usa-chat-form:focus-within { border-color: rgba(243,210,122,.55); }
.usa-chat-input {
    flex: 1 1 auto; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
    color: #fff; font: inherit; font-size: 16px;   /* 16px: stops iOS zooming into the field */
    line-height: 1.4; min-height: 34px; max-height: 120px; padding: 6px 0; margin: 0;
}
.usa-chat-input::placeholder { color: rgba(255,255,255,.45); }
.usa-chat-send {
    flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: var(--uc-gold); color: var(--uc-gold-ink); cursor: pointer;
    display: grid; place-items: center; transition: opacity .15s ease, transform .15s ease;
}
.usa-chat-send:hover { transform: scale(1.06); }
.usa-chat-send:disabled { opacity: .4; cursor: default; transform: none; }
.usa-chat-send:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.usa-chat-send svg { width: 18px; height: 18px; display: block; }


.usa-chat .usa-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phone: the panel takes the whole screen. */
@media (max-width: 600px) {
    .usa-chat { right: 16px; bottom: 16px; }
    .usa-chat.usa-chat-open { inset: 0; }
    /* Sized to the visible viewport (set by chat.js), so the input stays just above the
       on-screen keyboard instead of hiding under it. */
    .usa-chat-panel {
        position: fixed; left: 0; right: 0; bottom: auto;
        top: var(--uc-vtop, 0); height: var(--uc-vh, 100dvh);
        width: auto; max-height: none;
        border-radius: 0; animation: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
}

@media (prefers-reduced-motion: reduce) {
    .usa-chat-panel, .usa-chat-toggle, .usa-chat-send { animation: none; transition: none; }
}

/* Typing effect (chat.js typeOut): words and cards are laid out from the start, invisible,
   and fade in one by one where they'll stay — so the bubble doesn't jump as it "types". */
.usa-w { opacity: 0; transition: opacity .24s ease-out; }
.usa-w.usa-in { opacity: 1; }
.usa-product.usa-w { transform: translateY(6px); transition: opacity .32s ease-out, transform .32s cubic-bezier(.165,.84,.44,1); }
.usa-product.usa-w.usa-in { transform: none; }
@media (prefers-reduced-motion: reduce) { .usa-w, .usa-product.usa-w { opacity: 1; transform: none; transition: none; } }
