/* AI Store Assistant - storefront chat */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

#aisa {
  --aisa-primary: #24B9D7;
  --aisa-accent: #F39D72;
  --aisa-black: #0B0D10;
  --aisa-green: #34D399;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#aisa.aisa--dark {
  --p-bg: #0F1318;
  --p-head: #12171D;
  --p-log: #0F1318;
  --p-card: #161C23;
  --p-card-hover: #1B232C;
  --p-line: #232B34;
  --p-text: #EEF2F5;
  --p-muted: #8D98A5;
  --p-bubble: #1B222B;
  --p-input: #1A2028;
  --p-shadow: 0 24px 60px rgba(0,0,0,.55);
}
#aisa.aisa--light {
  --p-bg: #FFFFFF;
  --p-head: #FFFFFF;
  --p-log: #F6F6F6;
  --p-card: #FFFFFF;
  --p-card-hover: #F6F6F6;
  --p-line: #E6E8EB;
  --p-text: #111418;
  --p-muted: #6B7380;
  --p-bubble: #FFFFFF;
  --p-input: #F6F6F6;
  --p-shadow: 0 24px 60px rgba(17,20,24,.18);
}
#aisa *, #aisa *::before, #aisa *::after { box-sizing: border-box; }
#aisa button { font-family: inherit; line-height: 1.2; }
#aisa [hidden] { display: none !important; }

/* Icons: protect from theme CSS that fills every svg */
#aisa svg { display: block; flex: none; fill: none !important; stroke: currentColor !important; overflow: visible; }
#aisa svg path, #aisa svg circle, #aisa svg line, #aisa svg polyline { fill: none !important; stroke: currentColor !important; }
#aisa svg .aisa-dotfill { fill: currentColor !important; stroke: none !important; }

/* ---------- Launcher ---------- */
.aisa-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483000;
  display: flex; align-items: center; gap: 14px;
  padding: 7px 26px 7px 7px; margin: 0;
  border: 1px solid rgba(255,255,255,.08); border-radius: 999px; cursor: pointer;
  color: #FFFFFF;
  background: linear-gradient(135deg, #1A2128 0%, var(--aisa-black) 100%);
  box-shadow: 0 14px 34px rgba(0,0,0,.35);
  animation: aisa-float 3.6s ease-in-out infinite;
  transition: transform .2s ease, box-shadow .2s ease;
}
.aisa-launcher::before {
  content: ""; position: absolute; inset: -6px; border-radius: 999px; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--aisa-primary) 45%, transparent), transparent);
  filter: blur(10px); animation: aisa-glow 2.8s ease-in-out infinite;
}
.aisa-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.aisa-launcher:focus-visible { outline: 3px solid var(--aisa-primary); outline-offset: 3px; }

.aisa-launcher__avatar {
  position: relative; flex: none; width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--aisa-primary); color: #FFFFFF;
  box-shadow: 0 0 0 3px var(--aisa-black), 0 0 0 5px var(--aisa-primary);
}
.aisa-launcher__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.aisa-launcher__avatar::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--aisa-primary); opacity: 0;
  animation: aisa-ring 2.2s ease-out infinite;
}
.aisa-launcher__dot {
  position: absolute; right: -1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--aisa-green); border: 2.5px solid var(--aisa-black); z-index: 1;
}
.aisa-launcher__text { font-size: 16px; font-weight: 700; letter-spacing: .1px; white-space: nowrap; }
.aisa-launcher__x { display: none; }

/* "Hi" bubble above the avatar */
.aisa-hi {
  position: absolute; left: 4px; bottom: calc(100% + 12px);
  padding: 7px 14px; border-radius: 16px 16px 16px 4px;
  background: var(--aisa-accent); color: #1A0F0A;
  font-size: 14px; font-weight: 700; white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(8px) scale(.85); transform-origin: left bottom;
  transition: opacity .3s ease, transform .35s cubic-bezier(.2,1.4,.4,1);
}
.aisa-hi::after {
  content: ""; position: absolute; left: 16px; top: 100%;
  border: 7px solid transparent; border-top-color: var(--aisa-accent); border-left-color: var(--aisa-accent);
  border-bottom: 0; border-right-width: 9px;
}
.aisa-hi.is-shown { opacity: 1; transform: none; animation: aisa-bob 2.6s ease-in-out .4s infinite; }

#aisa.is-open .aisa-launcher { animation: none; padding: 0; width: 60px; height: 60px; justify-content: center; }
#aisa.is-open .aisa-launcher::before,
#aisa.is-open .aisa-launcher__avatar,
#aisa.is-open .aisa-launcher__text,
#aisa.is-open .aisa-hi { display: none; }
#aisa.is-open .aisa-launcher__x { display: flex; }

/* ---------- Panel ---------- */
.aisa-panel {
  position: fixed; right: 24px; bottom: 100px; z-index: 2147483001;
  width: 460px; max-width: calc(100vw - 32px);
  height: 780px; max-height: calc(100vh - 116px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--p-bg); color: var(--p-text);
  border: 1px solid var(--p-line); border-radius: 22px;
  box-shadow: var(--p-shadow);
  animation: aisa-in .25s ease-out;
}
.aisa-grip { display: none; }

.aisa-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px;
  background: var(--p-head); border-bottom: 1px solid var(--p-line);
}
.aisa-head__text { flex: 1; min-width: 0; line-height: 1.25; }
.aisa-head__title { display: block; font-size: 16px; font-weight: 800; color: var(--p-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aisa-head__sub { display: block; font-size: 12px; color: var(--p-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aisa-iconbtn {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: transparent; color: var(--p-muted);
  transition: background .15s ease, color .15s ease;
}
.aisa-iconbtn:hover { background: color-mix(in srgb, var(--p-text) 8%, transparent); color: var(--p-text); }
.aisa-back { margin-right: -6px; }

/* Avatars */
.aisa-ava {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--aisa-primary), color-mix(in srgb, var(--aisa-primary) 60%, #0B3B47));
  color: #FFFFFF; font-weight: 800; font-size: 17px;
}
.aisa-ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.aisa-head__ava::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--aisa-green); border: 2px solid var(--p-head);
}

/* ---------- Views ---------- */
.aisa-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.aisa-view--pick {
  padding: 22px 18px; overflow-y: auto;
  background: radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--aisa-primary) 9%, transparent), transparent 70%), var(--p-log);
}

.aisa-pick {
  padding: 20px 16px 16px; border-radius: 18px;
  background: color-mix(in srgb, var(--p-card) 70%, transparent);
  border: 1px solid var(--p-line);
}
.aisa-pick__title { margin: 0 0 6px; text-align: center; font-size: 17px; font-weight: 800; color: var(--p-text); line-height: 1.3; }
.aisa-pick__note { margin: 0 0 4px; text-align: center; font-size: 13px; line-height: 1.45; color: var(--aisa-primary); }
.aisa-agents { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.aisa-agent {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 12px 12px 12px; border-radius: 16px; cursor: pointer;
  background: var(--p-card); color: var(--p-text);
  border: 1px solid var(--p-line);
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.aisa-agent:hover { background: var(--p-card-hover); border-color: color-mix(in srgb, var(--aisa-primary) 55%, var(--p-line)); transform: translateY(-1px); }
.aisa-agent.is-active { border-color: var(--aisa-primary); background: color-mix(in srgb, var(--aisa-primary) 10%, var(--p-card)); }
.aisa-agent__ava { width: 50px; height: 50px; }
.aisa-agent__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.aisa-agent__name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 15px; font-weight: 800; }
.aisa-agent__sub { font-size: 13px; color: var(--p-muted); line-height: 1.35; }
.aisa-agent.is-active .aisa-agent__sub { color: var(--aisa-primary); font-weight: 600; }
.aisa-agent__chev { flex: none; color: var(--p-muted); display: flex; }

.aisa-tag {
  display: inline-flex; align-items: center; gap: 5px; font-style: normal;
  font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; line-height: 1.5;
}
.aisa-tag--active { color: var(--aisa-accent); background: color-mix(in srgb, var(--aisa-accent) 15%, transparent); }
.aisa-tag--active i { width: 6px; height: 6px; border-radius: 50%; background: var(--aisa-accent); animation: aisa-blink 1.4s ease-in-out infinite; }

/* ---------- Chat ---------- */
.aisa-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 10px;
  display: flex; flex-direction: column; gap: 14px;
  background: radial-gradient(120% 50% at 50% 0%, color-mix(in srgb, var(--aisa-primary) 7%, transparent), transparent 70%), var(--p-log);
  scroll-behavior: smooth;
}
.aisa-day { text-align: center; }
.aisa-day span {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--p-muted);
  padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--p-text) 7%, transparent);
}
.aisa-row { display: flex; align-items: flex-end; gap: 9px; max-width: 100%; animation: aisa-msg .25s ease-out; }
.aisa-row.is-user { justify-content: flex-end; }
.aisa-row__ava { width: 30px; height: 30px; font-size: 13px; margin-bottom: 18px; }
.aisa-col { display: flex; flex-direction: column; min-width: 0; max-width: 84%; }
.aisa-row.is-user .aisa-col { align-items: flex-end; max-width: 80%; }
.aisa-msg {
  padding: 11px 15px; border-radius: 18px; border-bottom-left-radius: 6px;
  background: var(--p-bubble); color: var(--p-text);
  border: 1px solid var(--p-line);
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.aisa-msg a { color: var(--aisa-primary); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.aisa-msg strong { font-weight: 800; }
.aisa-row.is-user .aisa-msg {
  background: var(--aisa-primary); color: #04161B; border: 0;
  border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; font-weight: 500;
}
.aisa-row.is-error .aisa-msg { border-color: #E05A5A; color: #E86A6A; }
.aisa-meta { font-size: 11px; color: var(--p-muted); margin: 5px 4px 0; }

/* Typing dots */
.aisa-typing .aisa-msg { display: flex; gap: 5px; padding: 14px 16px; }
.aisa-typing .aisa-msg span { width: 7px; height: 7px; border-radius: 50%; background: var(--p-muted); animation: aisa-dot 1.2s infinite ease-in-out; }
.aisa-typing .aisa-msg span:nth-child(2) { animation-delay: .15s; }
.aisa-typing .aisa-msg span:nth-child(3) { animation-delay: .3s; }
.aisa-typing .aisa-row__ava { margin-bottom: 0; }

/* Quick replies */
.aisa-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 39px; }
.aisa-chips button {
  border: 1px solid color-mix(in srgb, var(--aisa-primary) 60%, transparent); border-radius: 999px; cursor: pointer;
  padding: 7px 14px; font-size: 13px; font-weight: 700;
  background: color-mix(in srgb, var(--aisa-primary) 10%, transparent); color: var(--aisa-primary);
  transition: background .15s ease, color .15s ease;
}
.aisa-chips button:hover { background: var(--aisa-primary); color: #04161B; }

/* Product cards */
.aisa-cards { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.aisa-products { display: flex; flex-direction: column; gap: 8px; }
.aisa-card {
  flex: none; width: 156px; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  border-radius: 14px; background: var(--p-card); border: 1px solid var(--p-line);
  transition: border-color .15s ease;
}
.aisa-card:hover { border-color: var(--aisa-primary); }
.aisa-card__link { display: flex; flex-direction: column; gap: 6px; color: var(--p-text) !important; text-decoration: none !important; }
.aisa-card__add, .aisa-addall, .aisa-note__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; cursor: pointer; padding: 8px 10px;
  background: var(--aisa-primary); color: #04161B !important; text-decoration: none !important;
  font-size: 12.5px; font-weight: 800; line-height: 1.2;
  transition: filter .15s ease, opacity .15s ease;
}
.aisa-card__add:hover, .aisa-addall:hover, .aisa-note__btn:hover { filter: brightness(1.08); }
.aisa-card__add.is-busy, .aisa-addall.is-busy { opacity: .6; cursor: progress; }
.aisa-card__add.is-done, .aisa-addall.is-done { background: var(--aisa-green); }
.aisa-addall { align-self: flex-start; padding: 9px 14px; font-size: 13px; border-radius: 999px; }
.aisa-note {
  align-self: center; max-width: 92%; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.45;
  background: color-mix(in srgb, var(--aisa-green) 12%, var(--p-card)); color: var(--p-text);
  border: 1px solid color-mix(in srgb, var(--aisa-green) 45%, var(--p-line));
  animation: aisa-msg .25s ease-out;
}
.aisa-note.is-error { background: var(--p-card); border-color: #E05A5A; }
.aisa-note__btn { border-radius: 999px; padding: 8px 14px; }
.aisa-card img, .aisa-card__noimg { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 10px; background: #FFFFFF; display: block; }
.aisa-card__name { font-size: 12.5px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 33px; }
.aisa-card__row { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 13px; }
.aisa-card__row b { color: var(--aisa-primary); font-weight: 800; }
.aisa-card__row small { font-size: 11px; color: var(--p-muted); font-weight: 600; }
.aisa-card__row small.is-out { color: #E86A6A; }

/* Composer */
.aisa-emoji {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px 12px;
  background: var(--p-head); border-top: 1px solid var(--p-line);
}
.aisa-emoji button { border: 0; background: transparent; font-size: 22px; padding: 6px; border-radius: 8px; cursor: pointer; }
.aisa-emoji button:hover { background: color-mix(in srgb, var(--p-text) 8%, transparent); }
.aisa-form {
  display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 14px;
  background: var(--p-head); border-top: 1px solid var(--p-line); margin: 0;
}
.aisa-emoji-btn { color: var(--aisa-accent); width: 40px; height: 44px; }
.aisa-input {
  flex: 1; min-width: 0; resize: none; max-height: 120px; min-height: 44px; height: 44px;
  overflow-y: hidden; -webkit-appearance: none; appearance: none; box-shadow: none; margin: 0;
  padding: 11px 16px; border-radius: 22px; border: 1px solid var(--p-line);
  background: var(--p-input); color: var(--p-text);
  font: inherit; font-size: 14.5px; line-height: 1.45; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.aisa-input::placeholder { color: var(--p-muted); }
.aisa-input:focus { border-color: var(--aisa-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--aisa-primary) 20%, transparent); }
.aisa-send {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--aisa-primary); color: #04161B;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--aisa-primary) 40%, transparent);
  transition: transform .15s ease, opacity .15s ease;
}
.aisa-send:hover { transform: translateY(-1px); }
.aisa-send:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .aisa-launcher { right: 14px; bottom: 14px; padding: 6px 18px 6px 6px; gap: 11px; }
  .aisa-launcher__avatar { width: 46px; height: 46px; }
  .aisa-launcher__text { font-size: 15px; }
  .aisa-panel {
    right: 0; left: 0; bottom: 0; top: auto; width: 100%; max-width: 100%;
    height: 92vh; height: 92dvh; max-height: none;
    border-radius: 22px 22px 0 0; border-bottom: 0;
    animation: aisa-up .28s ease-out;
  }
  .aisa-grip { display: block; width: 44px; height: 5px; border-radius: 3px; margin: 8px auto 0; background: color-mix(in srgb, var(--p-text) 25%, transparent); flex: none; }
  .aisa-head { padding-top: 8px; }
  #aisa.is-open .aisa-launcher { display: none; }
  .aisa-input { font-size: 16px; }
  html.aisa-lock, html.aisa-lock body { overflow: hidden; }
}

/* ---------- Animations ---------- */
@keyframes aisa-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes aisa-glow { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes aisa-ring { 0% { transform: scale(.92); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes aisa-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes aisa-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes aisa-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes aisa-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes aisa-msg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes aisa-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  #aisa *, #aisa *::before, #aisa *::after { animation: none !important; transition: none !important; }
  .aisa-hi.is-shown { opacity: 1; transform: none; }
}

/* Older browsers without color-mix */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .aisa-launcher::before { background: radial-gradient(closest-side, rgba(36,185,215,.45), transparent); }
  .aisa-pick, .aisa-agent.is-active { background: var(--p-card); }
  .aisa-day span { background: rgba(127,127,127,.15); }
  .aisa-note { background: var(--p-card); }
  .aisa-tag--active { background: rgba(243,157,114,.15); }
  .aisa-chips button { background: transparent; border-color: var(--aisa-primary); }
  .aisa-iconbtn:hover, .aisa-emoji button:hover { background: rgba(127,127,127,.15); }
  .aisa-ava { background: var(--aisa-primary); }
  .aisa-view--pick, .aisa-log { background: var(--p-log); }
  .aisa-input:focus { box-shadow: none; }
  .aisa-send { box-shadow: none; }
}
