/**
 * PROMPT 213 — Public AI Assistant chat + floating launcher
 */
:root {
  --pa-purple: #7c3aed;
  --pa-blue: #2563eb;
  --pa-ink: #0f172a;
  --pa-muted: #64748b;
  --pa-bg: #f1f5f9;
  --pa-card: #fff;
  --pa-line: #e2e8f0;
  --pa-ok: #059669;
  --pa-radius: 18px;
  --pa-shadow: 0 12px 36px rgba(15, 23, 42, 0.12);
}

body.pa-page {
  margin: 0;
  font-family: 'Vazirmatn', Vazir, Tahoma, system-ui, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, var(--pa-bg) 40%, #fff 100%);
  color: var(--pa-ink);
  direction: rtl;
  min-height: 100vh;
}

.pa-shell {
  max-width: 920px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 12px 16px;
}

.pa-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 4px;
}
.pa-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.pa-brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}
.pa-brand strong {
  display: block;
  font-size: 1rem;
}
.pa-brand span {
  font-size: 0.75rem;
  color: var(--pa-muted);
  font-weight: 600;
}
.pa-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.pa-status.is-busy {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.pa-status.is-down {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.pa-links a {
  margin-right: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pa-blue);
  text-decoration: none;
}

.pa-card {
  flex: 1;
  background: var(--pa-card);
  border: 1px solid var(--pa-line);
  border-radius: 22px;
  box-shadow: var(--pa-shadow);
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 720px);
  overflow: hidden;
}

.pa-messages {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, #fafbff, #fff);
}

.pa-msg {
  max-width: min(92%, 640px);
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.7;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.pa-msg.user {
  align-self: flex-start;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.pa-msg.bot {
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--pa-line);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  border-bottom-left-radius: 6px;
}
.pa-msg .meta {
  display: block;
  margin-top: 8px;
  font-size: 0.7rem;
  opacity: 0.75;
  font-weight: 600;
}
.pa-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.78rem;
}
.pa-sources strong {
  display: block;
  margin-bottom: 6px;
  color: #5b21b6;
}
.pa-sources a {
  display: inline-flex;
  margin: 0 0 6px 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #5b21b6;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.72rem;
}

.pa-composer {
  border-top: 1px solid var(--pa-line);
  padding: 12px;
  background: #fff;
}
.pa-composer__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.pa-composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--pa-line);
  border-radius: 14px;
  padding: 12px;
  font: inherit;
  background: #f8fafc;
}
.pa-composer textarea:focus {
  outline: 2px solid #c4b5fd;
  border-color: #a78bfa;
  background: #fff;
}
.pa-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pa-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.pa-btn-send {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.28);
}
.pa-btn-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.pa-btn-ghost {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--pa-line);
}
.pa-hint {
  margin: 8px 2px 0;
  font-size: 0.72rem;
  color: var(--pa-muted);
  line-height: 1.5;
}

.pa-welcome {
  text-align: center;
  padding: 28px 16px;
  color: var(--pa-muted);
}
.pa-welcome h1 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: var(--pa-ink);
}
.pa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.pa-chips button {
  appearance: none;
  border: 1px solid #ddd6fe;
  background: #faf5ff;
  color: #5b21b6;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* Floating launcher (homepage) */
.pa-fab {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 99950;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 16px 0 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.38);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  direction: rtl;
}
.pa-fab:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.4);
}
.pa-fab__ico {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.pa-mem-list {
  margin: 8px 0;
  padding: 0 1rem 0 0;
  font-size: 0.82rem;
  line-height: 1.6;
}
.pa-mem-list li {
  margin-bottom: 6px;
}
.pa-mem-del {
  appearance: none;
  border: 0;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  margin-right: 6px;
}
.pa-mem-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  margin: 8px 0;
}
.pa-mem-actions {
  margin-top: 8px;
}

@media (max-width: 640px) {
  .pa-fab span.pa-fab__label {
    display: none;
  }
  .pa-fab {
    padding: 0;
    width: 56px;
    height: 56px;
    justify-content: center;
    border-radius: 50%;
  }
  .pa-composer__row {
    flex-direction: column;
  }
  .pa-actions {
    flex-direction: row;
    width: 100%;
  }
  .pa-btn {
    flex: 1;
  }
}
