/* ============================================================
   MEGAPOWER — Widget de chat en direct
   ============================================================ */
.mgp-chat, .mgp-chat * { box-sizing: border-box; }
.mgp-chat {
  --mgp-blue: #00b4ff;
  --mgp-bg: #0d1830;
  --mgp-bg2: #0a1226;
  --mgp-text: #e8f4ff;
  --mgp-muted: rgba(232, 244, 255, .55);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99998;
  font-family: 'DM Sans', system-ui, -apple-system, Arial, sans-serif;
}

/* Pastille */
.mgp-chat-toggle {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .8rem 1.15rem;
  background: var(--mgp-blue);
  color: #001018;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 180, 255, .4);
  transition: transform .18s ease, box-shadow .18s ease;
}
.mgp-chat-toggle:hover { transform: translateY(-2px); box-shadow: 0 12px 38px rgba(0, 180, 255, .55); }
.mgp-chat-toggle i { font-size: 1.05rem; }
.mgp-chat-toggle .mgp-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #16d67a; box-shadow: 0 0 0 0 rgba(22, 214, 122, .6);
  animation: mgp-pulse 2s infinite;
}
@keyframes mgp-pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 214, 122, .6); }
  70% { box-shadow: 0 0 0 8px rgba(22, 214, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 214, 122, 0); }
}

/* Panneau */
.mgp-chat-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 110px);
  background: var(--mgp-bg);
  border: 1px solid rgba(0, 180, 255, .25);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.mgp-chat.open .mgp-chat-panel { display: flex; }
.mgp-chat.open .mgp-chat-toggle { display: none; }

.mgp-chat-head {
  padding: 1rem 1.15rem;
  background: linear-gradient(135deg, #001a3e, #003060);
  border-bottom: 2px solid var(--mgp-blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mgp-chat-head h3 { margin: 0; color: var(--mgp-text); font-size: 1.05rem; font-weight: 700; }
.mgp-chat-head .mgp-sub { margin: 2px 0 0; font-size: .78rem; color: var(--mgp-muted); }
.mgp-chat-close { background: none; border: none; color: var(--mgp-text); font-size: 1.3rem; cursor: pointer; line-height: 1; opacity: .7; }
.mgp-chat-close:hover { opacity: 1; }

.mgp-chat-body {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  background: var(--mgp-bg2);
}
.mgp-msg { max-width: 82%; padding: .6rem .85rem; border-radius: 12px; font-size: .9rem; line-height: 1.45; word-wrap: break-word; }
.mgp-msg.visitor { align-self: flex-end; background: var(--mgp-blue); color: #001018; border-bottom-right-radius: 4px; }
.mgp-msg.agent, .mgp-msg.system { align-self: flex-start; background: rgba(255, 255, 255, .07); color: var(--mgp-text); border-bottom-left-radius: 4px; }
.mgp-msg.system { font-size: .82rem; color: var(--mgp-muted); background: transparent; border: 1px dashed rgba(0,180,255,.2); align-self: center; text-align: center; }

.mgp-chat-foot { padding: .75rem; border-top: 1px solid rgba(0, 180, 255, .15); background: var(--mgp-bg); }
.mgp-chat-intro { display: block; }
.mgp-chat-intro input {
  width: 100%; margin-bottom: .5rem; padding: .55rem .7rem;
  background: var(--mgp-bg2); border: 1px solid rgba(0, 180, 255, .25);
  border-radius: 8px; color: var(--mgp-text); font-size: .88rem;
}
.mgp-chat-row { display: flex; gap: .5rem; }
.mgp-chat-row textarea {
  flex: 1; resize: none; height: 42px; max-height: 90px; padding: .6rem .7rem;
  background: var(--mgp-bg2); border: 1px solid rgba(0, 180, 255, .25);
  border-radius: 8px; color: var(--mgp-text); font-size: .9rem; font-family: inherit;
}
.mgp-chat-row button {
  width: 44px; border: none; border-radius: 8px; background: var(--mgp-blue);
  color: #001018; font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
}
.mgp-chat-row button:disabled { opacity: .5; cursor: default; }
.mgp-err { margin: 0 2px .5rem; font-size: .8rem; color: #ff6b8a; font-weight: 500; }
.mgp-chat-foot .mgp-legal { margin: .45rem 2px 0; font-size: .68rem; color: var(--mgp-muted); }
@media (prefers-reduced-motion: reduce) { .mgp-chat-toggle, .mgp-chat-toggle .mgp-dot { transition: none; animation: none; } }

/* Mobile : panneau quasi plein écran, pastille confortable au pouce */
@media (max-width: 480px) {
  .mgp-chat { right: 12px; bottom: 12px; }
  .mgp-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100dvh - 88px);
    max-height: calc(100dvh - 88px);
    bottom: 60px;
  }
  .mgp-chat-toggle { padding: .75rem 1.05rem; font-size: .92rem; }
}
