/* ==== YOUR CORE CSS (unchanged) ==== */
.enatega-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: transparent;  
  border: none;
  cursor: pointer;
  z-index: 9999;
}
#enatega-chat-box code{
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  white-space: pre-wrap;        /* preserve line breaks but allow wrapping */
  word-wrap: break-word;        /* legacy name */
  overflow-wrap: anywhere;      /* modern: allow breaks at any point if needed */
  word-break: break-word;       /* fallback for some browsers */
  tab-size: 2;
}
/* Floating Chat Window */
.enatega-chat {
  position: fixed;
  bottom: 20px;
  right: 24px;
  width: 360px;
  max-width: 90%;
  z-index: 10000;
  display: flex;
  flex-direction: column;
}
/* Close Button */
.enatega-chat__close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  position: absolute;
  right: 15px;
  top: 15px;
  color: #666;
}
.enatega-chat__close:hover {
  color: #000;
}

/* FIXED (added missing commas so h3 styles apply): */
#enatega-chat-msgs h3,
#enatega-chat-msgs h4,
#enatega-chat-msgs h5,
#enatega-chat-msgs h6{
  font-size: 17px;
  color: #1a1d1e;
}

#enatega-chat-msgs h2{
  font-size: 20px;
}
#enatega-chat-msgs p{
  font-size: 16px;
  margin: 5px 0 15px;
}
#enatega-chat-msgs a{
  font-size: 16px;
  margin: 9px 0 ;
  font-size: 14px;
  padding: 9px 8px;
  font-weight: 600;
  background-color: transparent;
  background-image: linear-gradient(180deg, #7C6CE4 0, #624DE3 100%);
  border: 1px solid #0000001A;
  border-radius: 8px;
  color: #fff;
  box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .1), 0 -1px 0 1px rgba(0, 0, 0, .25) inset, 0 2px 0 0 rgba(255, 255, 255, .2) inset;
  display: inline-block;
  cursor: pointer;
  width: auto;
}
#enatega-chat-msgs ul{
  list-style-type: disc;
}

/* Typing indicator: three bouncing dots */
.typing {
  display: inline-flex;
  align-items: flex-end;   /* so the bounce is visible */
  gap: 6px;
  height: 16px;
  line-height: 0;
  color: currentColor;     /* match bubble text color */
}
.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  animation: dot-bounce 1s infinite ease-in-out;
}
.typing .dot:nth-child(2) { animation-delay: .12s; }
.typing .dot:nth-child(3) { animation-delay: .24s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: .35; }
  40%           { transform: translateY(-4px); opacity: 1;   }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .typing .dot { animation: none; opacity: .6; }
}

@keyframes enatega-typing {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-2px); }
}

.enatega-chat { max-width: 780px; height: 550px; background: #fff; border: 1px solid #E6E6E6; border-radius: 12px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,.06); font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.enatega-chat__header { padding: 14px 18px; border-bottom: 1px solid #eee; background:#fafafa; }
.enatega-chat__title { font-weight: 700; font-size: 18px; }
.enatega-chat__subtitle { color:#666; font-size: 13px; margin-top: 4px; }
.enatega-chat__msgs { height: 460px; overflow-y: auto; padding: 16px; background: #fff; }
.enatega-chat__row { display: flex; margin: 10px 0; }
.enatega-chat__row.user { justify-content: flex-end; }
.enatega-chat__row.assistant { justify-content: flex-start; }
.enatega-chat__row .bubble { max-width: 80%; padding: 10px 12px; border-radius: 16px; line-height: 1.4; }
.enatega-chat__row.user .bubble { background: #6C5CE7; color:#fff; border-bottom-right-radius: 6px; }
.enatega-chat__row.assistant .bubble { background: #F2F2FF; color:#222; border-bottom-left-radius: 6px; }
.enatega-chat__form { display:flex; gap:8px; padding: 12px; border-top: 1px solid #eee; background:#fafafa; }
.enatega-chat__form input { flex:1; padding:9px 10px; border:1px solid #ddd; border-radius: 10px; }
.enatega-chat__form button { padding: 10px 16px; border:0; border-radius:10px; background:#6C5CE7; color:#fff; font-weight:600; cursor:pointer; }
.enatega-chat__form button:disabled { opacity: .6; cursor: not-allowed; }
.enatega-chat__footnote { padding: 6px 14px 12px; font-size:12px; color:#666; }

/* ==== ADDITIONS (streaming, welcome, quick questions, tidy HTML) ==== */

/* Make assistant HTML render clean (avoid big gaps) */
.enatega-chat__row .bubble { white-space: normal; line-height: 1.45; }
#enatega-chat-msgs .enatega-chat__row .bubble h2,
#enatega-chat-msgs .enatega-chat__row .bubble h3 { 
  margin: 6px 0; 
  font-weight: 600; 
  line-height: 1.25; 
}
#enatega-chat-msgs .enatega-chat__row .bubble p { 
  margin: 4px 0;            /* overrides the more general #enatega-chat-msgs p */ 
}
#enatega-chat-msgs .enatega-chat__row .bubble p:first-child { margin-top: 0; }
#enatega-chat-msgs .enatega-chat__row .bubble p:last-child  { margin-bottom: 0; }
#enatega-chat-msgs .enatega-chat__row .bubble ul,
#enatega-chat-msgs .enatega-chat__row .bubble ol { 
  margin: 4px 0 4px 18px; 
  padding: 0; 
}
#enatega-chat-msgs .enatega-chat__row .bubble li { 
  margin: 2px 0; 
}

/* Optional style for inline source chips, if you ever render them */
.enatega-chat__row .sources { 
  display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 0 0; 
}
.enatega-chat__row .src-chip {
  display:inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9ecff;
  color: #1b214e;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

/* Streaming spinner (used in your JS) */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,.2);
  border-top-color: #6C5CE7;
  border-radius: 50%;
  animation: enatega-spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes enatega-spin { to { transform: rotate(360deg); } }

/* Quick questions (chips) inside an assistant bubble */
.sugg-title {
  color:#666;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
.sugg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sugg-chip {
  border: 0;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  background: #e6e8ff;
  color: #1b214e;
}
.sugg-chip:hover { filter: brightness(.95); }

/* Small screens: keep the widget usable */
@media (max-width: 420px) {
  .enatega-chat { width: calc(100% - 32px); right: 16px; left: 16px; }
  .enatega-chat__msgs { height: 420px; }
}

/* Prevent iOS focus zoom in the chat */
.enatega-chat__form input,
.enatega-chat__form textarea,
.enatega-chat__form select,
#enatega-chat-input {
  font-size: 14px;       /* key line */
  line-height: 1.3;
}

/* iOS-targeted safety net (keeps rest of site untouched) */
@supports (-webkit-touch-callout: none) {
  .enatega-chat__form input,
  .enatega-chat__form textarea,
  .enatega-chat__form select,
  #enatega-chat-input {
    font-size: 16px !important;
  }
}

/* Optional: avoid iOS text auto-scaling surprises inside the widget */
.enatega-chat, .enatega-chat * {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Blinking nudge above the floating toggle */
.enatega-nudge {
  position: fixed;
  right: 24px;                 /* align with your .enatega-chat-toggle */
  bottom: 80px;                /* 56px button + 12–16px gap */
  z-index: 10001;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #7C6CE4 0, #624DE3 100%);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  pointer-events: none;        /* don’t intercept clicks on the button */
  animation: enatega-blink 1.2s infinite ease-in-out;
  white-space: nowrap;
}
.enatega-nudge::after {        /* little speech-bubble tail */
  content: "";
  position: absolute;
  bottom: -6px; right: 18px;
  border: 6px solid transparent;
  border-top-color: #624DE3;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.18));
}
@keyframes enatega-blink {
  0%, 100% { opacity: .35; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-1px); }
}

/* Optional: make the button itself subtly bounce while nudge is visible */
.enatega-chat-toggle.nudge {
  animation: enatega-bounce 1.8s ease-in-out infinite;
}
@keyframes enatega-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

/* Small screens: tuck a bit closer */
@media (max-width: 420px) {
  .enatega-nudge { right: 16px; bottom: 88px; }
}

/* Allow absolute children (the down arrow) inside the messages pane */
.enatega-chat__msgs { position: relative; }

/* Scroll-to-bottom button (hidden by default) */
#enatega-scroll-down {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: none;
  border: 0;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  background: #6C5CE7;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  cursor: pointer;
  z-index: 2;             /* ensure above bubbles */
  pointer-events: auto;   /* clickable even if parent tweaks it */
}
#enatega-scroll-down.show { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
}

/* Simple chevron */
#enatega-scroll-down svg { width: 18px; height: 18px; }

/* Gentle pulse so it’s discoverable */
@keyframes enatega-pulse {
  0%,100% { transform: translateY(0); opacity: .95; }
  50%     { transform: translateY(1px); opacity: 1;  }
}
#enatega-scroll-down.show { animation: enatega-pulse 1.6s ease-in-out infinite; }
