/* ============================================
   AI assistant — floating button + chat panel
   ============================================ */

.asst-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 48px;
  padding: 0 18px 0 12px;
  border: 0;
  border-radius: 24px;
  background: var(--blue);
  color: #FFFFFF;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(19, 32, 44, 0.18), 0 1px 2px rgba(19, 32, 44, 0.12);
  transition: background .2s, transform .2s;
}
.asst-fab:hover { background: var(--blue-deep); transform: translateY(-1px); }
.asst-fab:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.asst-fab__mark { width: 24px; height: 24px; filter: brightness(0) invert(1); }
.asst-fab svg { width: 22px; height: 22px; }
.asst-fab[data-open] { padding: 0; width: 48px; justify-content: center; }
.asst-fab[data-open] .asst-fab__label,
.asst-fab[data-open] .asst-fab__mark { display: none; }

.asst {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 901;
  width: 400px;
  height: min(640px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(19, 32, 44, 0.28);
  overflow: hidden;
  font-family: var(--sans);
  color: var(--ink);
  animation: asstIn .22s cubic-bezier(.22, 1, .36, 1);
}
.asst[hidden] { display: none; }
@keyframes asstIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.asst__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--blue);
  color: #FFFFFF;
}
.asst__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}
.asst__avatar img { width: 22px; height: 22px; filter: brightness(0) invert(1); }
.asst__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.asst__titles strong { font-family: var(--serif); font-weight: 500; font-size: 16px; }
.asst__titles span { font-size: 12px; opacity: .8; }
.asst__btn {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #FFFFFF;
  border-radius: 8px;
  height: 32px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.asst__btn:hover { background: rgba(255, 255, 255, 0.12); }
.asst__btn--icon { width: 32px; padding: 0; display: grid; place-items: center; }
.asst__btn svg { width: 16px; height: 16px; }

.asst__list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: var(--paper-warm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.asst-msg { display: flex; }
.asst-msg--user { justify-content: flex-end; }
.asst-msg__bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.asst-msg--assistant .asst-msg__bubble { background: var(--paper); border: 1px solid var(--line-soft); border-top-left-radius: 4px; }
.asst-msg--user .asst-msg__bubble { background: var(--blue); color: #FFFFFF; border-top-right-radius: 4px; white-space: pre-wrap; }
.asst-msg[data-error] .asst-msg__bubble { background: var(--terra-soft); border-color: var(--terra-soft); color: var(--terra-ink); }
.asst-msg__bubble p { margin: 0 0 6px; }
.asst-msg__bubble p:last-child { margin-bottom: 0; }
.asst-msg__bubble ul, .asst-msg__bubble ol { margin: 4px 0 8px 20px; }
.asst-msg__bubble li { margin: 2px 0; }
.asst-msg__bubble a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.asst-msg__bubble .asst-h { margin-top: 6px; }

.asst-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.asst-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: asstDot 1.2s infinite ease-in-out; }
.asst-typing i:nth-child(2) { animation-delay: .15s; }
.asst-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes asstDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* product cards */
.asst-products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.asst-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
}
.asst-card__img { display: block; aspect-ratio: 4 / 3; background: var(--paper-2); }
.asst-card__img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.asst-card__body { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; }
.asst-card__cat { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.asst-card__cat i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.asst-card__name { color: var(--ink); font-weight: 500; text-decoration: none; line-height: 1.35; }
.asst-card__name:hover { color: var(--blue); }
.asst-card__meta { font-size: 11.5px; color: var(--muted); }
.asst-card__price { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.asst-card__note { font-size: 11.5px; color: var(--ochre-ink); }
.asst-card__actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.asst-card__actions a, .asst-card__actions button {
  flex: 1;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.asst-card__actions a { border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
.asst-card__actions a:hover { border-color: var(--blue); color: var(--blue); }
.asst-card__actions button { border: 0; background: var(--blue); color: #FFFFFF; }
.asst-card__actions button:hover { background: var(--blue-deep); }
.asst-card__actions button.is-added { background: var(--green); }
.asst-card__actions button:disabled { opacity: .6; cursor: default; }

.asst-orders { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.asst-orders strong { display: block; margin-bottom: 6px; font-weight: 500; }
.asst-orders ul { list-style: none; margin: 0; padding: 0; }
.asst-orders li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.asst-orders a { color: var(--blue); }
.asst-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--slate-soft); color: var(--slate); }
.asst-status[data-status="ready"], .asst-status[data-status="delivered"] { background: var(--green-soft); color: var(--green); }
.asst-status[data-status="cancelled"] { background: var(--line-soft); color: var(--muted); }
.asst-status[data-status="pending"] { background: var(--ochre-soft); color: var(--ochre-ink); }

.asst-note { font-size: 12.5px; color: var(--green); background: var(--green-soft); border-radius: 10px; padding: 8px 12px; }

.asst-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; }
.asst-suggest button {
  max-width: 92%;
  text-align: left;
  border: 1px solid var(--blue-soft);
  background: var(--paper);
  color: var(--blue);
  border-radius: 14px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.asst-suggest button:hover { background: var(--blue-soft); }

.asst__form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--paper); }
.asst__form textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
}
.asst__form textarea:focus { outline: none; border-color: var(--blue); }
.asst__send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.asst__send:disabled { opacity: .45; cursor: default; }
.asst__send svg { width: 18px; height: 18px; }
.asst__disclaimer { padding: 0 14px 10px; font-size: 11px; color: var(--muted); background: var(--paper); text-align: center; }

@media (max-width: 560px) {
  .asst-fab { right: 16px; bottom: 16px; padding: 0; width: 48px; justify-content: center; }
  .asst-fab__label { display: none; }
  .asst {
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    border: 0;
    height: 100dvh;
  }
  body.asst-open .asst-fab { display: none; }
  body.asst-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .asst, .asst-typing i { animation: none; }
}
