/* ─── HealthyGPT Widget Styles ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --hgpt-green:      #1a6b45;
  --hgpt-green-mid:  #2a9d6f;
  --hgpt-green-lite: #e8f5ef;
  --hgpt-accent:     #f0a500;
  --hgpt-white:      #ffffff;
  --hgpt-bg:         #f7fbf9;
  --hgpt-text:       #1c2b24;
  --hgpt-muted:      #6b8c7d;
  --hgpt-border:     #c9e4d7;
  --hgpt-shadow:     0 8px 40px rgba(26,107,69,0.13);
  --hgpt-radius:     18px;
  --hgpt-font-head:  'Playfair Display', Georgia, serif;
  --hgpt-font-body:  'DM Sans', system-ui, sans-serif;
}

/* ── Base Widget ─────────────────────────────────────────────────────────── */
.hgpt-widget {
  font-family: var(--hgpt-font-body);
  background: var(--hgpt-white);
  border: 1.5px solid var(--hgpt-border);
  border-radius: var(--hgpt-radius);
  box-shadow: var(--hgpt-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: hgptFadeIn 0.5s ease;
}

.hgpt-inline {
  max-width: 780px;
  margin: 30px auto;
  height: 620px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.hgpt-header {
  background: linear-gradient(135deg, var(--hgpt-green) 0%, #0f4a2f 100%);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.hgpt-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hgpt-pulse {
  width: 11px;
  height: 11px;
  background: #4ade80;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.hgpt-pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #4ade80;
  animation: hgptPulse 2s infinite;
}

.hgpt-title {
  font-family: var(--hgpt-font-head);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--hgpt-white);
  letter-spacing: -0.01em;
}

.hgpt-badge {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.9);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
}

.hgpt-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.hgpt-close:hover { background: rgba(255,255,255,0.3); }

/* ── Messages Area ───────────────────────────────────────────────────────── */
.hgpt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--hgpt-bg);
  scroll-behavior: smooth;
}

.hgpt-messages::-webkit-scrollbar { width: 5px; }
.hgpt-messages::-webkit-scrollbar-track { background: transparent; }
.hgpt-messages::-webkit-scrollbar-thumb { background: var(--hgpt-border); border-radius: 99px; }

/* ── Message Bubbles ─────────────────────────────────────────────────────── */
.hgpt-msg {
  display: flex;
  gap: 12px;
  animation: hgptSlideIn 0.35s ease;
  max-width: 88%;
}

.hgpt-msg.hgpt-user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 75%;
}

.hgpt-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.hgpt-msg.hgpt-bot .hgpt-avatar {
  background: linear-gradient(135deg, var(--hgpt-green), var(--hgpt-green-mid));
  color: white;
  font-size: 1.1rem;
}

.hgpt-msg.hgpt-user .hgpt-avatar {
  background: var(--hgpt-accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
}

.hgpt-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.65;
  font-size: 0.915rem;
  color: var(--hgpt-text);
}

.hgpt-msg.hgpt-bot .hgpt-bubble {
  background: var(--hgpt-white);
  border: 1px solid var(--hgpt-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 12px rgba(26,107,69,0.06);
}

.hgpt-msg.hgpt-user .hgpt-bubble {
  background: linear-gradient(135deg, var(--hgpt-green), var(--hgpt-green-mid));
  color: white;
  border-bottom-right-radius: 4px;
}

/* Markdown-like formatting inside bot bubbles */
.hgpt-bubble h1, .hgpt-bubble h2, .hgpt-bubble h3 {
  font-family: var(--hgpt-font-head);
  color: var(--hgpt-green);
  margin: 12px 0 6px;
  font-size: 1rem;
}
.hgpt-bubble strong { color: var(--hgpt-green); font-weight: 600; }
.hgpt-bubble em { color: var(--hgpt-muted); }
.hgpt-bubble ul, .hgpt-bubble ol {
  padding-left: 18px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hgpt-bubble li { line-height: 1.55; }
.hgpt-bubble p { margin: 6px 0; }
.hgpt-bubble code {
  background: var(--hgpt-green-lite);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.hgpt-bubble hr {
  border: none;
  border-top: 1px solid var(--hgpt-border);
  margin: 12px 0;
}
.hgpt-bubble blockquote {
  border-left: 3px solid var(--hgpt-green-mid);
  padding-left: 12px;
  color: var(--hgpt-muted);
  margin: 8px 0;
}

/* ── Typing Indicator ────────────────────────────────────────────────────── */
.hgpt-typing .hgpt-bubble {
  padding: 14px 20px;
}
.hgpt-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 18px;
}
.hgpt-dots span {
  width: 7px;
  height: 7px;
  background: var(--hgpt-green-mid);
  border-radius: 50%;
  animation: hgptBounce 1.2s infinite;
}
.hgpt-dots span:nth-child(2) { animation-delay: 0.2s; }
.hgpt-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Input Area ──────────────────────────────────────────────────────────── */
.hgpt-input-area {
  padding: 16px 18px;
  border-top: 1px solid var(--hgpt-border);
  background: var(--hgpt-white);
  flex-shrink: 0;
}

/* ── Suggestions ─────────────────────────────────────────────────────────── */
.hgpt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.hgpt-chip {
  background: var(--hgpt-green-lite);
  border: 1px solid var(--hgpt-border);
  color: var(--hgpt-green);
  font-family: var(--hgpt-font-body);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.hgpt-chip:hover {
  background: var(--hgpt-green);
  color: white;
  border-color: var(--hgpt-green);
  transform: translateY(-1px);
}

/* ── Input Row ───────────────────────────────────────────────────────────── */
.hgpt-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.hgpt-input {
  flex: 1;
  font-family: var(--hgpt-font-body);
  font-size: 0.915rem;
  color: var(--hgpt-text);
  background: var(--hgpt-bg);
  border: 1.5px solid var(--hgpt-border);
  border-radius: 12px;
  padding: 12px 16px;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hgpt-input:focus {
  border-color: var(--hgpt-green-mid);
  box-shadow: 0 0 0 3px rgba(42,157,111,0.12);
}
.hgpt-input::placeholder { color: var(--hgpt-muted); }

.hgpt-send {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--hgpt-green), var(--hgpt-green-mid));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  box-shadow: 0 4px 14px rgba(26,107,69,0.3);
}
.hgpt-send:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(26,107,69,0.4); }
.hgpt-send:active { transform: translateY(0); }
.hgpt-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.hgpt-send svg { width: 18px; height: 18px; stroke: white; }

/* ── Disclaimer ──────────────────────────────────────────────────────────── */
.hgpt-disclaimer {
  font-size: 0.7rem;
  color: var(--hgpt-muted);
  text-align: center;
  margin-top: 10px;
  margin-bottom: 0;
  line-height: 1.4;
}

/* ── Floating Button ─────────────────────────────────────────────────────── */
#hgpt-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  background: linear-gradient(135deg, var(--hgpt-green), var(--hgpt-green-mid));
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 28px rgba(26,107,69,0.4);
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
}
#hgpt-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 10px 36px rgba(26,107,69,0.5);
}
.hgpt-fab-icon { width: 26px; height: 26px; stroke: white; }
.hgpt-fab-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: var(--hgpt-accent);
  border-radius: 50%;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ── Float Widget ────────────────────────────────────────────────────────── */
.hgpt-float {
  position: fixed;
  bottom: 102px;
  right: 28px;
  width: 380px;
  height: 530px;
  z-index: 9998;
  animation: hgptFloatIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Error Bubble ────────────────────────────────────────────────────────── */
.hgpt-error .hgpt-bubble {
  background: #fff5f5;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes hgptFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes hgptSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes hgptFloatIn {
  from { opacity: 0; transform: scale(0.8) translateY(20px); transform-origin: bottom right; }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes hgptPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50%       { transform: scale(1.6); opacity: 0; }
}
@keyframes hgptBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .hgpt-inline  { height: 520px; margin: 16px 0; }
  .hgpt-float   { width: calc(100vw - 20px); right: 10px; bottom: 90px; }
  #hgpt-fab     { bottom: 18px; right: 18px; }
  .hgpt-bubble  { font-size: 0.875rem; }
}
