/* AI Earning Lab — On-site Support Chat Widget
   Brand: deep forest green / rich black / warm cream / brass-gold.
   All classes are prefixed `ael-chat-` so nothing here can clash with the
   site's own stylesheet. Mobile-first: most visitors are on phones. */

:root {
  --ael-chat-forest: #0d2b1d;
  --ael-chat-forest-2: #123b27;
  --ael-chat-black: #0a0f0c;
  --ael-chat-panel: #101613;
  --ael-chat-cream: #f6f2e7;
  --ael-chat-cream-dim: #cfc9b8;
  --ael-chat-gold: #f0c85a;
  --ael-chat-brass: #b08d3e;
  --ael-chat-line: rgba(240, 200, 90, 0.28);
  --ael-chat-radius: 16px;
  --ael-chat-font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ael-chat-serif: "Newsreader", Georgia, serif;
}

/* ---------- Floating button ---------- */
.ael-chat-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px 0 14px;
  border: 1px solid var(--ael-chat-brass);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ael-chat-forest-2), var(--ael-chat-forest));
  color: var(--ael-chat-cream);
  font-family: var(--ael-chat-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.ael-chat-btn:hover { border-color: var(--ael-chat-gold); }
.ael-chat-btn:focus-visible { outline: 2px solid var(--ael-chat-gold); outline-offset: 2px; }
.ael-chat-btn svg { width: 24px; height: 24px; flex: 0 0 auto; fill: var(--ael-chat-gold); }
.ael-chat-btn-label { white-space: nowrap; }

/* ---------- Panel ---------- */
.ael-chat-panel {
  position: fixed;
  right: 16px;
  bottom: 80px;
  z-index: 99991;
  display: none;
  flex-direction: column;
  align-items: stretch;
  width: min(384px, calc(100vw - 24px));
  height: min(600px, calc(100dvh - 110px));
  /* Site-immunity: the panel is a <section>, and the site's global CSS pads
     every <section> (homepage inline CSS: `section{padding:11vh 5vw}`;
     main.css: `section{padding:104px 0}`). That padding used to eat the
     panel's content box, squeezing the inner layout into a ~190px column on
     desktop. Zero it explicitly — a class selector beats the element rule. */
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  text-align: left;
  border: 1px solid var(--ael-chat-line);
  border-radius: var(--ael-chat-radius);
  background: var(--ael-chat-panel);
  color: var(--ael-chat-cream);
  font-family: var(--ael-chat-font);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.ael-chat-panel.ael-chat-open { display: flex; }
/* Site-immunity: every widget descendant keeps border-box sizing and zeroed
   margins regardless of the host page's global resets. */
.ael-chat-panel *,
.ael-chat-btn {
  box-sizing: border-box;
  margin: 0;
}

.ael-chat-head {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--ael-chat-forest-2), var(--ael-chat-black));
  border-bottom: 1px solid var(--ael-chat-line);
}
.ael-chat-avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--ael-chat-gold);
  background: var(--ael-chat-forest);
  color: var(--ael-chat-gold);
  font-family: var(--ael-chat-serif);
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.ael-chat-head-text { flex: 1 1 auto; min-width: 0; }
.ael-chat-title { font-family: var(--ael-chat-serif); font-size: 17px; font-weight: 600; line-height: 1.2; }
.ael-chat-subtitle { font-size: 12px; color: var(--ael-chat-cream-dim); line-height: 1.3; }
.ael-chat-close {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--ael-chat-cream);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.ael-chat-close:hover { background: rgba(240, 200, 90, 0.12); }

/* ---------- Messages ---------- */
.ael-chat-body {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ael-chat-black);
}
.ael-chat-msg {
  box-sizing: border-box;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}
.ael-chat-msg strong { color: var(--ael-chat-gold); font-weight: 700; }
.ael-chat-msg-agent {
  align-self: flex-start;
  background: #17251d;
  border: 1px solid rgba(159, 177, 165, 0.22);
  border-bottom-left-radius: 4px;
  color: var(--ael-chat-cream);
}
.ael-chat-msg-user {
  align-self: flex-end;
  background: var(--ael-chat-forest-2);
  border: 1px solid var(--ael-chat-line);
  border-bottom-right-radius: 4px;
  color: var(--ael-chat-cream);
}
.ael-chat-msg-user strong { color: var(--ael-chat-cream); }

/* Typing indicator */
.ael-chat-typing { display: inline-flex; gap: 5px; align-items: center; padding: 12px; }
.ael-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ael-chat-gold);
  animation: ael-chat-blink 1.2s infinite ease-in-out;
}
.ael-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ael-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ael-chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Quick-question chips */
.ael-chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; width: 100%; box-sizing: border-box; }
.ael-chat-chip {
  border: 1px solid var(--ael-chat-brass);
  background: transparent;
  color: var(--ael-chat-gold);
  border-radius: 999px;
  padding: 7px 12px;
  font-family: var(--ael-chat-font);
  font-size: 13px;
  cursor: pointer;
}
.ael-chat-chip:hover { background: rgba(240, 200, 90, 0.12); }

/* ---------- Capture / interest form ---------- */
.ael-chat-form {
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  background: #17251d;
  border: 1px solid var(--ael-chat-line);
  border-radius: 14px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.ael-chat-form label { font-size: 12.5px; color: var(--ael-chat-cream-dim); }
.ael-chat-form input,
.ael-chat-form textarea {
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(159, 177, 165, 0.35);
  border-radius: 10px;
  background: var(--ael-chat-black);
  color: var(--ael-chat-cream);
  font-family: var(--ael-chat-font);
  font-size: 14.5px;
  padding: 9px 10px;
}
.ael-chat-form input:focus,
.ael-chat-form textarea:focus { outline: 2px solid var(--ael-chat-brass); outline-offset: 0; }
/* No native number-spinner controls may ever show inside the widget. */
.ael-chat-form input::-webkit-outer-spin-button,
.ael-chat-form input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.ael-chat-form input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.ael-chat-form button {
  border: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--ael-chat-gold), var(--ael-chat-brass));
  color: #1c1503;
  font-family: var(--ael-chat-font);
  font-size: 14.5px; font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}
.ael-chat-form .ael-chat-skip {
  background: transparent;
  color: var(--ael-chat-cream-dim);
  font-weight: 500;
  border: 1px solid rgba(159, 177, 165, 0.35);
}

/* ---------- Composer ---------- */
.ael-chat-foot {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid var(--ael-chat-line);
  background: var(--ael-chat-panel);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.ael-chat-demo-note { font-size: 11.5px; color: var(--ael-chat-cream-dim); padding: 0 2px 6px; width: 100%; box-sizing: border-box; }
.ael-chat-composer { display: flex; gap: 8px; align-items: flex-end; width: 100%; box-sizing: border-box; }
.ael-chat-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(159, 177, 165, 0.35);
  border-radius: 12px;
  background: var(--ael-chat-black);
  color: var(--ael-chat-cream);
  font-family: var(--ael-chat-font);
  font-size: 15px;
  line-height: 1.4;
  padding: 10px 12px;
  resize: none;
  max-height: 110px;
}
.ael-chat-input:focus { outline: 2px solid var(--ael-chat-brass); }
.ael-chat-send {
  flex: 0 0 auto;
  height: 42px; padding: 0 16px;
  border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--ael-chat-gold), var(--ael-chat-brass));
  color: #1c1503;
  font-family: var(--ael-chat-font);
  font-size: 14.5px; font-weight: 700;
  cursor: pointer;
}
.ael-chat-send:disabled { opacity: 0.55; cursor: default; }

/* ---------- Small screens: near-fullscreen panel ---------- */
@media (max-width: 480px) {
  .ael-chat-btn { right: 12px; bottom: 12px; }
  .ael-chat-panel {
    right: 0; bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ael-chat-typing span { animation: none; opacity: 0.7; }
}
