:root {
  --mg20-chat-blue: #0865f5;
  --mg20-chat-blue-dark: #0647bd;
  --mg20-chat-ink: #101a2f;
  --mg20-chat-muted: #687792;
  --mg20-chat-line: #d7e4f8;
  --mg20-chat-panel: #ffffff;
  --mg20-chat-soft: #f4f8ff;
}

#mgChatLauncher,
#mgChatPanel {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

#mgChatLauncher *,
#mgChatPanel * { box-sizing: border-box; }
#mgChatLauncher[hidden],#mgChatPanel[hidden] { display:none !important; }

#toggle-iframe-btn,
#custom-iframe-container { display: none !important; }

#mgChatLauncher {
  position: fixed;
  z-index: 2147481000;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.95);
  border-radius: 20px;
  color: #fff;
  background: #071c25;
  box-shadow: 0 16px 36px rgba(5,80,213,.32), 0 0 0 1px rgba(5,68,170,.12);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

#mgChatLauncher:hover { transform: translateY(-2px); box-shadow: 0 20px 42px rgba(5,80,213,.38); }
#mgChatLauncher:focus-visible { outline: 3px solid rgba(8,101,245,.28); outline-offset: 3px; }
.mg20-launch-logo { width:44px;height:44px;border-radius:15px;object-fit:cover;display:block; }
#mgChatLauncher .mg20-launch-icon { position:relative;width:24px;height:19px;border:2px solid #fff;border-radius:8px;font-size:0;line-height:1; }
#mgChatLauncher .mg20-launch-icon::after { content:"";position:absolute;left:3px;bottom:-6px;width:7px;height:7px;border-left:2px solid #fff;border-bottom:2px solid #fff;background:#0760e9;transform:skewY(-35deg); }
#mgChatLauncher .mg20-launch-online { position:absolute;right:3px;bottom:3px;width:11px;height:11px;border-radius:50%;background:#20c977;border:2px solid #fff; }
#mgChatLauncher .mg20-launch-badge { position:absolute;right:-5px;top:-7px;min-width:21px;height:21px;padding:0 5px;display:none;place-items:center;border-radius:999px;background:#ed2d38;color:#fff;border:2px solid #fff;font-size:11px;font-weight:900; }
#mgChatLauncher.has-unread .mg20-launch-badge { display:grid; }

#mgChatPanel {
  position: fixed;
  z-index: 2147481001;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(82px, calc(env(safe-area-inset-bottom) + 82px));
  width: min(392px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 110px));
  min-height: 430px;
  display: grid;
  grid-template-rows: auto auto minmax(0,1fr) auto auto auto auto;
  overflow: hidden;
  color: var(--mg20-chat-ink);
  background: var(--mg20-chat-panel);
  border: 1px solid rgba(188,208,240,.92);
  border-radius: 25px;
  box-shadow: 0 28px 80px rgba(10,30,70,.24), 0 4px 18px rgba(10,30,70,.10);
  transform: translateY(12px) scale(.98);
  transform-origin: left bottom;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .22s ease, opacity .2s ease, visibility .2s ease;
}

#mgChatPanel.is-open { transform: translateY(0) scale(1); opacity: 1; visibility: visible; pointer-events: auto; }

.mg20-chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 13px 14px;
  color: var(--mg20-chat-ink);
  background: #fff !important;
  border-bottom: 1px solid #dce7f6;
}

.mg20-chat-brand { width:43px;height:43px;display:grid;place-items:center;overflow:hidden;flex:0 0 auto;border-radius:15px;background:#081b25;color:#65f18a;border:1px solid rgba(255,255,255,.7);font-size:19px;font-weight:1000;box-shadow:0 7px 18px rgba(0,0,0,.18); }
.mg20-chat-brand img { width:100%;height:100%;object-fit:cover;display:block; }
.mg20-chat-head-copy { min-width:0;flex:1; }
.mg20-chat-head-copy strong { display:block;font-size:15px;line-height:1.25;font-weight:900;letter-spacing:-.015em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#142039!important; }
.mg20-chat-status { display:flex;align-items:center;gap:6px;margin-top:3px;font-size:11.5px;font-weight:750;color:#60718c!important; }
.mg20-chat-status::before { content:"";width:7px;height:7px;border-radius:50%;background:#6eff9c;box-shadow:0 0 0 3px rgba(110,255,156,.16); }
.mg20-chat-status.waiting::before { background:#ffd45c; }
.mg20-chat-status.closed::before { background:#d4e0f2; }
.mg20-chat-head-actions { display:flex;gap:5px; }
.mg20-chat-icon-btn { width:34px;height:34px;display:grid;place-items:center;border:1px solid #d5e3f7;border-radius:12px;background:#f4f8ff;color:#075ee8;font-size:19px;line-height:1;cursor:pointer; }
.mg20-chat-icon-btn:hover { background:#e8f1ff; }

.mg20-chat-notice { display:none;padding:9px 13px;border-bottom:1px solid #dfeaff;background:#f3f7ff;color:#36527d;font-size:11.5px;font-weight:750;line-height:1.35;text-align:center; }
.mg20-chat-notice.is-visible { display:block; }
.mg20-chat-notice.human { background:#ecfdf5;color:#08734b;border-color:#c9f3df; }
.mg20-chat-notice.waiting { background:#fffbeb;color:#8a5910;border-color:#f8e7ae; }

.mg20-chat-messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 15px 12px 20px;
  background:
    radial-gradient(circle at 90% 0, rgba(8,101,245,.055), transparent 34%),
    linear-gradient(#fbfdff, #f6f9fe);
}
.mg20-chat-messages::-webkit-scrollbar { width:6px; }
.mg20-chat-messages::-webkit-scrollbar-thumb { background:#c8d8ee;border-radius:99px; }

.mg20-message { display:flex;align-items:flex-end;gap:7px;margin:0 0 11px; }
.mg20-message.customer { justify-content:flex-end; }
.mg20-message.system { justify-content:center; }
.mg20-msg-avatar { width:29px;height:29px;display:grid;place-items:center;overflow:hidden;flex:0 0 auto;border:2px solid #fff;border-radius:10px;background:#071c25;color:#61ed87;font-size:10px;font-weight:1000;box-shadow:0 4px 12px rgba(20,35,55,.14); }
.mg20-msg-avatar img { width:100%;height:100%;display:block;object-fit:cover; }
.mg20-msg-avatar.customer { color:#075ee8;background:#e6efff; }
.mg20-msg-wrap { max-width:82%; }
.mg20-msg-name { display:block;margin:0 0 4px 3px;color:#6d7c92;font-size:10px;font-weight:850; }
.mg20-msg-bubble { padding:10px 11px;border:1px solid #e1e9f5;border-radius:16px 16px 16px 5px;background:#fff;color:#172238;font-size:13.2px;line-height:1.43;box-shadow:0 5px 14px rgba(20,50,90,.05);overflow-wrap:anywhere; }
.mg20-message.customer .mg20-msg-bubble { border-color:#0865f5;border-radius:16px 16px 5px 16px;background:linear-gradient(145deg,#0876ff,#0860eb);color:#fff;box-shadow:0 7px 18px rgba(8,101,245,.18); }
.mg20-message.pending .mg20-msg-bubble { opacity:.7; }
.mg20-message.system .mg20-msg-wrap { max-width:92%; }
.mg20-message.system .mg20-msg-bubble { padding:7px 11px;border:0;border-radius:999px;background:#e8f0fd;color:#536781;font-size:10.5px;font-weight:800;text-align:center;box-shadow:none; }
.mg20-msg-bubble a { color:inherit;font-weight:850;text-decoration:underline;text-underline-offset:2px; }
.mg20-msg-time { display:block;margin:4px 4px 0;color:#91a0b5;font-size:9.5px;text-align:left; }
.mg20-message.customer .mg20-msg-time { text-align:right; }

.mg20-products { display:grid;grid-auto-flow:column;grid-auto-columns:minmax(188px,82%);gap:8px;overflow-x:auto;padding:8px 0 3px;scroll-snap-type:x mandatory; }
.mg20-product { display:grid;grid-template-columns:64px minmax(0,1fr);min-height:76px;overflow:hidden;border:1px solid #dce7f7;border-radius:15px;background:#fff;color:#142039;text-decoration:none;box-shadow:0 5px 14px rgba(25,53,90,.06);scroll-snap-align:start; }
.mg20-product img { width:64px;height:100%;min-height:76px;object-fit:cover;background:#edf3fb; }
.mg20-product-copy { min-width:0;padding:9px 8px; }
.mg20-product-copy b { display:-webkit-box;overflow:hidden;font-size:11px;line-height:1.25;-webkit-line-clamp:2;-webkit-box-orient:vertical; }
.mg20-product-copy strong { display:block;margin-top:5px;color:#0860e7;font-size:12.5px; }
.mg20-product-copy span { display:block;margin-top:2px;color:#73829a;font-size:9.5px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.mg20-message-links { display:flex;flex-wrap:wrap;gap:6px;margin-top:8px; }
.mg20-message-links a { display:inline-flex;align-items:center;min-height:31px;padding:7px 10px;border:1px solid #bcd3f5;border-radius:10px;color:#0755c7;background:#fff;font-size:10px;font-weight:900;text-decoration:none;box-shadow:0 3px 9px rgba(25,53,90,.05); }
.mg20-message-links a:hover { border-color:#0865f5;background:#edf5ff; }

.mg20-typing { display:none;align-items:center;gap:8px;padding:0 14px 9px;background:#f6f9fe;color:#708099;font-size:10.5px;font-weight:750; }
.mg20-typing.is-visible { display:flex; }
.mg20-typing-dots { display:flex;gap:3px; }
.mg20-typing-dots i { width:5px;height:5px;border-radius:50%;background:#4d79bd;animation:mg20Typing 1s infinite ease-in-out; }
.mg20-typing-dots i:nth-child(2){animation-delay:.14s}.mg20-typing-dots i:nth-child(3){animation-delay:.28s}
@keyframes mg20Typing { 0%,70%,100%{transform:translateY(0);opacity:.4}35%{transform:translateY(-3px);opacity:1} }

.mg20-chat-quick { display:flex;gap:7px;overflow-x:auto;padding:9px 11px 7px;border-top:1px solid #e7eef8;background:#fff; }
.mg20-chat-quick button { flex:0 0 auto;border:1px solid #bfd4f6;border-radius:999px;padding:7px 10px;background:#f6f9ff;color:#164d9b;font-size:10.5px;font-weight:850;cursor:pointer; }
.mg20-chat-quick button:hover { background:#eaf2ff; }
#mgChatHumanQuick[hidden] { display:none!important; }
.mg20-chat-composer { display:flex;align-items:flex-end;gap:7px;padding:9px 10px calc(9px + env(safe-area-inset-bottom));background:#fff; }
.mg20-chat-composer textarea { width:100%;height:42px;max-height:105px;resize:none;border:1px solid #cbdcf3;border-radius:15px;padding:10px 12px;background:#f9fbff;color:#152238;font:inherit;font-size:13px;line-height:1.35;outline:none; }
.mg20-chat-composer textarea:focus { border-color:#6aa4ff;box-shadow:0 0 0 3px rgba(8,101,245,.09);background:#fff; }
.mg20-chat-send { width:42px;height:42px;display:grid;place-items:center;flex:0 0 auto;border:0;border-radius:15px;background:#0865f5;color:#fff;font-size:18px;font-weight:900;cursor:pointer;box-shadow:0 8px 18px rgba(8,101,245,.24); }
.mg20-chat-send:disabled,.mg20-chat-composer textarea:disabled { opacity:.55;cursor:not-allowed; }
.mg20-chat-new { display:none;margin:9px 11px 11px;border:0;border-radius:14px;padding:11px;background:#0865f5;color:#fff;font-size:12px;font-weight:900;cursor:pointer; }
#mgChatPanel.is-closed .mg20-chat-new { display:block; }
#mgChatPanel.is-closed .mg20-chat-quick,
#mgChatPanel.is-closed .mg20-chat-composer { display:none; }

/* O menu V19 usa fundo branco no mobile; estes seletores mantêm todos os rótulos legíveis. */
#slide-menu-inicio .mg-inicio-menu-title,
#slide-menu-inicio .mg-inicio-menu-item,
#slide-menu-inicio .mg-inicio-menu-item span,
#slide-menu-inicio .mg-inicio-account-name,
#slide-menu-inicio .mg-inicio-account-link,
#slide-menu-inicio .mg-inicio-menu-label,
#slide-menu-inicio .mg-inicio-menu-small,
#slide-menu-inicio a:not(.mg-inicio-cart-link):not(.mg-inicio-logout):not(.mg-inicio-logout-link) { color:#17233b !important; }
#slide-menu-inicio .mg-inicio-menu-item i,
#slide-menu-inicio .mg-inicio-menu-item svg { color:#1670ef !important;fill:currentColor; }
#slide-menu-inicio .mg-inicio-cart-link,
#slide-menu-inicio .mg-inicio-cart-link span,
#slide-menu-inicio .mg-inicio-cart-link i,
#slide-menu-inicio .mg-inicio-logout,
#slide-menu-inicio .mg-inicio-logout span,
#slide-menu-inicio .mg-inicio-logout i,
#slide-menu-inicio .mg-inicio-logout-link,
#slide-menu-inicio .mg-inicio-logout-link span,
#slide-menu-inicio .mg-inicio-logout-link i { color:#fff !important; }

html.mg19-menu-open #mgChatLauncher,
html.mg19-menu-open #mgChatPanel,
html.mg19-interface-busy #mgChatLauncher,
html.mg19-interface-busy #mgChatPanel,
body.mg-modal-open #mgChatLauncher,
body.mg-modal-open #mgChatPanel { opacity:0 !important;visibility:hidden !important;pointer-events:none !important; }

@media (max-width: 899px) {
  #mgChatLauncher { left:max(10px,env(safe-area-inset-left));bottom:calc(74px + env(safe-area-inset-bottom));width:52px;height:52px;border-radius:18px; }
  #mgChatPanel { left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right));bottom:calc(72px + env(safe-area-inset-bottom));width:auto;height:min(590px,calc(100dvh - 142px));min-height:360px;border-radius:21px; }
  #mgChatPanel.is-open + #mgChatLauncher,
  html.mg20-chat-open #mgChatLauncher { opacity:0;visibility:hidden;pointer-events:none; }
  .mg20-chat-head { min-height:64px;padding:10px 12px; }
  .mg20-chat-brand { width:39px;height:39px;border-radius:13px; }
  .mg20-chat-messages { padding:12px 10px 16px; }
  .mg20-msg-wrap { max-width:85%; }
}

@media (max-width: 380px) {
  #mgChatPanel { bottom:calc(68px + env(safe-area-inset-bottom));height:calc(100dvh - 126px);min-height:0; }
  .mg20-chat-head-actions .mg20-chat-close-session { display:none; }
  .mg20-chat-quick { padding-block:7px 5px; }
}

@media (prefers-reduced-motion: reduce) {
  #mgChatLauncher,#mgChatPanel,.mg20-typing-dots i { transition:none;animation:none; }
}
