/* Pointcoin AI hosted chat styles. Reuses Pointcoin tokens:
   Poppins, brand #314a6b, solid CTA (matches /dashboard .cta-button), pill radius, 16px cards. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --pai-brand: #314a6b;
  --pai-bg: #f5f5f5;
  --pai-card: #ffffff;
  --pai-border: #e0e0e0;
  --pai-text: #1f2733;
  --pai-muted: #5f6368;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

.pai-body {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  background: var(--pai-bg);
  color: var(--pai-text);
  min-height: 100vh;
  padding-bottom: 140px;
}

/* Header */
.pai-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--pai-card);
  border-bottom: 1px solid var(--pai-border);
}
.pai-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--pai-brand);
  font-weight: 600;
  font-size: 18px;
}
.pai-ghost-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.pai-ghost-btn:hover { background: rgba(0, 0, 0, 0.12); }

/* Layout */
.pai-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Thread */
.pai-thread { display: flex; flex-direction: column; gap: 16px; }
.pai-msg { display: flex; }
.pai-msg-user { justify-content: flex-end; }
.pai-msg-assistant { justify-content: flex-start; }
.pai-msg-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 15px;
  white-space: normal;
  word-wrap: break-word;
}
.pai-msg-user .pai-msg-content {
  background: var(--pai-brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pai-msg-assistant .pai-msg-content {
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-bottom-left-radius: 4px;
}
.pai-msg-content code {
  background: rgba(0, 0, 0, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
}
.pai-code {
  background: #1f2733;
  color: #e6edf3;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 8px 0;
}

/* Rendered Markdown blocks (used in chat bubbles and duel option bodies) */
.pai-msg-content p,
.pai-option-body p { margin: 0 0 8px; }
.pai-msg-content p:last-child,
.pai-option-body p:last-child { margin-bottom: 0; }
.pai-msg-content ul,
.pai-msg-content ol,
.pai-option-body ul,
.pai-option-body ol { margin: 4px 0 8px; padding-left: 22px; }
.pai-msg-content li,
.pai-option-body li { margin: 3px 0; }
.pai-msg-content h1,
.pai-msg-content h2,
.pai-msg-content h3,
.pai-option-body h1,
.pai-option-body h2,
.pai-option-body h3 {
  font-size: 1.05em;
  font-weight: 600;
  margin: 10px 0 4px;
  line-height: 1.3;
}
.pai-msg-content h1:first-child,
.pai-msg-content h2:first-child,
.pai-msg-content h3:first-child,
.pai-option-body h1:first-child,
.pai-option-body h2:first-child,
.pai-option-body h3:first-child { margin-top: 0; }

.pai-msg-content a,
.pai-option-body a {
  color: #4a6cf7;
  text-decoration: underline;
  word-break: break-word;
}

/* Tables */
.pai-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.pai-table th,
.pai-table td {
  border: 1px solid var(--pai-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.pai-table th {
  background: rgba(0, 0, 0, 0.04);
  font-weight: 600;
}
.pai-msg-content a:hover,
.pai-option-body a:hover { color: #314a6b; }

/* Typing indicator (shown in a streaming target until its first token) */
.pai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}
.pai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3b0;
  display: inline-block;
  animation: pai-typing-bounce 1.2s infinite ease-in-out both;
}
.pai-typing span:nth-child(1) { animation-delay: -0.24s; }
.pai-typing span:nth-child(2) { animation-delay: -0.12s; }
.pai-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes pai-typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Duel */
.pai-duel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
/* hidden attribute must win over the grid/flex display above */
.pai-duel[hidden],
.pai-option[hidden] { display: none; }
/* after a pick, the surviving option spans the full width */
.pai-duel-picked { grid-template-columns: 1fr; }
.pai-option {
  display: flex;
  flex-direction: column;
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 16px;
}
.pai-option-head {
  font-weight: 600;
  color: var(--pai-brand);
  margin-bottom: 10px;
  font-size: 14px;
  letter-spacing: 0.3px;
}
.pai-option-body {
  flex: 1;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
  min-height: 40px;
}
.pai-pick-btn {
  margin-top: 14px;
  background-color: #314a6b;
  color: #fff;
  border: 2px solid transparent;
  padding: 12px 18px;
  border-radius: 25px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(49, 74, 107, 0.25);
  transition: all 0.3s ease;
}
.pai-pick-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(49, 74, 107, 0.35);
}
.pai-pick-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pai-pick-btn.pai-picked { border-color: rgba(49, 74, 107, 0.4); }

/* Feedback chips */
.pai-feedback {
  margin-top: 18px;
  background: var(--pai-card);
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  padding: 18px;
}
.pai-feedback-q { font-weight: 600; margin-bottom: 12px; }
.pai-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.pai-chip {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid var(--pai-border);
  color: #333;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pai-chip:hover { background: rgba(0, 0, 0, 0.09); color: #1f2733; }
.pai-chip-on {
  background: var(--pai-brand);
  color: #fff;
  border-color: var(--pai-brand);
}
/* keep selected chips readable on hover (white text stays on a dark fill) */
.pai-chip-on:hover {
  background: #253a52;
  border-color: #253a52;
  color: #fff;
}

/* CTA */
.pai-cta {
  display: inline-block;
  background-color: #314a6b;
  color: #fff;
  border: 2px solid transparent;
  padding: 15px 30px;
  border-radius: 25px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 8px 25px rgba(49, 74, 107, 0.25);
  transition: all 0.3s ease;
  cursor: pointer;
}
.pai-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(49, 74, 107, 0.35);
}
.pai-cta:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Unauthenticated "try it now" lander conversion CTA */
.pai-install-cta {
  margin: 18px 0 8px;
  padding: 22px 20px;
  background: #fff;
  border: 1px solid var(--pai-border);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.pai-install-btn { font-size: 16px; }
.pai-install-sub {
  margin-top: 10px;
  color: var(--pai-muted);
  font-size: 13px;
  line-height: 1.4;
}

/* Composer */
.pai-form {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
  background: linear-gradient(180deg, rgba(245,245,245,0) 0%, var(--pai-bg) 30%);
}
.pai-input {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid var(--pai-border);
  border-radius: 24px;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
  outline: none;
}
.pai-input:focus { box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28); }
.pai-input:disabled { opacity: 0.7; }
.pai-send {
  flex: 0 0 auto;
  background: none;
  border: none;
  cursor: pointer;
  color: #314a6b;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transition: background-color 0.2s;
}
.pai-send:hover:not(:disabled) { background-color: rgba(95, 99, 104, 0.1); }
.pai-send:disabled { opacity: 0.6; cursor: not-allowed; }

/* Read-only / empty */
.pai-readonly-banner {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.pai-badge {
  background: rgba(49, 74, 107, 0.08);
  color: var(--pai-brand);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.pai-empty { text-align: center; padding: 80px 20px; }
.pai-empty h1 { margin-bottom: 12px; color: var(--pai-brand); }
.pai-empty p { color: var(--pai-muted); margin-bottom: 24px; }

/* Toast */
.pai-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2733;
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
  max-width: 90%;
}
.pai-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
  .pai-duel { grid-template-columns: 1fr; }
  .pai-msg-content { max-width: 90%; }
}

/* How-it-works modal */
.pai-modal[hidden] { display: none; }
.pai-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pai-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.pai-modal-card {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  max-width: 460px;
  width: calc(100% - 40px);
  padding: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.pai-modal-card h2 {
  color: var(--pai-brand);
  font-size: 20px;
  margin-bottom: 14px;
}
.pai-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: #9aa3b0;
  cursor: pointer;
}
.pai-modal-close:hover { color: #5f6368; }
.pai-help-list {
  margin: 0;
  padding-left: 20px;
}
.pai-help-list li {
  margin: 10px 0;
  line-height: 1.5;
  font-size: 14px;
}
