/* ============================================================
   EmailHelp — chat widget styles (css/chat.css)
   ------------------------------------------------------------
   Everything here is namespaced .mm-chat* (widget), .mm-toast*
   (MM.toast) and .chat-demo* (hero mockup defaults). Design
   tokens come from css/style.css; every var() carries a fallback
   so the widget still renders if loaded on its own.
   ============================================================ */

.mm-chat {
  --mmc-primary: var(--primary, #6366F1);
  --mmc-grad: var(--grad, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #22D3EE 100%));
  --mmc-dark: var(--bg-dark-2, #0D1425);
  --mmc-text: var(--text, #0F172A);
  --mmc-muted: var(--text-muted, #5B6B84);
  --mmc-on-dark: var(--text-on-dark, #F8FAFC);
  --mmc-muted-dark: var(--text-muted-dark, #9AA8BF);
  --mmc-border: var(--border, rgba(15, 23, 42, .08));
  --mmc-radius: var(--radius, 16px);
  --mmc-radius-lg: var(--radius-lg, 24px);
  --mmc-ease: var(--ease, cubic-bezier(.22, 1, .36, 1));
  --mmc-shadow: var(--shadow-lg, 0 30px 80px -20px rgba(15, 23, 42, .35), 0 10px 30px -10px rgba(15, 23, 42, .2));
  --mmc-glow: var(--shadow-glow, 0 10px 40px -10px rgba(99, 102, 241, .45));
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1400; /* above a vendor (Tawk/Crisp/Tidio) bubble — chat.js sets Tawk customStyle.zIndex = 105, above the header (100) but below the mobile menu (110) and toasts (120) — and above the site header/menu */
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--mmc-text);
  -webkit-font-smoothing: antialiased;
}
.mm-chat *, .mm-chat *::before, .mm-chat *::after { box-sizing: border-box; }
.mm-chat button { font: inherit; color: inherit; cursor: pointer; }
.mm-chat__icon { display: inline-flex; width: 24px; height: 24px; }
.mm-chat__icon svg { width: 100%; height: 100%; }

/* ---------- Launcher ---------- */
.mm-chat__launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--mmc-grad);
  color: #fff;
  box-shadow: var(--mmc-glow), 0 6px 20px rgba(15, 23, 42, .2);
  transition: transform .35s var(--mmc-ease), box-shadow .35s var(--mmc-ease);
  isolation: isolate;
}
.mm-chat__launcher:hover { transform: translateY(-2px) scale(1.04); }
.mm-chat__launcher:active { transform: scale(.96); transition-duration: .08s; } /* tap feedback */
.mm-chat__launcher:focus-visible { outline: 0; box-shadow: var(--mmc-glow), 0 0 0 4px rgba(99, 102, 241, .35); }
.mm-chat__launcher .mm-chat__icon { grid-area: 1 / 1; width: 28px; height: 28px; transition: opacity .25s, transform .35s var(--mmc-ease); }
.mm-chat__launcher-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.mm-chat.is-open .mm-chat__launcher-icon { opacity: 0; transform: rotate(90deg) scale(.6); }
.mm-chat.is-open .mm-chat__launcher-close { opacity: 1; transform: none; }
.mm-chat__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--mmc-grad);
  opacity: .45;
  z-index: -1;
  animation: mm-chat-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
.mm-chat.is-open .mm-chat__pulse { animation: none; opacity: 0; }
@keyframes mm-chat-pulse {
  0% { transform: scale(1); opacity: .45; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.mm-chat__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger, #EF4444);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  border: 2px solid #fff;
  transform: scale(0);
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1); /* small overshoot */
}
.mm-chat__launcher.has-unread .mm-chat__badge { transform: scale(1); }
.mm-chat__label {
  position: absolute;
  right: 72px;
  bottom: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--mmc-dark);
  color: var(--mmc-on-dark);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .25s, transform .3s var(--mmc-ease);
  pointer-events: none;
}
.mm-chat:not(.is-open) .mm-chat__launcher:hover ~ .mm-chat__label,
.mm-chat:not(.is-open) .mm-chat__launcher:focus-visible ~ .mm-chat__label { opacity: 1; transform: none; }


/* ---------- Proactive teaser ---------- */
.mm-chat__teaser {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: min(300px, calc(100vw - 48px));
  padding: 6px 6px 6px 14px;
  border-radius: var(--mmc-radius);
  border-bottom-right-radius: 6px;
  background: #fff;
  color: var(--mmc-text);
  border: 1px solid var(--mmc-border);
  box-shadow: var(--mmc-shadow);
  opacity: 0;
  transform: translateY(12px) scale(.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .35s, transform .5s cubic-bezier(.34, 1.4, .64, 1);
}
.mm-chat__teaser.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.mm-chat.is-open .mm-chat__teaser { opacity: 0; pointer-events: none; }
.mm-chat__teaser-text {
  flex: 1;
  padding: 8px 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}
.mm-chat__teaser-cta { display: block; margin-top: 4px; font-size: 12.5px; font-weight: 600; color: #4F46E5; } /* visible action cue */
.mm-chat__teaser-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mmc-muted);
}
.mm-chat__teaser-close:hover { background: rgba(15, 23, 42, .06); color: var(--mmc-text); }
.mm-chat__teaser-close .mm-chat__icon { width: 18px; height: 18px; }

/* ---------- Panel ---------- */
.mm-chat__panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: min(640px, 85vh);
  max-height: calc(100vh - 110px);
  border-radius: var(--mmc-radius-lg);
  background: var(--bg-2, #fff);
  border: 1px solid var(--mmc-border);
  box-shadow: var(--mmc-shadow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .3s, transform .45s var(--mmc-ease), visibility 0s linear .45s;
}
.mm-chat.is-open .mm-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .3s, transform .45s var(--mmc-ease), visibility 0s;
}
.mm-chat__panel:focus { outline: none; }

/* Header */
.mm-chat__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 16px 18px;
  color: var(--mmc-on-dark);
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(99, 102, 241, .55), transparent 55%),
    radial-gradient(90% 140% at 100% 100%, rgba(34, 211, 238, .28), transparent 60%),
    var(--mmc-dark);
  border-bottom: 1px solid var(--border-dark, rgba(255, 255, 255, .08));
}
.mm-chat__avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--mmc-grad);
  color: #fff;
  font-family: Sora, Inter, system-ui, sans-serif;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .12);
}
.mm-chat__who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mm-chat__name { font-family: Sora, Inter, system-ui, sans-serif; font-weight: 600; font-size: 15px; }
.mm-chat__title { font-size: 12px; color: var(--mmc-muted-dark); }
.mm-chat__status { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--mmc-muted-dark); }
.mm-chat__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success, #10B981);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .25);
}
/* Vendor status (hand-off mode): chat.js swaps the modifier from Tawk's onStatusChange */
.mm-chat__dot--online { background: var(--success, #10B981); box-shadow: 0 0 0 3px rgba(16, 185, 129, .25); }
.mm-chat__dot--away { background: var(--warning, #F59E0B); box-shadow: 0 0 0 3px rgba(245, 158, 11, .25); }
.mm-chat__dot--offline { background: #94A3B8; box-shadow: 0 0 0 3px rgba(148, 163, 184, .25); }
.mm-chat__actions { position: relative; display: flex; align-items: center; gap: 2px; }
.mm-chat__iconbtn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--mmc-on-dark);
  opacity: .85;
  transition: background .2s, opacity .2s;
}
.mm-chat__iconbtn:hover, .mm-chat__iconbtn:focus-visible { background: rgba(255, 255, 255, .12); opacity: 1; outline: none; }
.mm-chat__iconbtn .mm-chat__icon { width: 20px; height: 20px; }
.mm-chat__dots { display: inline-flex; gap: 3px; }
.mm-chat__dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.mm-chat__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 40px;
  min-width: 160px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  color: var(--mmc-text);
  border: 1px solid var(--mmc-border);
  box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .35);
  z-index: 2;
}
.mm-chat__menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.mm-chat__menu-item:hover, .mm-chat__menu-item:focus-visible { background: rgba(99, 102, 241, .1); color: var(--primary-600, #4F46E5); outline: none; }

/* Messages */
.mm-chat__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: var(--bg, #F7F9FC);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.mm-chat__msgs { display: flex; flex-direction: column; gap: 8px; }
.mm-chat__msg { display: flex; max-width: 100%; animation: mm-chat-in .35s var(--mmc-ease) both; }
.mm-chat__msg--static { animation: none; }
.mm-chat__msg--bot { justify-content: flex-start; }
.mm-chat__msg--user { justify-content: flex-end; }
.mm-chat__msg--system { justify-content: center; }
.mm-chat__bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mm-chat__msg--bot .mm-chat__bubble {
  background: #fff;
  color: var(--mmc-text);
  border: 1px solid var(--mmc-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
}
.mm-chat__msg--user .mm-chat__bubble {
  background: var(--mmc-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, .5);
}
.mm-chat__msg--system .mm-chat__bubble {
  max-width: 92%;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 185, 129, .1);
  color: #047857;
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
}
.mm-chat__msg--bot + .mm-chat__msg--bot { margin-top: -2px; }
@keyframes mm-chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
/* Typing indicator */
.mm-chat__typing .mm-chat__bubble { display: inline-flex; gap: 5px; align-items: center; padding: 12px 14px; }
.mm-chat__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mmc-muted);
  opacity: .5;
  animation: mm-chat-dot 1.2s ease-in-out infinite;
}
.mm-chat__typing i:nth-child(2) { animation-delay: .15s; }
.mm-chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mm-chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Quick-reply chips */
/* Chips live inside the scrolling body, right under the last bot bubble (like Intercom's reply buttons) */
.mm-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 6px;
  background: transparent;
}
.mm-chat__chips[hidden] { display: none; }
.mm-chat__chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, .35);
  background: #fff;
  color: var(--primary-600, #4F46E5);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  transition: background .2s, color .2s, transform .2s var(--mmc-ease), box-shadow .2s;
  animation: mm-chat-in .35s var(--mmc-ease) both;
}
.mm-chat__chip:hover, .mm-chat__chip:focus-visible {
  background: var(--mmc-primary);
  border-color: var(--mmc-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -8px rgba(99, 102, 241, .6);
  outline: none;
}

/* Input bar */
.mm-chat__inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--mmc-border);
}
.mm-chat__input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 14px;
  border: 1px solid var(--mmc-border);
  border-radius: 14px;
  background: var(--bg, #F7F9FC);
  color: var(--mmc-text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.mm-chat__input:focus { border-color: var(--mmc-primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, .2); background: #fff; }
.mm-chat__input::placeholder { color: var(--mmc-muted); }
.mm-chat__send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--mmc-grad);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(99, 102, 241, .6);
  transition: transform .2s var(--mmc-ease), box-shadow .2s;
}
.mm-chat__send:hover, .mm-chat__send:focus-visible { transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(99, 102, 241, .7); outline: none; }
.mm-chat__send .mm-chat__icon { width: 20px; height: 20px; }
.mm-chat__footer {
  padding: 8px 12px 10px;
  background: #fff;
  color: var(--mmc-muted);
  font-size: 11.5px;
  text-align: center;
  letter-spacing: .01em;
}

/* ---------- Mobile: full-screen panel ---------- */
@media (max-width: 560px) {
  .mm-chat { right: 16px; bottom: 16px; }
  .mm-chat__panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    transform: translateY(24px);
  }
  .mm-chat.is-open .mm-chat__panel { transform: none; }
  .mm-chat.is-open .mm-chat__launcher, .mm-chat.is-open .mm-chat__label { display: none; }
  .mm-chat__header { padding-top: max(16px, env(safe-area-inset-top)); }
  .mm-chat__footer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .mm-chat__teaser { bottom: 70px; }
  body.mm-chat-open { overflow: hidden; touch-action: none; }
}

/* ---------- Mobile: lift the launcher above the cookie banner while it is open (main.js sets body.cookie-open + --cookie-h) ---------- */
@media (max-width: 720px) {
  body.cookie-open .mm-chat:not(.is-open) { bottom: calc(var(--cookie-h, 180px) + 28px); transition: bottom .4s var(--mmc-ease); }
}

/* ---------- Handed off to the live-chat vendor (chat.js adds .is-handed-off) ----------
   The vendor conversation runs in an embedded frame INSIDE our panel: our launcher, header and footer stay;
   the bot message area and input bar step aside. The frame is kept at a real size off-screen before the
   hand-off so the vendor lays itself out correctly from the start. */
.mm-chat__frame-wrap { position: absolute; left: -2000px; top: 0; width: 380px; height: 520px; background: #fff; }
.mm-chat.is-handed-off .mm-chat__frame-wrap { position: relative; left: auto; top: auto; width: auto; height: auto; flex: 1 1 auto; min-height: 0; }
.mm-chat__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
/* Our own "connecting" screen sits over the frame until the vendor has actually drawn the conversation */
.mm-chat__connecting { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; background: var(--bg-2, #fff); }
.mm-chat__frame-wrap.is-ready .mm-chat__connecting { display: none; }
.mm-chat__connecting-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 24px; }
.mm-chat__connecting-inner .mm-chat__avatar { width: 56px; height: 56px; font-size: 1.4rem; }
.mm-chat__connecting-text { margin: 0; font-weight: 600; color: var(--text, #0F172A); }
.mm-chat__spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(99, 102, 241, .2); border-top-color: var(--primary, #6366F1); animation: mm-spin .9s linear infinite; }
@keyframes mm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mm-chat__spinner { animation: none; } }
.mm-chat.is-handed-off .mm-chat__header,
.mm-chat.is-handed-off .mm-chat__body,
.mm-chat.is-handed-off .mm-chat__inputbar,
.mm-chat.is-handed-off .mm-chat__footer { display: none !important; } /* one box: the live conversation fills our panel edge to edge */

/* ---------- Hidden while the mobile menu is open (menu owns the viewport) ---------- */
body.menu-open .mm-chat:not(.is-open) .mm-chat__launcher,
body.menu-open .mm-chat:not(.is-open) .mm-chat__label,
body.menu-open .mm-chat:not(.is-open) .mm-chat__teaser {
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

/* ---------- Toast (MM.toast) ---------- */
.mm-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1500; /* stays above the chat panel (1400) */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
  width: min(92vw, 480px);
}
.mm-toast {
  pointer-events: auto;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--bg-dark-2, #0D1425);
  color: var(--text-on-dark, #F8FAFC);
  font: 500 14px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .5);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s, transform .35s var(--ease, cubic-bezier(.22, 1, .36, 1));
  cursor: pointer;
}
.mm-toast.is-visible { opacity: 1; transform: none; }
.mm-toast--success { border-color: rgba(16, 185, 129, .6); box-shadow: 0 16px 40px -12px rgba(16, 185, 129, .45); }
.mm-toast--error { border-color: rgba(239, 68, 68, .6); box-shadow: 0 16px 40px -12px rgba(239, 68, 68, .45); }
.mm-toast--info { border-color: rgba(99, 102, 241, .6); }

/* ---------- Hero chat-mockup defaults ([data-chat-demo]) ----------
   Page CSS (css/pages/index.css) may override any of these. */
.chat-demo__msgs { display: flex; flex-direction: column; gap: 10px; }
.chat-demo__msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.5;
  animation: mm-chat-in .4s var(--ease, cubic-bezier(.22, 1, .36, 1)) both;
}
.chat-demo__msg--agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, .08);
  color: var(--text-on-dark, #F8FAFC);
  border: 1px solid rgba(255, 255, 255, .1);
  border-bottom-left-radius: 6px;
}
.chat-demo__msg--user {
  align-self: flex-end;
  background: var(--grad, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #22D3EE 100%));
  color: #fff;
  border-bottom-right-radius: 6px;
}
.chat-demo__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 12px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .1);
}
.chat-demo__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted-dark, #9AA8BF);
  animation: mm-chat-dot 1.2s ease-in-out infinite;
}
.chat-demo__typing i:nth-child(2) { animation-delay: .15s; }
.chat-demo__typing i:nth-child(3) { animation-delay: .3s; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .mm-chat__pulse, .mm-chat__typing i, .chat-demo__typing i { animation: none; }
  .mm-chat__msg, .mm-chat__chip, .chat-demo__msg { animation: none; }
  .mm-chat__panel, .mm-chat__teaser, .mm-chat__launcher, .mm-chat__badge, .mm-chat__label, .mm-toast { transition: none; }
}

/* ---------- Print ---------- */
@media print { .mm-chat, .mm-toast-wrap { display: none !important; } }
