/* JeremiahGPT chat widget — scoped to #jgpt-root so it can't leak into or be
   overridden by the host site's styles. */

#jgpt-root {
  --jgpt-navy: #0b1220;
  --jgpt-navy-deep: #070c16;
  --jgpt-panel: #101a2e;
  --jgpt-panel-alt: #16223a;
  --jgpt-gold: #c8a96e;
  --jgpt-gold-soft: rgba(200, 169, 110, 0.35);
  --jgpt-white: #f7f5f0;
  --jgpt-muted: #a9b3c7;
  --jgpt-heading-font: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --jgpt-body-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: fixed;
  z-index: 2147483000;
  bottom: max(24px, env(safe-area-inset-bottom));
  right: max(24px, env(safe-area-inset-right));
  font-family: var(--jgpt-body-font);
  color: var(--jgpt-white);
}

#jgpt-root * {
  box-sizing: border-box;
}

/* ---------- Launcher bubble ---------- */

.jgpt-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid var(--jgpt-gold-soft);
  background: linear-gradient(155deg, var(--jgpt-panel) 0%, var(--jgpt-navy-deep) 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(200, 169, 110, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.jgpt-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(200, 169, 110, 0.18);
}

.jgpt-launcher svg {
  width: 26px;
  height: 26px;
  stroke: var(--jgpt-gold);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.jgpt-launcher .jgpt-icon-close {
  position: absolute;
  opacity: 0;
  transform: scale(0.7);
}

#jgpt-root.jgpt-open .jgpt-icon-chat {
  opacity: 0;
  transform: scale(0.7);
}
#jgpt-root.jgpt-open .jgpt-icon-close {
  opacity: 1;
  transform: scale(1);
}

.jgpt-launcher .jgpt-pulse {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--jgpt-gold-soft);
  animation: jgpt-pulse 2.6s ease-out infinite;
}

@keyframes jgpt-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.55); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .jgpt-launcher .jgpt-pulse { animation: none; }
}

/* ---------- Attention callout ---------- */

.jgpt-callout {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 236px;
  max-width: calc(100vw - 56px);
  background: linear-gradient(155deg, var(--jgpt-panel) 0%, var(--jgpt-navy-deep) 100%);
  border: 1px solid var(--jgpt-gold-soft);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px);
  animation: jgpt-callout-in 0.4s ease forwards;
  animation-delay: 1.3s;
  cursor: pointer;
}

.jgpt-callout::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 26px;
  width: 14px;
  height: 14px;
  background: var(--jgpt-navy-deep);
  border-right: 1px solid var(--jgpt-gold-soft);
  border-bottom: 1px solid var(--jgpt-gold-soft);
  transform: rotate(45deg);
}

.jgpt-callout-title {
  font-family: var(--jgpt-heading-font);
  font-size: 14px;
  color: var(--jgpt-gold);
  margin: 0 0 4px;
  padding-right: 16px;
}

.jgpt-callout-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--jgpt-white);
  margin: 0;
}

.jgpt-callout-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--jgpt-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.jgpt-callout-close svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

#jgpt-root.jgpt-open .jgpt-callout,
#jgpt-root.jgpt-callout-hidden .jgpt-callout {
  display: none;
}

@keyframes jgpt-callout-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .jgpt-callout { animation: none; opacity: 1; transform: none; }
}

/* ---------- Panel ---------- */

.jgpt-panel {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  background: linear-gradient(180deg, var(--jgpt-panel) 0%, var(--jgpt-navy-deep) 100%);
  border: 1px solid rgba(200, 169, 110, 0.22);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#jgpt-root.jgpt-open .jgpt-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* header */

.jgpt-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(200, 169, 110, 0.16);
  background: radial-gradient(120% 140% at 0% 0%, rgba(200, 169, 110, 0.1), transparent 60%);
  display: flex;
  align-items: center;
  gap: 12px;
}

.jgpt-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--jgpt-navy-deep);
  border: 1px solid var(--jgpt-gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--jgpt-heading-font);
  color: var(--jgpt-gold);
  font-size: 16px;
  flex-shrink: 0;
}

.jgpt-header-text h3 {
  margin: 0;
  font-family: var(--jgpt-heading-font);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0.2px;
  color: var(--jgpt-white);
}

.jgpt-header-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--jgpt-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.jgpt-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6fcf97;
  box-shadow: 0 0 0 2px rgba(111, 207, 151, 0.2);
  flex-shrink: 0;
}

/* messages */

.jgpt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.jgpt-messages::-webkit-scrollbar { width: 6px; }
.jgpt-messages::-webkit-scrollbar-thumb {
  background: rgba(200, 169, 110, 0.25);
  border-radius: 3px;
}

.jgpt-row {
  display: flex;
  gap: 8px;
  max-width: 100%;
}

.jgpt-row.jgpt-user { justify-content: flex-end; }

.jgpt-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.jgpt-row.jgpt-assistant .jgpt-bubble {
  background: var(--jgpt-panel-alt);
  border: 1px solid rgba(200, 169, 110, 0.14);
  border-top-left-radius: 4px;
  color: var(--jgpt-white);
  max-width: 88%;
}

.jgpt-row.jgpt-user .jgpt-bubble {
  background: linear-gradient(135deg, var(--jgpt-gold) 0%, #b6935a 100%);
  color: #1a1305;
  border-top-right-radius: 4px;
  max-width: 82%;
  font-weight: 500;
}

.jgpt-row.jgpt-system .jgpt-bubble {
  background: transparent;
  border: 1px dashed rgba(200, 169, 110, 0.3);
  color: var(--jgpt-muted);
  font-size: 12.5px;
  max-width: 100%;
}

.jgpt-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.jgpt-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jgpt-gold);
  opacity: 0.5;
  animation: jgpt-blink 1.2s infinite ease-in-out;
}
.jgpt-typing span:nth-child(2) { animation-delay: 0.15s; }
.jgpt-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes jgpt-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* suggestion chips */

.jgpt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
}

.jgpt-chip {
  border: 1px solid rgba(200, 169, 110, 0.35);
  background: transparent;
  color: var(--jgpt-gold);
  font-family: var(--jgpt-body-font);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.jgpt-chip:hover {
  background: rgba(200, 169, 110, 0.12);
}

/* input */

.jgpt-inputbar {
  border-top: 1px solid rgba(200, 169, 110, 0.16);
  padding: 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(7, 12, 22, 0.4);
}

.jgpt-input {
  flex: 1;
  resize: none;
  max-height: 90px;
  min-height: 38px;
  background: var(--jgpt-navy-deep);
  border: 1px solid rgba(200, 169, 110, 0.22);
  border-radius: 10px;
  color: var(--jgpt-white);
  font-family: var(--jgpt-body-font);
  font-size: 16px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s ease;
}

@media (min-width: 481px) {
  .jgpt-input { font-size: 13.5px; }
}

.jgpt-input:focus {
  border-color: var(--jgpt-gold);
}

.jgpt-input::placeholder {
  color: var(--jgpt-muted);
}

.jgpt-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--jgpt-gold-soft);
  background: var(--jgpt-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.jgpt-send:hover { transform: translateY(-1px); }
.jgpt-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.jgpt-send svg {
  width: 16px;
  height: 16px;
  stroke: #1a1305;
}

.jgpt-footer {
  text-align: center;
  font-size: 10.5px;
  color: var(--jgpt-muted);
  padding: 6px 12px 10px;
  letter-spacing: 0.2px;
}

.jgpt-footer a {
  color: var(--jgpt-gold);
  text-decoration: none;
}
.jgpt-footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  #jgpt-root { bottom: 16px; right: 16px; }
  .jgpt-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    bottom: 76px;
    right: -8px;
  }
}
