/* ==========================================================================
   Mogara Chat widget — scoped to #mgc-chat
   ========================================================================== */
#mgc-chat, #mgc-chat *, #mgc-chat *::before, #mgc-chat *::after { box-sizing: border-box; }
#mgc-chat {
  --pri: #7c3aed; --pri-d: #6d28d9; --navy: #050425; --tx: #12132e; --mut: #5b6079; --bd: #e7e5f2;
  --wa: #25d366; --wa-d: #128c7e; --on: #10b981;
  --ease: cubic-bezier(.22, 1, .36, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --bottom: 24px;
  font-family: 'Arimo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
#mgc-chat button, #mgc-chat input, #mgc-chat textarea {
  font-family: inherit; margin: 0; box-shadow: none; text-transform: none; letter-spacing: normal; line-height: normal; min-height: 0;
}
#mgc-chat button { border: 0; background: none; cursor: pointer; padding: 0; color: inherit; }
#mgc-chat a { text-decoration: none; }
#mgc-chat p, #mgc-chat h3, #mgc-chat ul, #mgc-chat li, #mgc-chat form, #mgc-chat label { margin: 0; padding: 0; list-style: none; }
#mgc-chat svg { display: block; flex: none; }
#mgc-chat img { max-width: none; border: 0; margin: 0; }
#mgc-chat [hidden] { display: none !important; }

/* stack above the Guided Discovery help button when both are on a page */
#mgc-chat.mgc-stack { --bottom: 96px; }

/* ---------- avatar ---------- */
#mgc-chat .mgc-av { position: relative; width: 44px; height: 44px; flex: none; border-radius: 50%; background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
#mgc-chat .mgc-av img { width: 100% !important; height: 100% !important; border-radius: 50% !important; object-fit: cover !important; object-position: center top !important; display: block !important; }
#mgc-chat .mgc-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; background: #9a9db8; border: 2.5px solid #0e0d2d; }
#mgc-chat.is-online .mgc-dot { background: var(--on); }
#mgc-chat.is-online .mgc-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--on); animation: mgcPulse 1.9s ease-out infinite; }

/* ---------- floating button ---------- */
#mgc-chat .mgc-fab {
  position: fixed; right: 24px; bottom: calc(var(--bottom) + env(safe-area-inset-bottom, 0px)); z-index: 99960;
  display: inline-flex; align-items: center; gap: 11px;
  padding: 7px 20px 7px 7px !important; border-radius: 999px !important;
  background: linear-gradient(160deg, #17134a 0%, #0e0d2d 70%) !important; color: #fff !important;
  border: 1px solid rgba(167, 139, 250, .45) !important;
  box-shadow: 0 20px 44px -14px rgba(5, 4, 37, .7), 0 0 0 6px rgba(124, 58, 237, .12) !important;
  opacity: 0; transform: translateY(24px) scale(.96); pointer-events: none;
  transition: opacity .45s var(--ease), transform .55s var(--ease), box-shadow .3s ease, bottom .4s var(--ease);
}
#mgc-chat .mgc-fab.is-show { opacity: 1; transform: none; pointer-events: auto; }
#mgc-chat .mgc-fab:hover { transform: translateY(-3px); box-shadow: 0 26px 50px -14px rgba(5, 4, 37, .75), 0 0 0 7px rgba(124, 58, 237, .2) !important; }
#mgc-chat .mgc-fab:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 3px; }
#mgc-chat .mgc-fabTx { display: flex; flex-direction: column; gap: 2px; text-align: left; }
#mgc-chat .mgc-fabTx small { font-size: 11.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: #c4b5fd; }
#mgc-chat .mgc-fabTx b { font-size: 15px; font-weight: 700; color: #fff; }
#mgc-chat .mgc-fabIc { display: none; }
#mgc-chat .mgc-badge {
  position: absolute; left: 36px; top: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center; background: #ef4444; color: #fff; font-size: 11.5px; font-weight: 700; border: 2px solid #0e0d2d;
  animation: mgcPop .5s var(--spring);
}
#mgc-chat.is-open .mgc-fab,
#mgc-chat.mgc-at-end .mgc-fab { opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; }

/* one-time greeting bubble */
#mgc-chat .mgc-hello {
  position: fixed; right: 24px; bottom: calc(var(--bottom) + 72px + env(safe-area-inset-bottom, 0px)); z-index: 99960;
  max-width: 270px; padding: 14px 40px 14px 16px; border-radius: 16px 16px 4px 16px;
  background: #fff; color: var(--tx); border: 1px solid var(--bd);
  box-shadow: 0 18px 40px -16px rgba(5, 4, 37, .45);
  font-size: 14px; line-height: 1.45; cursor: pointer;
  opacity: 0; transform: translateY(10px) scale(.97); pointer-events: none; transform-origin: bottom right;
  transition: opacity .35s ease, transform .45s var(--ease);
}
#mgc-chat .mgc-hello.is-show { opacity: 1; transform: none; pointer-events: auto; }
#mgc-chat .mgc-hello b { display: block; font-size: 14.5px; color: var(--navy); margin-bottom: 2px; }
#mgc-chat .mgc-helloX { position: absolute; right: 8px; top: 8px; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: #8a8fa8; }
#mgc-chat .mgc-helloX:hover { background: #f3f2f8; color: var(--tx); }

/* ---------- panel ---------- */
#mgc-chat .mgc-panel {
  position: fixed; right: 24px; bottom: calc(var(--bottom) + env(safe-area-inset-bottom, 0px)); z-index: 99965;
  width: 380px; max-height: calc(100vh - 48px); overflow: hidden;
  display: flex; flex-direction: column;
  border-radius: 22px; background: #fff;
  box-shadow: 0 40px 90px -30px rgba(5, 4, 37, .7), 0 0 0 1px rgba(124, 58, 237, .12);
  opacity: 0; transform: translateY(18px) scale(.96); transform-origin: bottom right; pointer-events: none;
  transition: opacity .3s ease, transform .45s var(--ease);
}
#mgc-chat.is-open .mgc-panel { opacity: 1; transform: none; pointer-events: auto; }

#mgc-chat .mgc-top {
  position: relative; overflow: hidden; flex: none;
  padding: 22px 22px 20px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(124, 58, 237, .5), transparent 60%),
    linear-gradient(165deg, #17134a 0%, #050425 78%);
  color: #fff;
}
#mgc-chat .mgc-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(167, 139, 250, .5), transparent); }
#mgc-chat .mgc-x {
  position: absolute; right: 14px; top: 14px; z-index: 1; width: 34px; height: 34px; border-radius: 50% !important;
  display: grid !important; place-items: center; color: #fff !important; background: rgba(255, 255, 255, .08) !important;
  transition: background-color .2s ease, transform .3s var(--ease);
}
#mgc-chat .mgc-x:hover { background: rgba(255, 255, 255, .18) !important; transform: rotate(90deg); }
#mgc-chat .mgc-x:focus-visible, #mgc-chat .mgc-back:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
#mgc-chat .mgc-host { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
#mgc-chat .mgc-host .mgc-av { width: 48px; height: 48px; box-shadow: 0 0 0 2px #0e0d2d, 0 0 0 4px rgba(167, 139, 250, .6); }
#mgc-chat .mgc-hostTx { display: flex; flex-direction: column; gap: 3px; }
#mgc-chat .mgc-hostTx b { font-size: 15.5px; color: #fff; }
#mgc-chat .mgc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #b9bcd6; }
#mgc-chat .mgc-status i { width: 7px; height: 7px; border-radius: 50%; background: #9a9db8; }
#mgc-chat.is-online .mgc-status { color: #a7f3d0; }
#mgc-chat.is-online .mgc-status i { background: var(--on); }
#mgc-chat .mgc-title { font-family: 'Oswald', 'Arial Narrow', Arial, sans-serif; font-weight: 600; font-size: 27px; line-height: 1.15; color: #fff; }
#mgc-chat .mgc-title em { font-style: normal; background: linear-gradient(90deg, #a78bfa, #e879f9); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
#mgc-chat .mgc-lead { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: #c9cbe4; }

#mgc-chat .mgc-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; background: #faf9fe; }

/* option cards */
#mgc-chat .mgc-opts { display: grid; gap: 10px; }
#mgc-chat .mgc-opt {
  width: 100%; display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 13px 14px !important; border-radius: 14px !important;
  background: #fff !important; border: 1px solid var(--bd) !important; color: var(--tx) !important;
  transition: border-color .2s ease, transform .3s var(--ease), box-shadow .3s ease;
}
#mgc-chat .mgc-opt:hover { border-color: #cbbdfb !important; transform: translateY(-2px); box-shadow: 0 12px 24px -16px rgba(76, 29, 149, .5); }
#mgc-chat .mgc-opt:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
#mgc-chat .mgc-optIc { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; background: #f1ecff; color: var(--pri); }
#mgc-chat .mgc-optIc svg { width: 21px; height: 21px; }
#mgc-chat .mgc-opt--wa .mgc-optIc { background: var(--wa); color: #fff; }
#mgc-chat .mgc-opt--live .mgc-optIc { background: linear-gradient(135deg, #7c3aed, #6d28d9); color: #fff; }
#mgc-chat .mgc-optTx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#mgc-chat .mgc-optTx b { font-size: 15px; font-weight: 700; color: var(--navy); }
#mgc-chat .mgc-optTx small { font-size: 12.5px; color: var(--mut); line-height: 1.35; }
#mgc-chat .mgc-tag { flex: none; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #e7f8f0; color: #0b7a45; }
#mgc-chat .mgc-arrow { flex: none; color: #b3aed0; transition: transform .3s var(--ease), color .2s ease; }
#mgc-chat .mgc-opt:hover .mgc-arrow { transform: translateX(3px); color: var(--pri); }

#mgc-chat .mgc-foot { flex: none; padding: 11px 16px 13px; border-top: 1px solid #efedf7; background: #fff; text-align: center; font-size: 12px; color: var(--mut); }
#mgc-chat .mgc-foot span { color: #f5b400; letter-spacing: 1px; margin-right: 4px; }

/* staggered entrance of the options */
#mgc-chat .mgc-in { opacity: 0; transform: translateY(8px); }
#mgc-chat.is-open .mgc-in { opacity: 1; transform: none; transition: opacity .35s ease calc(.08s + var(--d, 0) * 55ms), transform .45s var(--ease) calc(.08s + var(--d, 0) * 55ms), border-color .2s ease, box-shadow .3s ease; }

/* ---------- message view ---------- */
#mgc-chat .mgc-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 13px; font-weight: 700; color: var(--pri) !important; }
#mgc-chat .mgc-bubble {
  position: relative; max-width: 88%; margin-bottom: 14px; padding: 11px 14px; border-radius: 16px 16px 16px 5px;
  background: #fff; border: 1px solid var(--bd); font-size: 14px; line-height: 1.5; color: var(--tx);
  box-shadow: 0 6px 16px -12px rgba(5, 4, 37, .3);
}
#mgc-chat .mgc-form { display: grid; gap: 10px; }
#mgc-chat .mgc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#mgc-chat .mgc-field input, #mgc-chat .mgc-field textarea {
  width: 100%; display: block; padding: 11px 13px !important; border-radius: 11px !important;
  border: 1px solid var(--bd) !important; background: #fff !important; color: var(--tx) !important;
  font-size: 15px !important; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
#mgc-chat .mgc-field textarea { min-height: 96px; resize: vertical; line-height: 1.5 !important; }
#mgc-chat .mgc-field input:focus, #mgc-chat .mgc-field textarea:focus { border-color: var(--pri) !important; box-shadow: 0 0 0 3px rgba(124, 58, 237, .14) !important; }
#mgc-chat .mgc-field input::placeholder, #mgc-chat .mgc-field textarea::placeholder { color: #8a8fa8; }
#mgc-chat .mgc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
#mgc-chat .mgc-send {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 18px !important; border-radius: 12px !important;
  background: linear-gradient(90deg, #6d28d9 0%, #7c3aed 55%, #9b5cf6 100%) !important; color: #fff !important;
  font-size: 15px; font-weight: 700; box-shadow: 0 12px 26px -12px rgba(124, 58, 237, .85);
  transition: transform .3s var(--ease), opacity .2s ease;
}
#mgc-chat .mgc-send:hover { transform: translateY(-1px); }
#mgc-chat .mgc-send[disabled] { opacity: .6; cursor: default; transform: none; }
#mgc-chat .mgc-send:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
#mgc-chat .mgc-err { font-size: 13px; color: #dc2626; }
#mgc-chat .mgc-note { font-size: 12px; color: var(--mut); text-align: center; }
#mgc-chat .mgc-done { text-align: center; padding: 18px 6px 8px; }
#mgc-chat .mgc-doneIc { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: #e7f8f0; color: #0b7a45; animation: mgcPop .6s var(--spring); }
#mgc-chat .mgc-done h3 { font-family: 'Oswald', 'Arial Narrow', Arial, sans-serif; font-weight: 600; font-size: 22px; color: var(--navy); margin-bottom: 6px; }
#mgc-chat .mgc-done p { font-size: 14px; line-height: 1.55; color: var(--mut); }
#mgc-chat .mgc-done .mgc-opt { margin-top: 16px; }

@keyframes mgcPulse { from { transform: scale(1); opacity: .8; } to { transform: scale(2.1); opacity: 0; } }
@keyframes mgcPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- phones: round button + bottom sheet ---------- */
@media (max-width: 640px) {
  #mgc-chat { --bottom: 14px; }
  #mgc-chat.mgc-stack { --bottom: 82px; }
  #mgc-chat .mgc-fab { right: 14px; padding: 5px !important; gap: 0; }
  #mgc-chat .mgc-fab .mgc-av { width: 50px; height: 50px; }
  #mgc-chat .mgc-fabTx { display: none; }
  #mgc-chat .mgc-fabIc { display: grid; place-items: center; position: absolute; left: -5px; top: -5px; width: 24px; height: 24px; border-radius: 50%; background: var(--pri); color: #fff; border: 2px solid #fff; }
  #mgc-chat .mgc-fabIc svg { width: 12px; height: 12px; }
  #mgc-chat .mgc-badge { left: auto; right: -4px; top: -4px; }
  #mgc-chat .mgc-hello { right: 14px; left: 14px; max-width: none; bottom: calc(var(--bottom) + 70px + env(safe-area-inset-bottom, 0px)); }
  #mgc-chat .mgc-panel { right: 0; left: 0; bottom: 0; width: 100%; max-height: 88vh; border-radius: 22px 22px 0 0; transform: translateY(100%); }
  #mgc-chat.is-open .mgc-panel { transform: none; }
  #mgc-chat .mgc-panel::before { content: ""; position: absolute; left: 50%; top: 8px; z-index: 2; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: rgba(255, 255, 255, .35); }
  #mgc-chat .mgc-scrim { position: fixed; inset: 0; z-index: 99962; background: rgba(5, 4, 37, .55); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
  #mgc-chat.is-open .mgc-scrim { opacity: 1; pointer-events: auto; }
  #mgc-chat .mgc-top { padding: 24px 18px 18px; }
  #mgc-chat .mgc-foot { padding-bottom: calc(13px + env(safe-area-inset-bottom, 0px)); }
  #mgc-chat .mgc-row { grid-template-columns: 1fr; }
}
@media (min-width: 641px) { #mgc-chat .mgc-scrim { display: none; } }

@media (prefers-reduced-motion: reduce) {
  #mgc-chat *, #mgc-chat *::before, #mgc-chat *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
