/* Chat window (app/templates/partials/chat.php). Hand-written, not generated from the Astro
   components like site.css, so build-css.mjs never overwrites it. Uses site.css tokens. */

.psp-chat { --chat-w: 384px; font-family: var(--sans); }

.chat-launch {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 22px 0 8px;
  border: 0; border-radius: 999px; background: var(--ink); color: var(--white);
  font: 600 .9375rem/1 var(--sans); cursor: pointer;
  box-shadow: 0 18px 36px -14px rgba(25, 27, 60, .65), 0 4px 10px rgba(25, 27, 60, .18);
  opacity: 0; pointer-events: none; transform: translateY(24px) scale(.96);
  transition: opacity .5s, transform .6s cubic-bezier(.22, 1, .36, 1), background-color .2s;
}
.chat-launch .ico {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--gold); color: var(--ink);
}
.chat-launch:hover { background: var(--ink-2); }
.chat-launch.show, .psp-chat.open .chat-launch, .psp-chat.active .chat-launch { opacity: 1; pointer-events: auto; transform: none; }
.chat-launch:focus-visible, .chat-panel :focus-visible:not(textarea) { outline: 3px solid var(--gold); outline-offset: 2px; }
.psp-chat.open .chat-launch { visibility: hidden; }

.chat-panel {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  display: flex; flex-direction: column; width: var(--chat-w); height: min(620px, calc(100dvh - 48px));
  background: var(--paper); border-radius: var(--radius-l); overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(25, 27, 60, .45), 0 6px 18px rgba(25, 27, 60, .14);
  animation: chat-in .35s cubic-bezier(.22, 1, .36, 1);
}
.chat-panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px;
  background: var(--ink); color: var(--white); border-bottom: 2px solid var(--gold);
}
.chat-head img { flex: none; }
.chat-head div { flex: 1; min-width: 0; }
.chat-head h2 { margin: 0; font: 700 1rem/1.25 var(--sans); color: var(--white); }
.chat-head p { margin: 2px 0 0; font-size: .8125rem; color: var(--on-dark-muted); }
.chat-close {
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--on-dark); cursor: pointer;
}
.chat-close:hover { background: rgba(255, 255, 255, .1); }
.chat-head .chat-close + .chat-close { margin-left: -8px; }
.chat-back svg { transform: rotate(180deg); }
.psp-chat [hidden] { display: none !important; }

/* History: older chats on this browser (chat.js). */
.chat-history { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.chat-history ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-history button {
  width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--white); color: var(--text); cursor: pointer;
  font: inherit; transition: border-color .2s, background-color .2s;
}
.chat-history button:hover { border-color: var(--gold); background: var(--gold-soft); }
.chat-history strong { font-size: .9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-history span { font-size: .8125rem; color: var(--muted); }
.chat-history-empty { font-size: .875rem; color: var(--muted); }
.chat-history-note { margin: 12px 2px 0; font-size: .8125rem; line-height: 1.5; color: var(--muted); }

.chat-log {
  position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg {
  max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: .9375rem; line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg p { margin: 0; }
.msg p + p { margin-top: .55em; }
.msg a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg.bot { align-self: flex-start; background: var(--white); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--white); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.note { align-self: center; max-width: 100%; padding: 6px 12px; background: var(--gold-soft); color: var(--gold-ink); font-size: .8125rem; border-radius: 999px; text-align: center; }

.msg.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; animation: chat-dot 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 30% { opacity: 1; transform: translateY(-3px); } }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.chat-chips button {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white);
  color: var(--indigo); font: 600 .8125rem/1.2 var(--sans); cursor: pointer; transition: border-color .2s, background-color .2s;
}
.chat-chips button:hover { border-color: var(--gold); background: var(--gold-soft); }

.chat-wa {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px;
  border-radius: 999px; background: var(--wa); color: var(--white); font-weight: 600; font-size: .875rem; text-decoration: none;
}

.chat-form {
  display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 0; padding: 6px 6px 6px 14px;
  background: var(--white); border: 1px solid var(--line); border-radius: 22px;
}
.chat-form:focus-within { border-color: var(--indigo); }
.chat-form textarea {
  flex: 1; min-height: 24px; max-height: 120px; padding: 7px 0; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--text); font: 400 .9375rem/1.45 var(--sans);
}
.chat-send {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: var(--gold); color: var(--ink); cursor: pointer; transition: opacity .2s;
}
.chat-send:disabled { opacity: .45; cursor: default; }
.chat-foot { margin: 0; padding: 8px 16px 12px; font-size: .75rem; line-height: 1.45; color: var(--muted); }
.chat-foot a { color: var(--wa); font-weight: 600; }

@media (width <= 640px) {
  .chat-launch { right: 16px; bottom: 16px; width: 56px; padding: 0; justify-content: center; }
  .chat-launch .txt { display: none; }
  .chat-panel { inset: 0; width: auto; height: 100dvh; border-radius: 0; }
  .chat-form textarea { font-size: 1rem; } /* no iOS zoom on focus */
}

@media (prefers-reduced-motion: reduce) {
  .chat-launch { transition: opacity .2s linear; transform: none; }
  .chat-panel { animation: none; }
  .msg.typing i { animation: none; opacity: .6; }
}
