/* onboarding-chat.css — the conversational onboarding shell: a chat-style
   wizard where Addy asks each question with a typing effect, answers arrive
   as pills or through the bottom input, and the whole thing reads like a
   premium messaging app. Also styles the avatar sheet that slides up inside
   that shell (partials/avatar-sheet.php).

   Shared by onboarding.php (the full wizard) and avatar-edit.php (the same
   chat view with just the avatar editor in it). */

.auth-body { background: linear-gradient(160deg, #f5f3fb 0%, #eef0fb 55%, #f7eef4 100%); }

.onb-chat-wrap {
  /* The global `body { display:flex }` (sidebar layout) makes this a flex
     item — without these it shrinks to the shell's width and sits
     left-flush. Fill the row so the shell can center / go full-bleed. */
  flex: 1 1 100%;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.chat-shell {
  width: 100%;
  max-width: 560px;
  height: min(86vh, 780px);
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #fff);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(61, 32, 80, 0.18);
  overflow: hidden;
  position: relative;
}

.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.chat-head-av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 3px 10px rgba(61, 32, 80, 0.18);
  flex: none;
}

.chat-head-meta { flex: 1; min-width: 0; }

.chat-head-name {
  font-weight: 700;
  color: var(--plum);
  font-size: 0.98rem;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chat-head-name .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #35c26a;
  box-shadow: 0 0 0 3px rgba(53, 194, 106, 0.18);
}

.chat-head-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-progress {
  flex: none;
  text-align: right;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-progress-track {
  width: 74px;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 5px;
}

.chat-progress-bar {
  height: 100%;
  width: 8%;
  background: var(--brand-grad);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.chat-logout {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.05rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-logout:hover {
  background: var(--gray-bg, #f4f1f9);
  color: var(--coral);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 100%;
  animation: msgIn 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.msg-row.bot { justify-content: flex-start; }
.msg-row.user { justify-content: flex-end; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  margin-bottom: 2px;
}

.bubble {
  max-width: 78%;
  padding: 0.65rem 0.9rem;
  font-size: 0.92rem;
  line-height: 1.4;
  border-radius: 18px;
  word-wrap: break-word;
}

.bubble.bot {
  background: var(--gray-bg, #f4f1f9);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

/* In dark mode --gray-bg equals the chat surface, so Addy's bubbles would
   vanish — give them a distinct, slightly-lighter tile. */
:root[data-theme="dark"] .bubble.bot {
  background: rgba(255, 255, 255, 0.08);
}

.bubble.user {
  background: var(--brand-grad);
  color: var(--on-brand, #fff);
  border-bottom-right-radius: 5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(124, 92, 191, 0.28);
}

.bubble.error {
  background: #fdecea;
  color: var(--coral);
  border-bottom-left-radius: 5px;
}

.typing { display: inline-flex; gap: 4px; padding: 0.2rem 0.1rem; }
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mauve);
  opacity: 0.5;
  animation: typingBounce 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  background: var(--mauve);
  vertical-align: text-bottom;
  animation: caretBlink 0.9s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

/* ── Bottom answer dock ── */
.chat-dock {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  min-height: 68px;
}

/* Dark mode: the header + input dock hardcode white above, so give them
   dark frosted surfaces to match the chat body (their text/borders already
   use theme tokens, so they become readable once the surface flips). */
:root[data-theme="dark"] .chat-head,
:root[data-theme="dark"] .chat-dock {
  background: rgba(255, 255, 255, 0.05);
}

.dock-fade { animation: dockIn 0.25s ease; }
@keyframes dockIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dock-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  /* Some pills are links (e.g. "Back to profile") — keep them button-shaped. */
  display: inline-block;
  text-decoration: none;
  border: 1.5px solid var(--accent);
  background: var(--accent-pale);
  color: var(--plum);
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

.pill-row { row-gap: 0.45rem; }

/* Breathing room between the tappable pills and the input bar below. */
.pill-row + .dock-input-row { margin-top: 0.75rem; }

.pill:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(124, 92, 191, 0.22); }
.pill:active { transform: translateY(0); }

.pill.ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
}

.pill.suggest {
  border-color: var(--border);
  background: var(--card-bg, #fff);
  color: var(--text);
}

.pill.pill-primary {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

/* Onboarding review (final "your plan") card */
.onb-review {
  width: 100%;
  margin-bottom: 0.6rem;
}

.onb-review-eta {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--accent-pale);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.6rem;
}

.onb-review-eta strong { color: var(--plum); }

.onb-verdict {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.84rem;
  line-height: 1.5;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.7rem;
  border: 1px solid transparent;
}
.onb-verdict > i { flex: none; font-size: 1.05rem; margin-top: 1px; }
.onb-verdict > span { flex: 1; min-width: 0; }
.onb-verdict b { font-weight: 700; }
.onb-verdict.ok {
  background: rgba(26, 158, 92, 0.12);
  border-color: rgba(26, 158, 92, 0.25);
  color: #157a47;
}
.onb-verdict.ok > i { color: #1a9e5c; }
.onb-verdict.warn {
  background: rgba(224, 112, 106, 0.12);
  border-color: rgba(224, 112, 106, 0.28);
  color: #c0524c;
}
.onb-verdict.warn > i { color: var(--coral, #e0706a); }
:root[data-theme="dark"] .onb-verdict.ok { color: #6ee7a8; }
:root[data-theme="dark"] .onb-verdict.warn { color: #f0a29c; }

.onb-review-note {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.onb-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.onb-review-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--gray-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
}

.onb-review-row span { color: var(--text-muted); }
.onb-review-row b { color: var(--plum); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }

@media (max-width: 480px) {
  .onb-review-grid { grid-template-columns: 1fr; }
}

.dock-input-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.dock-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.7rem 1.05rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dock-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-pale);
}

.dock-send {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--brand-grad);
  color: #fff;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(124, 92, 191, 0.3);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.dock-send:hover { transform: scale(1.05); }
.dock-send:disabled { opacity: 0.5; cursor: default; transform: none; }

.dock-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.dock-back:hover { color: var(--accent); }

/* Persistent "Skip to Dashboard" bar — sits above the dock's top border
   line and stays put on every step. */
.chat-skipbar {
  flex: none;
  text-align: center;
  padding: 0.5rem 1rem 0.55rem;
}

.dock-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0.2rem 0.4rem;
}

.dock-skip:hover { color: var(--accent); }

/* ── Skip confirmation modal ── */
.skip-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(30, 16, 46, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.skip-modal.is-open { display: flex; animation: skipFade 0.18s ease; }

@keyframes skipFade { from { opacity: 0; } to { opacity: 1; } }

.skip-modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg, #fff);
  border-radius: 20px;
  padding: 1.5rem 1.4rem 1.3rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(30, 16, 46, 0.32);
  animation: skipPop 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes skipPop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.skip-modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  margin: 0 auto 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--accent-pale);
  color: var(--accent);
}

.skip-modal-title {
  font-weight: 700;
  color: var(--plum);
  font-size: 1.08rem;
  margin-bottom: 0.4rem;
}

.skip-modal-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.15rem;
}

.skip-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.skip-modal-actions .btn { width: 100%; }

/* ── In-chat avatar sheet ──
   The avatar builder (assets/css/avatar-builder.css, scoped under
   .avatar-setup) slides up *inside* the chat shell, so building an avatar
   never feels like leaving the conversation. Its own header/footer replace
   the standalone page's chrome; the builder itself is untouched. */
.avatar-sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  background: var(--card-bg, #fff);
}

.avatar-sheet.is-open { display: flex; animation: sheetUp 0.28s cubic-bezier(0.2, 0.7, 0.3, 1); }

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sheet-head-title { font-weight: 700; color: var(--plum); font-size: 0.98rem; line-height: 1.15; }
.sheet-head-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.sheet-head-meta { flex: 1; min-width: 0; }

.sheet-close {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--gray-bg, #f4f1f9);
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.sheet-close:hover { color: var(--coral); }

.sheet-foot {
  flex: none;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.8rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.sheet-foot .btn { padding-top: 0.6rem; padding-bottom: 0.6rem; }
.sheet-foot #avSave { flex: 1; }

.sheet-error {
  flex: none;
  margin: 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: #fdecea;
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

/* The builder's own hide helper is scoped to .avatar-setup — the sheet's
   own chrome lives outside it, so mirror the rule here. */
.avatar-sheet .as-hidden { display: none !important; }

/* The avatar answer bubble carries the finished avatar, not text. */
.bubble.avatar-answer { padding: 0.35rem; background: var(--accent-pale); border-bottom-right-radius: 5px; }
.bubble.avatar-answer img { display: block; width: 72px; height: 76px; border-radius: 14px; }

@media (max-width: 600px) {
  .onb-chat-wrap { padding: 0; }
  .chat-shell {
    height: 100vh;
    height: 100dvh;
    max-width: none;
    border-radius: 0;
  }
}
