/* ── MEA Floating Chat Widget ── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600&display=swap');

:root {
  --ea-primary:    #102130;
  --ea-primary-d:  #0a1820;
  --ea-primary-l:  #e4eaf0;
  --ea-surface:    #ffffff;
  --ea-bg:         #f8fafc;
  --ea-border:     #e2e8f0;
  --ea-text:       #1e293b;
  --ea-muted:      #64748b;
  --ea-bot-bg:     #f1f5f9;
  --ea-bot-c:      #1e293b;
  --ea-user-bg:    #102130;
  --ea-user-c:     #ffffff;
  --ea-radius:     20px;
  --ea-shadow:     0 8px 40px rgba(16,33,48,.22), 0 2px 8px rgba(0,0,0,.08);
  --ea-w:          380px;
  --ea-h:          540px;
  --ea-gap:        20px;           /* distance from viewport edges */
  --ea-font:       'Plus Jakarta Sans', system-ui, sans-serif;
}

/* ── FAB (Floating Action Button) ────────────────────────────── */
#ea-fab {
  position: fixed;
  bottom: var(--ea-gap);
  right: var(--ea-gap);
  z-index: 99999;
  width: 60px;
  height: 60px;
  background: var(--ea-primary);
  border-radius: 50%;
  box-shadow: 0 4px 20px rgba(16,33,48,.4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .2s, box-shadow .2s, background .2s;
  user-select: none;
  outline: none;
  font-family: var(--ea-font);
}
#ea-fab:hover  { transform: scale(1.07); box-shadow: 0 6px 28px rgba(16,33,48,.5); background: var(--ea-primary-d); }
#ea-fab:active { transform: scale(.96); }
#ea-fab:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

#ea-fab svg {
  width: 26px; height: 26px;
  color: #fff;
  stroke: #fff;
  flex-shrink: 0;
}
#ea-fab-label {
  font-size: .6rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  letter-spacing: .03em;
  line-height: 1;
}

/* ── Chat Window ──────────────────────────────────────────────── */
#ea-chatbox {
  position: fixed;
  bottom: calc(var(--ea-gap) + 70px);
  right: var(--ea-gap);
  z-index: 99998;
  width: var(--ea-w);
  max-height: var(--ea-h);
  display: flex;
  flex-direction: column;
  background: var(--ea-surface);
  border-radius: var(--ea-radius);
  box-shadow: var(--ea-shadow);
  overflow: hidden;
  font-family: var(--ea-font);
  border: 1px solid rgba(26,86,219,.12);

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#ea-chatbox.ea-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────────────── */
#ea-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ea-primary);
  flex-shrink: 0;
}
#ea-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: grid; place-items: center;
  font-size: 19px;
  flex-shrink: 0;
}
#ea-header-info { flex: 1; line-height: 1.25; overflow: hidden; }
#ea-header-info strong {
  display: block;
  color: #fff;
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ea-status {
  font-size: .7rem;
  color: rgba(255,255,255,.75);
  display: flex; align-items: center; gap: 4px;
}
#ea-status::before {
  content: '';
  width: 6px; height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

#ea-header-actions { display: flex; gap: 4px; }
#ea-header-actions button {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.15);
  border: none; border-radius: 8px;
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s;
  padding: 0;
}
#ea-header-actions button:hover { background: rgba(255,255,255,.28); }
#ea-header-actions button svg { width: 15px; height: 15px; stroke: #fff; }

/* ── Messages area ────────────────────────────────────────────── */
#ea-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ea-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
#ea-messages::-webkit-scrollbar { width: 4px; }
#ea-messages::-webkit-scrollbar-track { background: transparent; }
#ea-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── Message bubbles ──────────────────────────────────────────── */
.ea-msg {
  display: flex;
  gap: 8px;
  animation: ea-in .22s ease both;
}
@keyframes ea-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ea-msg.ea-user { flex-direction: row-reverse; }

.ea-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
  background: var(--ea-primary-l);
}
.ea-msg.ea-user .ea-icon { background: #e2e8f0; }

.ea-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: .85rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.ea-msg.ea-bot  .ea-bubble {
  background: var(--ea-bot-bg);
  color: var(--ea-bot-c);
  border-top-left-radius: 4px;
}
.ea-msg.ea-user .ea-bubble {
  background: var(--ea-user-bg);
  color: var(--ea-user-c);
  border-top-right-radius: 4px;
}
.ea-bubble time {
  display: block;
  font-size: .68rem;
  opacity: .5;
  margin-top: 5px;
  text-align: right;
}
.ea-error { color: #ef4444; font-size: .82rem; }

/* ── Typing indicator ─────────────────────────────────────────── */
#ea-typing {
  padding: 0 16px 10px;
  background: var(--ea-bg);
  display: flex; gap: 4px; align-items: center;
  flex-shrink: 0;
}
#ea-typing span {
  width: 7px; height: 7px;
  background: var(--ea-muted);
  border-radius: 50%;
  animation: ea-bounce .9s infinite;
}
#ea-typing span:nth-child(2) { animation-delay: .15s; }
#ea-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes ea-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* ── Input form ───────────────────────────────────────────────── */
#ea-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ea-border);
  background: var(--ea-surface);
  flex-shrink: 0;
}
#ea-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--ea-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--ea-font);
  font-size: .85rem;
  color: var(--ea-text);
  background: var(--ea-bg);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color .2s;
}
#ea-input:focus { border-color: var(--ea-primary); }
#ea-send {
  width: 40px; height: 40px;
  background: var(--ea-primary);
  border: none; border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s, transform .1s;
  color: #fff;
  padding: 0;
}
#ea-send:hover  { background: var(--ea-primary-d); }
#ea-send:active { transform: scale(.93); }
#ea-send:disabled { opacity: .45; cursor: not-allowed; }
#ea-send svg { width: 17px; height: 17px; stroke: #fff; display: block; }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --ea-gap: 12px;
  }
  #ea-chatbox {
    /* Full-screen style on mobile */
    width: calc(100vw - 24px);
    max-height: 70vh;
    bottom: calc(var(--ea-gap) + 68px);
    right: 12px;
    border-radius: 16px;
  }
  #ea-fab {
    width: 54px;
    height: 54px;
  }
  #ea-fab svg { width: 22px; height: 22px; }
  #ea-fab-label { font-size: .55rem; }
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
  #ea-chatbox { transition: none; }
  .ea-msg      { animation: none; }
  #ea-typing span { animation: none; }
}
