/* ai-chat.css — Lunaris shared "Hỏi AI" panel (see assets/js/ai-chat.js).
   Uses the tokens from lunaris.css, so load that first. */

/* ── Launcher ── */
.ai-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, rgba(61, 31, 92, 0.92), rgba(26, 15, 48, 0.94));
  color: var(--gold-light);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5), 0 0 26px rgba(201, 169, 110, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform var(--tr-base), box-shadow var(--tr-base), opacity var(--tr-base);
  animation: ai-launcher-in 0.6s var(--ease-spring) 0.4s backwards;
}
@keyframes ai-launcher-in {
  from { opacity: 0; transform: translateY(16px) scale(0.9); }
}
.ai-launcher:active { transform: scale(0.96); transition-duration: 0.08s; }
.ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 34px rgba(201, 169, 110, 0.3);
}
.ai-launcher-mark {
  width: 24px;
  height: 24px;
  filter: brightness(1.9) drop-shadow(0 0 6px rgba(201, 169, 110, 0.7));
}
.ai-open .ai-launcher { opacity: 0; transform: scale(0.9); pointer-events: none; }

/* ── Panel ── */
.ai-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 910;
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 44px));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-solid);
  box-shadow: var(--shadow-panel), 0 0 60px rgba(107, 63, 160, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  /* Grows out of the launcher's corner, and shrinks back into it. */
  transform-origin: 100% 100%;
  animation: ai-rise 0.38s var(--ease-spring) both;
}
.ai-panel[hidden] { display: none; }
.ai-panel.is-closing {
  animation: ai-fall 0.2s var(--ease-out) both;
  pointer-events: none;
}

@keyframes ai-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@keyframes ai-fall {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateY(12px) scale(0.96); }
}

.ai-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: radial-gradient(120% 140% at 0% 0%, rgba(107, 63, 160, 0.28), transparent 60%);
}
.ai-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.ai-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--gold-pale);
}
.ai-icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--tr-fast), border-color var(--tr-fast), transform var(--tr-base);
}
.ai-icon-btn:hover { color: var(--gold-light); border-color: var(--line-strong); transform: rotate(90deg); }

/* ── Conversation ── */
.ai-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.ai-empty { margin: auto 0; text-align: center; padding: 12px 4px; }
.ai-empty[hidden] { display: none; }
.ai-empty-title {
  margin: 0 0 6px;
  font-family: var(--font-accent);
  font-size: 22px;
  font-style: italic;
  color: var(--gold-light);
}
.ai-empty-hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.55; color: var(--text-muted); }
.ai-empty-hint:empty { display: none; }

.ai-suggestions { display: flex; flex-direction: column; gap: 8px; }
.ai-chip {
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--mist);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--tr-fast), background var(--tr-fast), color var(--tr-fast), transform var(--tr-base);
  animation: ai-bubble-in 0.4s var(--ease-out) backwards;
}
.ai-chip:nth-child(2) { animation-delay: 50ms; }
.ai-chip:nth-child(3) { animation-delay: 100ms; }
.ai-chip:nth-child(4) { animation-delay: 150ms; }
.ai-chip:hover { border-color: var(--line-strong); background: rgba(201, 169, 110, 0.1); color: var(--gold-pale); transform: translateX(3px); }

.ai-bubble {
  display: flex;
  animation: ai-bubble-in 0.34s var(--ease-out) backwards;
}
.ai-bubble--user { transform-origin: 100% 100%; }
.ai-bubble--assistant { transform-origin: 0 100%; }

@keyframes ai-bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.ai-bubble-body {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.ai-bubble--user { justify-content: flex-end; }
.ai-bubble--user .ai-bubble-body {
  border-bottom-right-radius: 4px;
  background: linear-gradient(135deg, rgba(201, 169, 110, 0.24), rgba(201, 169, 110, 0.14));
  color: var(--gold-pale);
  white-space: pre-wrap;
}
.ai-bubble--assistant .ai-bubble-body {
  max-width: 100%;
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
.ai-bubble-body p { margin: 0 0 8px; }
.ai-bubble-body p:last-child,
.ai-bubble-body ul:last-child { margin-bottom: 0; }
.ai-bubble-body ul { margin: 0 0 8px; padding-left: 18px; }
.ai-bubble-body li { margin-bottom: 4px; }
.ai-bubble-body li::marker { color: var(--gold); }
.ai-bubble-body strong { color: var(--gold-light); font-weight: 600; }

.ai-bubble.is-pending .ai-bubble-body::after {
  content: "";
  display: inline-block;
  width: 26px;
  height: 8px;
  background:
    radial-gradient(circle, var(--gold) 45%, transparent 50%) 0 50% / 8px 8px no-repeat,
    radial-gradient(circle, var(--gold) 45%, transparent 50%) 9px 50% / 8px 8px no-repeat,
    radial-gradient(circle, var(--gold) 45%, transparent 50%) 18px 50% / 8px 8px no-repeat;
  animation: ai-dots 1.1s ease-in-out infinite;
}
@keyframes ai-dots { 50% { opacity: 0.3; } }
.ai-bubble.is-pending .ai-bubble-body::after { animation-timing-function: var(--ease-in-out); }

.ai-bubble.is-error .ai-bubble-body { border-color: rgba(255, 122, 114, 0.4); color: var(--red); }
.ai-error-tail { margin-top: 8px; font-size: 12px; color: var(--red); }
.ai-login-cta {
  display: block;
  margin-top: 10px;
  padding: 8px 16px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: var(--text, inherit);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ── Footer / input ── */
.ai-foot {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-notice {
  padding: 8px 12px;
  border: 1px solid rgba(255, 122, 114, 0.3);
  border-radius: var(--radius);
  background: rgba(255, 122, 114, 0.08);
  color: var(--red);
  font-size: 12px;
  line-height: 1.45;
}
.ai-notice[hidden],
.ai-context[hidden] { display: none; }
.ai-context {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
}
.ai-context::before { content: "✦ "; color: var(--gold); }

.ai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color var(--tr-fast);
}
.ai-form:focus-within { border-color: var(--line-strong); }
.ai-input {
  flex: 1;
  min-height: 34px;
  max-height: 140px;
  padding: 7px 0;
  border: 0;
  outline: 0; /* .ai-form:focus-within draws the ring instead */
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}
.ai-input::placeholder { color: var(--text-faint); }
.ai-send {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #17110a;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--tr-fast), filter var(--tr-fast), background var(--tr-base), color var(--tr-base);
}
.ai-send:hover { transform: translateY(-1px); filter: brightness(1.06); }
.ai-send:active { transform: scale(0.92); transition-duration: 0.08s; }
.ai-send.is-stop { background: var(--surface-3); color: var(--gold-light); font-size: 11px; }

.ai-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ai-disclaimer { font-size: 11px; color: var(--text-faint); }
.ai-text-btn {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ai-text-btn:hover { color: var(--gold-light); }

/* ── Phone: bottom sheet ── */
@media (max-width: 560px) {
  .ai-launcher { right: 14px; bottom: 14px; }
  .ai-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(86dvh, 680px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
    transform-origin: 50% 100%;
  }
  @keyframes ai-rise {
    from { opacity: 0.4; transform: translateY(100%); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes ai-fall {
    from { transform: none; }
    to   { transform: translateY(100%); }
  }
  .ai-panel { animation-duration: 0.42s; animation-timing-function: var(--ease-out); }
  .ai-panel.is-closing { animation-duration: 0.26s; animation-timing-function: var(--ease-in-out); }
  .ai-disclaimer { display: none; }
}
