/* GoWolffia Chat Widget — Styles
 * Matches scroll-to-top button design language
 * Bottom-left floating bubble + expandable chat panel
 */

/* ── Floating Bubble ─────────────────────────────────────────────────────── */

.go-chat-bubble {
  position: fixed;
  left: 1.25rem;            /* 20px — mirrors scroll-to-top at right */
  bottom: 1.25rem;          /* 20px */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #2c5530;
  background: #fff;
  color: #2c5530;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 1000;
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.2s ease;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.go-chat-bubble.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.go-chat-bubble:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  transform: scale(1.05);
}

.go-chat-bubble svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Chat Panel ──────────────────────────────────────────────────────────── */

.go-chat-panel {
  position: fixed;
  left: 1.25rem;
  bottom: 4.5rem;           /* above the bubble */
  width: 380px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e8e0;
  box-shadow: 0 24px 60px -30px rgba(14, 54, 40, 0.22);
  display: flex;
  flex-direction: column;
  z-index: 999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.go-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.go-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #2c5530;
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 500;
}

.go-chat-header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 10px;
  flex-shrink: 0;
}

.go-chat-header-title {
  flex: 1;
}

.go-chat-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  color: #fff;
  cursor: pointer;
  padding: 0;
  margin-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.go-chat-close:hover {
  background: rgba(255,255,255,0.32);
}

.go-chat-close:active {
  transform: scale(0.92);
}

.go-chat-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.go-chat-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Messages */
.go-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #0f1512;
  min-height: 200px;
  max-height: 400px;
}

.go-chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
}

.go-chat-msg.user {
  align-self: flex-end;
  background: #2c5530;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.go-chat-msg.bot {
  align-self: flex-start;
  background: #f4f5f0;
  color: #0f1512;
  border-bottom-left-radius: 4px;
}

.go-chat-msg.bot.has-table {
  max-width: 96%;
}

.go-chat-msg.bot strong {
  color: #2c5530;
}

/* Markdown typography inside bot messages */
.go-chat-msg.bot h2,
.go-chat-msg.bot h3,
.go-chat-msg.bot h4,
.go-chat-msg.bot h5,
.go-chat-msg.bot h6 {
  font-size: 13px;
  font-weight: 600;
  color: #2c5530;
  margin: 10px 0 4px;
  line-height: 1.4;
}

.go-chat-msg.bot h2 {
  font-size: 14px;
}

.go-chat-msg.bot h3:first-child,
.go-chat-msg.bot h4:first-child,
.go-chat-msg.bot h5:first-child,
.go-chat-msg.bot h6:first-child {
  margin-top: 0;
}

.go-chat-msg.bot p {
  margin: 4px 0;
}

.go-chat-msg.bot p:first-child {
  margin-top: 0;
}

.go-chat-msg.bot p:last-child {
  margin-bottom: 0;
}

.go-chat-msg.bot ul,
.go-chat-msg.bot ol {
  margin: 4px 0;
  padding-left: 18px;
}

.go-chat-msg.bot ul {
  list-style: disc;
}

.go-chat-msg.bot ol {
  list-style: decimal;
}

.go-chat-msg.bot li {
  margin: 2px 0;
}

.go-chat-msg.bot code {
  background: #e8ece5;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.go-chat-msg.bot a {
  color: #2c5530;
  text-decoration: underline;
  word-break: break-all;
}

/* Suggested questions */
.go-chat-suggested {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
}

.go-chat-suggested button {
  background: #f4f5f0;
  border: 1px solid #e5e8e0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: "Inter", sans-serif;
  color: #2c5530;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.go-chat-suggested button:hover {
  background: #e8ece5;
  border-color: #2c5530;
}

/* Typing indicator */
.go-chat-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}

.go-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: go-chat-bounce 1.2s ease-in-out infinite;
}

.go-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.go-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes go-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Input area */
.go-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e8e0;
  background: #fff;
}

.go-chat-input {
  flex: 1;
  border: 1px solid #e5e8e0;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: "Inter", sans-serif;
  color: #0f1512;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  max-height: 96px;
  line-height: 1.4;
}

.go-chat-input:focus {
  border-color: #2c5530;
}

.go-chat-input::placeholder {
  color: #9ca3af;
}

.go-chat-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #2c5530;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.go-chat-send:hover {
  background: #1a3d22;
}

.go-chat-send:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.go-chat-send svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Streaming cursor */
.go-chat-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: #2c5530;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: go-chat-blink 0.8s ease-in-out infinite;
}

@keyframes go-chat-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Mobile */
@media (max-width: 480px) {
  .go-chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    height: 100vh;
  }

  .go-chat-messages {
    max-height: none;
  }
}

/* ── Page-specific color overrides (matching scroll-to-top variants) ────── */

/* Attorney page (gold) */
.go-chat-theme-gold .go-chat-bubble { border-color: #c9a86c; color: #c9a86c; }
.go-chat-theme-gold .go-chat-header { background: linear-gradient(135deg, #c9a86c, #d4b87a); }
.go-chat-theme-gold .go-chat-msg.user { background: linear-gradient(135deg, #c9a86c, #d4b87a); }
.go-chat-theme-gold .go-chat-send { background: linear-gradient(135deg, #c9a86c, #d4b87a); }

/* Biohackers page (lime) */
.go-chat-theme-lime .go-chat-bubble { border-color: #00ff88; color: #00ff88; }
.go-chat-theme-lime .go-chat-bubble { background: transparent; }
.go-chat-theme-lime .go-chat-header { background: #0f1512; }
.go-chat-theme-lime .go-chat-msg.user { background: #0f1512; color: #00ff88; }
.go-chat-theme-lime .go-chat-send { background: #0f1512; }

/* Clinics page (blue) */
.go-chat-theme-blue .go-chat-bubble { border-color: #4a90e2; color: #4a90e2; }
.go-chat-theme-blue .go-chat-header { background: #4a90e2; }
.go-chat-theme-blue .go-chat-msg.user { background: #4a90e2; }
.go-chat-theme-blue .go-chat-send { background: #4a90e2; }

/* Skincare page (viridian) */
.go-chat-theme-skincare .go-chat-bubble { border-color: #1f5c47; color: #1f5c47; }
.go-chat-theme-skincare .go-chat-header { background: #1f5c47; }
.go-chat-theme-skincare .go-chat-msg.user { background: #1f5c47; }
.go-chat-theme-skincare .go-chat-send { background: #1f5c47; }

/* ── Markdown Tables ─────────────────────────────────────────────────────── */

.go-chat-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid #dcdfd6;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.go-chat-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.4;
  min-width: 420px;
}

.go-chat-table-wrap th {
  padding: 8px 10px;
  background: #e4e9e0;
  color: #2c5530;
  font-weight: 600;
  font-size: 11px;
  border-bottom: 2px solid #d2d8cb;
  text-align: left;
  white-space: nowrap;
}

.go-chat-table-wrap td {
  padding: 7px 10px;
  border-bottom: 1px solid #eef0ea;
  vertical-align: top;
  word-break: break-word;
}

.go-chat-table-wrap tr:last-child td {
  border-bottom: none;
}

.go-chat-table-wrap tr:nth-child(even) td {
  background: #fcfdfa;
}

.go-chat-table-wrap tr:hover td {
  background: #f0f2ec;
}

/* ── Email Opt-In Card ───────────────────────────────────────────────────── */

.go-chat-email-card {
  max-width: 96%;
  align-self: flex-start;
  background: #fff;
  border: 1px solid #dcdfd6;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 4px 0;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  color: #0f1512;
  box-shadow: 0 4px 14px -8px rgba(14, 54, 40, 0.18);
}

.go-chat-email-card-title {
  font-weight: 600;
  color: #2c5530;
  margin-bottom: 4px;
}

.go-chat-email-card-text {
  margin-bottom: 8px;
  line-height: 1.45;
}

.go-chat-email-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e5e8e0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: "Inter", sans-serif;
  outline: none;
  margin-bottom: 8px;
}

.go-chat-email-input:focus {
  border-color: #2c5530;
}

.go-chat-email-consent {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 10px;
  cursor: pointer;
}

.go-chat-email-consent input {
  margin-top: 1px;
  flex-shrink: 0;
}

.go-chat-email-consent a {
  color: #2c5530;
  text-decoration: underline;
}

.go-chat-email-row {
  display: flex;
  gap: 8px;
}

.go-chat-email-submit {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: #2c5530;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: "Inter", sans-serif;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.go-chat-email-submit:hover {
  background: #1a3d22;
}

.go-chat-email-dismiss {
  border: 1px solid #e5e8e0;
  background: transparent;
  color: #64748b;
  border-radius: 8px;
  font-size: 12px;
  font-family: "Inter", sans-serif;
  padding: 7px 12px;
  cursor: pointer;
}

.go-chat-email-dismiss:hover {
  background: #f4f5f0;
}

.go-chat-email-error {
  margin-top: 8px;
  font-size: 11px;
  color: #b91c1c;
  line-height: 1.4;
}

.go-chat-email-success {
  color: #2c5530;
  font-weight: 500;
  line-height: 1.5;
}
