/* assets/wally-chat.css — trợ lý Wally (chatbot tra cứu, góc phải-dưới mọi trang laci.vn).
   Widget tĩnh, không gọi mạng. Toàn bộ style bọc trong .wally-chat để không ảnh hưởng trang. */

.wally-chat {
  --wc-night: #0e1a16;
  --wc-night-2: #091310;
  --wc-cream: #f1eee6;
  --wc-muted: rgba(241, 238, 230, .62);
  --wc-line: rgba(241, 238, 230, .16);
  --wc-gold: #c4a36d;
  --wc-purple: #6b4da8;
  --wc-yellow: #f2c14e;

  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(26px, env(safe-area-inset-bottom));
  width: 60px;   /* khung neo cố định — panel banh ra từ góc dưới-phải của khung này */
  height: 60px;
  z-index: 9990;
  font-family: Manrope, "DM Sans", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.55;
}

/* ---------- launcher ---------- */
.wally-chat__launcher {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  position: relative;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 8px 15px rgba(0, 0, 0, .42));
  transition: transform .22s cubic-bezier(.2, .75, .2, 1);
}
.wally-chat__launcher::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(107, 77, 168, .34), rgba(107, 77, 168, 0) 70%);
  z-index: -1;
}
.wally-chat__launcher img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.wally-chat__launcher:hover { transform: translateY(-3px) scale(1.05); }
.wally-chat__launcher:focus-visible {
  outline: 3px solid var(--wc-yellow);
  outline-offset: 4px;
  border-radius: 14px;
}
.wally-chat__ping {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--wc-yellow);
  color: #231a05;
  font: 700 10px/18px Manrope, sans-serif;
  text-align: center;
}
.wally-chat.is-open .wally-chat__launcher { display: none; }

/* ---------- panel ---------- */
.wally-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(358px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 40px));
  display: none;
  flex-direction: column;
  background: var(--wc-night);
  color: var(--wc-cream);
  border: 1px solid rgba(242, 193, 78, .28);
  border-radius: 18px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.wally-chat.is-open .wally-chat__panel { display: flex; }

.wally-chat__head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 12px 12px 14px;
  background: linear-gradient(180deg, rgba(107, 77, 168, .28), transparent);
  border-bottom: 1px solid var(--wc-line);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.wally-chat__head.is-dragging { cursor: grabbing; }
.wally-chat__grip {
  flex: none;
  color: var(--wc-muted);
  font-size: 13px;
  letter-spacing: -2px;
  margin-right: -4px;
}
.wally-chat__avatar {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
}
.wally-chat__avatar img { width: 38px; height: 38px; object-fit: contain; display: block; }
.wally-chat__who { flex: 1; min-width: 0; }
.wally-chat__who b { display: block; font-size: .92rem; font-weight: 600; }
.wally-chat__who span { font-size: .72rem; color: var(--wc-muted); }
.wally-chat__who .wally-chat__live { color: #7fc494; }
.wally-chat__head button {
  appearance: none;
  border: 0;
  background: rgba(241, 238, 230, .08);
  color: var(--wc-cream);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.wally-chat__head button:hover { background: rgba(241, 238, 230, .16); }
.wally-chat__head button:focus-visible { outline: 2px solid var(--wc-yellow); outline-offset: 2px; }

/* ---------- body ---------- */
.wally-chat__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(242, 193, 78, .30) transparent;
  overscroll-behavior: contain;
}
.wally-chat__body::-webkit-scrollbar { width: 5px; }
.wally-chat__body::-webkit-scrollbar-track { background: transparent; }
.wally-chat__body::-webkit-scrollbar-thumb { background: rgba(242, 193, 78, .20); border-radius: 99px; }
.wally-chat__body:hover::-webkit-scrollbar-thumb { background: rgba(242, 193, 78, .42); }

.wally-chat__msg { max-width: 88%; font-size: .86rem; overflow-wrap: anywhere; }
.wally-chat__msg--bot {
  align-self: flex-start;
  background: var(--wc-night-2);
  border: 1px solid var(--wc-line);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 12px;
}
.wally-chat__msg--user {
  align-self: flex-end;
  background: var(--wc-purple);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 12px;
}
.wally-chat__msg--bot ul { margin: 6px 0 2px; padding-left: 18px; }
.wally-chat__msg--bot li { margin: 3px 0; }
.wally-chat__msg--bot a {
  color: var(--wc-yellow);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wally-chat__msg--bot a:hover { text-decoration-thickness: 2px; }
.wally-chat__msg--bot a:focus-visible { outline: 2px solid var(--wc-yellow); outline-offset: 2px; border-radius: 2px; }
.wally-chat__src {
  display: block;
  margin-top: 6px;
  font: 500 .7rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--wc-yellow);
}
.wally-chat__disc {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--wc-line);
  font-size: .74rem;
  color: var(--wc-muted);
}
.wally-chat__typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px; }
.wally-chat__typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--wc-muted);
  animation: wally-bob 1s infinite;
}
.wally-chat__typing i:nth-child(2) { animation-delay: .15s; }
.wally-chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes wally-bob {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.wally-chat__chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 0 6px; }
.wally-chat__chip {
  appearance: none;
  cursor: pointer;
  border: 1px solid rgba(242, 193, 78, .35);
  background: rgba(242, 193, 78, .07);
  color: var(--wc-cream);
  font: 500 .78rem Manrope, sans-serif;
  padding: 7px 11px;
  border-radius: 999px;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.wally-chat__chip:hover { background: rgba(242, 193, 78, .16); }
.wally-chat__chip:focus-visible { outline: 2px solid var(--wc-yellow); outline-offset: 2px; }
.wally-chat__chip .wally-chat__ic { margin-right: 5px; }
.wally-chat__chip--back { border-color: var(--wc-line); background: transparent; color: var(--wc-muted); }

/* ---------- footer ---------- */
.wally-chat__foot {
  border-top: 1px solid var(--wc-line);
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--wc-night);
}
.wally-chat__foot textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--wc-line);
  border-radius: 10px;
  background: var(--wc-night-2);
  color: var(--wc-cream);
  font: 400 .84rem Manrope, sans-serif;
  padding: 9px 11px;
  max-height: 80px;
}
.wally-chat__foot textarea::placeholder { color: var(--wc-muted); }
.wally-chat__foot textarea:focus-visible { outline: 2px solid var(--wc-purple); outline-offset: 0; border-color: transparent; }
.wally-chat__send {
  appearance: none;
  border: 0;
  cursor: pointer;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--wc-yellow);
  color: #231a05;
  font-size: 16px;
  display: grid;
  place-items: center;
}
.wally-chat__send:hover { filter: brightness(1.05); }
.wally-chat__send:focus-visible { outline: 2px solid var(--wc-cream); outline-offset: 2px; }

/* màn hình rộng: canh lề phải bằng logo / nút CTA ở header (clamp 20–62px), nhấc cao hơn khỏi đáy */
@media (min-width: 900px) {
  .wally-chat {
    right: clamp(24px, 4vw, 62px);
    bottom: 40px;
  }
}

/* ---------- mobile: vẫn ở góc phải-dưới, chỉ co lại vừa màn hình ---------- */
@media (max-width: 640px) {
  .wally-chat { right: 16px; bottom: 16px; }
  .wally-chat__panel {
    width: calc(100vw - 24px);
    height: min(74vh, calc(100vh - 96px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .wally-chat *, .wally-chat *::before { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
