/* Hosted Email support chat widget. */
.he-chat, .he-chat * { box-sizing: border-box; }

.he-chat {
  --he-accent: #2b6cb0;
  --he-accent-ink: #fff;
  --he-bg: #ffffff;
  --he-ink: #1a1c1d;
  --he-muted: #6b7177;
  --he-line: #e3e5e8;
  --he-user: #2b6cb0;
  --he-bot: #f2f3f5;
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Launcher button */
.he-launcher {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--he-accent); color: var(--he-accent-ink);
  border: 0; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.he-launcher svg { display: block; }
.he-launcher:hover { transform: scale(1.05); }
.he-chat.is-open .he-launcher { display: none; }

/* Panel */
.he-panel {
  position: absolute; right: 0; bottom: 0;
  width: 370px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 40px);
  background: var(--he-bg); border: 1px solid var(--he-line);
  border-radius: 16px; box-shadow: 0 14px 44px rgba(0,0,0,.24);
  display: none; flex-direction: column; overflow: hidden;
}
.he-chat.is-open .he-panel { display: flex; }
/* animate only on user toggle, never on cross-page restore */
.he-chat.he-animate .he-panel { animation: he-pop .14s ease-out; }
@keyframes he-pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.he-header {
  background: var(--he-accent); color: var(--he-accent-ink);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
}
.he-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.he-header p { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.he-close { background: transparent; border: 0; color: inherit; font-size: 20px; cursor: pointer; line-height: 1; padding: 4px; }

.he-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* Each message is a column: the bubble plus a small timestamp under it. */
.he-msgrow { display: flex; flex-direction: column; max-width: 84%; gap: 3px; }
.he-msgrow.user { align-self: flex-end; align-items: flex-end; }
.he-msgrow.bot  { align-self: flex-start; align-items: flex-start; }
.he-msg { max-width: 100%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.he-msgrow.user .he-msg { background: var(--he-user); color: #fff; border-bottom-right-radius: 4px; }
.he-msgrow.bot  .he-msg { background: var(--he-bot); color: var(--he-ink); border-bottom-left-radius: 4px; }
.he-msg img { max-width: 100%; border-radius: 8px; margin-top: 6px; display: block; }
.he-time { font-size: 11px; color: var(--he-muted); padding: 0 4px; }

/* Rendered Markdown inside bot bubbles */
.he-msg > * + * { margin-top: 6px; }
.he-msg .he-p { margin: 0; }
.he-msg ul, .he-msg ol { margin: 0; padding-left: 20px; }
.he-msg li { margin: 2px 0; }
.he-msg li::marker { color: var(--he-muted); }
.he-msg strong { font-weight: 600; }
.he-msg code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; overflow-wrap: anywhere; }
.he-msgrow.bot .he-msg a { color: var(--he-accent); text-decoration: underline; }

/* Day divider ("Today" / "Yesterday" / "Wed, 16th June") */
.he-daysep { align-self: stretch; display: flex; align-items: center; gap: 8px; margin: 4px 2px; color: var(--he-muted); font-size: 11px; }
.he-daysep::before, .he-daysep::after { content: ""; flex: 1; height: 1px; background: var(--he-line); }

/* "Loading conversation…" while history is fetched on open */
.he-histload { align-self: center; margin: auto; display: flex; align-items: center; gap: 8px; color: var(--he-muted); font-size: 13px; }
.he-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--he-line); border-top-color: var(--he-accent); animation: he-spin 0.7s linear infinite; }
@keyframes he-spin { to { transform: rotate(360deg); } }

/* "Load previous messages" at the top of the transcript */
.he-loadprev-row { align-self: center; margin: 2px 0 4px; }
.he-loadprev { background: transparent; border: 1px solid var(--he-line); color: var(--he-muted); font-size: 12px; cursor: pointer; padding: 5px 12px; border-radius: 999px; }
.he-loadprev:hover { background: #fff; color: var(--he-ink); border-color: #c9ced3; }
.he-loadprev:disabled { opacity: .6; cursor: default; }

.he-endrow { align-self: center; margin: 6px 0 2px; }
.he-end { background: transparent; border: 1px solid var(--he-line); color: var(--he-muted); font-size: 12px; cursor: pointer; padding: 5px 12px; border-radius: 999px; }
.he-end:hover { background: #fff; color: var(--he-ink); border-color: #c9ced3; }

.he-typing { align-self: flex-start; background: var(--he-bot); padding: 11px 14px; border-radius: 14px; display: none; }
.he-typing.is-on { display: inline-flex; gap: 4px; }
.he-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa0a6; animation: he-blink 1.2s infinite both; }
.he-typing span:nth-child(2) { animation-delay: .2s; }
.he-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes he-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* Pending image previews above the input */
.he-attachments { display: flex; gap: 6px; padding: 0 12px; flex-wrap: wrap; }
.he-attachments:empty { display: none; }
.he-attachments .thumb { position: relative; width: 46px; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--he-line); }
.he-attachments .thumb img { width: 100%; height: 100%; object-fit: cover; }
.he-attachments .thumb button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(26,28,29,.82); color: #fff; font-size: 11px; cursor: pointer; line-height: 18px; padding: 0; box-shadow: 0 0 0 1px rgba(255,255,255,.5); }
.he-attachments .thumb button:hover { background: #1a1c1d; }

.he-input {
  border-top: 1px solid var(--he-line); padding: 10px 12px;
  display: flex; align-items: flex-end; gap: 8px;
}
.he-input textarea {
  flex: 1; resize: none; border: 1px solid var(--he-line); border-radius: 10px;
  padding: 9px 10px; font: inherit; min-height: 38px; max-height: 120px; outline: none;
}
.he-input textarea:focus { border-color: var(--he-accent); }
.he-iconbtn { background: transparent; border: 0; cursor: pointer; font-size: 19px; padding: 6px; color: var(--he-muted); }
.he-iconbtn:hover { color: var(--he-ink); }
.he-send { background: var(--he-accent); color: #fff; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; }
.he-send:disabled { opacity: .5; cursor: default; }

.he-foot { text-align: center; font-size: 11px; color: var(--he-muted); padding: 0 12px 8px; }
