/* Puberty Ready! chat assistant. Uses the palette tokens from style.css. */

.chat-launcher {
  position: fixed; right: 16px; bottom: 16px; z-index: 150;
  display: inline-flex; align-items: center; gap: .5em;
  padding: 6px 18px 6px 6px; border: 0; border-radius: 999px;
  background: var(--pink); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  box-shadow: var(--shadow-lg); cursor: pointer;
}
.chat-launcher img { width: 44px; height: 44px; border-radius: 50%; background: var(--blush); object-fit: cover; object-position: top; }
.chat-launcher:hover { background: #b9265a; }
.chat-launcher.is-open { display: none; }
.chat-launcher[hidden] { display: none; }

.chat-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 160;
  width: min(390px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden; font-size: .97rem;
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px;
  background: var(--navy); color: #fff;
}
.chat-head img { width: 40px; height: 40px; border-radius: 50%; background: var(--blush); object-fit: cover; object-position: top; }
.chat-head h2 { flex: 1; margin: 0; font-size: 1.15rem; color: #fff; }
.chat-lang {
  font: inherit; font-size: .85rem; padding: 4px 6px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.4); background: var(--navy-2); color: #fff;
}
.chat-icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer;
}
.chat-icon-btn:hover { background: rgba(255,255,255,.15); }
.chat-icon-btn svg, .chat-send svg { width: 20px; height: 20px; }
.chat-panel :focus-visible { outline-color: var(--pink); }
.chat-head :focus-visible { outline-color: var(--sun); }

.chat-notice {
  margin: 0; padding: 8px 14px; font-size: .8rem; line-height: 1.4;
  background: var(--sun); color: var(--ink);
}

.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--cream); }
.chat-msg { max-width: 85%; padding: 9px 13px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-msg p { margin: 0 0 .45em; }
.chat-msg p:last-child { margin: 0; }
.chat-bot { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-user { align-self: flex-end; background: var(--lilac); color: var(--ink); border-bottom-right-radius: 4px; }

.chat-typing { display: inline-flex; gap: 4px; padding: 13px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--lavender); animation: chat-dot 1s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; opacity: .7; } }

.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; background: var(--cream); }
.chat-quick:not(:empty) { padding-bottom: 10px; }
.chat-chip {
  font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--pink); background: var(--paper); color: var(--pink); font-weight: 700;
}
.chat-chip:hover { background: var(--blush); }

.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--paper); }
.chat-input textarea {
  flex: 1; resize: none; font: inherit; padding: 9px 12px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); max-height: 120px;
}
.chat-input textarea:focus { border-color: var(--lavender-ink); outline: none; }
.chat-send {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 50%; background: var(--pink); color: #fff; cursor: pointer;
}
.chat-send:disabled { opacity: .5; cursor: wait; }

/* Contact form inside the conversation */
.chat-form {
  align-self: stretch; background: var(--paper); border: 2px solid var(--lavender); border-radius: var(--radius-sm);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.chat-form-intro { margin: 0; font-weight: 700; color: var(--navy); }
.chat-field { display: flex; flex-direction: column; gap: 3px; }
.chat-field label { font-size: .85rem; font-weight: 700; color: var(--navy); }
.chat-field input:not([type=checkbox]), .chat-field select, .chat-field textarea {
  font: inherit; font-size: .95rem; padding: 7px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); width: 100%;
}
.chat-field [aria-invalid=true] { border-color: var(--pink); }
.chat-field small, .chat-hint { font-size: .78rem; color: var(--muted); margin: 0; }
.chat-consent label { font-weight: 400; font-size: .82rem; line-height: 1.4; color: var(--ink); }
.chat-consent input { margin-right: 4px; vertical-align: -2px; }
.chat-err { margin: 0; font-size: .82rem; color: var(--pink); font-weight: 700; }
.chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.chat-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.chat-link-btn { font: inherit; font-size: .9rem; border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; }

@media (max-width: 480px) {
  .chat-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; }
  .chat-launcher { right: 12px; bottom: 12px; }
}
@media print { .chat-launcher, .chat-panel { display: none !important; } }
