/* Kyrin2 live support widget.
   Desktop: a 380 px panel above the bubble. Phones (<= 520 px): a full-screen sheet that follows the keyboard (chat.js sets --m2-vvh / --m2-vvt
   from visualViewport), so the message list gets all the space and the input is never hidden. The widget does not depend on the page's own
   typography: everything it shows is sized here, and the box rules of the page (section, small, strong, ...) are neutralised below.
   A page can lift the bubble above its own fixed bar with  .m2-chat{--m2-lift:68px}. */

.m2-chat,
.m2-chat *,
.m2-chat *::before,
.m2-chat *::after { box-sizing: border-box; }

.m2-chat {
  position: fixed;
  right: 22px;
  bottom: calc(22px + var(--m2-lift, 0px) + env(safe-area-inset-bottom, 0px));
  z-index: 999998;
  font: 400 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: normal;
  text-transform: none;
  color: #eee1c9;
  -webkit-text-size-adjust: 100%;
}
.m2-chat button,
.m2-chat input,
.m2-chat label { font: inherit; letter-spacing: inherit; text-transform: none; margin: 0; }
.m2-chat strong,
.m2-chat small,
.m2-chat span,
.m2-chat time,
.m2-chat b { font-size: inherit; line-height: inherit; }

/* ---- bubble ---- */
.m2-chat-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 1px solid #f0cf7d;
  border-radius: 50%;
  background: linear-gradient(145deg, #c99a43, #79501f);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
  color: #160d07;
  cursor: pointer;
}
.m2-chat-button svg { width: 28px; height: 28px; }
.m2-chat-badge {
  position: absolute;
  top: -3px;
  right: -2px;
  min-width: 21px;
  padding: 3px;
  border: 2px solid #150e09;
  border-radius: 20px;
  background: #d63e32;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}
.m2-chat-hidden { display: none; }

/* ---- panel ---- */
.m2-chat .m2-chat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 28px));
  height: min(600px, calc(100dvh - 74px - 22px - var(--m2-lift, 0px) - 16px));
  min-height: 340px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #a77d3d;
  border-radius: 16px;
  background: #100c09;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .8);
}
.m2-chat .m2-chat-panel.m2-chat-hidden { display: none; }

/* header: icon, title + one status line, close */
.m2-chat-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 12px 14px;
  border-bottom: 1px solid #60451f;
  background: linear-gradient(135deg, #2a1b0f, #17100b);
}
.m2-chat-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #c99a43, #79501f);
  color: #160d07;
}
.m2-chat-avatar svg { width: 20px; height: 20px; }
.m2-chat-head > div { flex: 1; min-width: 0; }
.m2-chat-head strong { display: block; color: #f1d28b; font-size: 15px; font-weight: 700; line-height: 1.25; }
.m2-chat-head small {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  color: #b8a888;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.m2-chat-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c7b89d;
  cursor: pointer;
}
.m2-chat-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.m2-chat-close svg { width: 20px; height: 20px; }

/* messages: the part of the panel that grows */
.m2-chat-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.m2-chat-msg {
  position: relative;
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 4px 14px 14px 14px;
  background: #2b2118;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.m2-chat-msg.visitor { align-self: flex-end; border-radius: 14px 4px 14px 14px; background: #755126; color: #fff; }
.m2-chat-msg b { display: block; margin-bottom: 2px; color: #e0bd72; font-size: 11px; font-weight: 700; }
.m2-chat-msg time { display: block; margin-top: 3px; color: #988b77; font-size: 10px; text-align: right; }
.m2-chat-msg.visitor time { color: #d9bf94; }
.m2-chat-msg.deleted { opacity: .72; }
.m2-chat-msg.deleted span { font-style: italic; }
.m2-chat-error { flex: none; padding: 0 14px 6px; color: #e89182; font-size: 12px; line-height: 1.35; }
.m2-chat-error:empty { display: none; }

/* notification offer: one compact row */
.m2-chat-push-prompt {
  position: relative;
  z-index: 3;
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-top: 1px solid #60451f;
  background: #211812;
  color: #f5ead5;
}
.m2-chat-push-prompt.m2-chat-hidden { display: none; }
.m2-chat-push-copy { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.m2-chat-push-copy strong { color: #f1d28b; font-size: 12px; font-weight: 700; line-height: 1.3; }
.m2-chat-push-copy span { color: #c8b89c; font-size: 11px; line-height: 1.3; }
.m2-chat-push-enable {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: #b1853e;
  color: #1a1007;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.m2-chat-push-dismiss {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c7b89d;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.m2-chat-push-instruction { max-width: 94%; border: 1px solid rgba(222, 184, 98, .35); background: #3a2a1b; }

/* reply preview (answering one message) */
.m2-chat-reply-preview {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border-top: 1px solid #60451f;
  background: #211812;
  color: #f5ead5;
}
.m2-chat-reply-preview.m2-chat-hidden { display: none; }
.m2-chat-reply-preview > div { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.m2-chat-reply-preview strong { color: #f1d28b; font-size: 11px; }
.m2-chat-reply-preview span { overflow: hidden; color: #c8b89c; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.m2-chat-reply-preview button { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: #c7b89d; font-size: 18px; cursor: pointer; }
.m2-chat-reply-quote {
  margin: 0 0 6px;
  padding: 5px 8px;
  overflow: hidden;
  border-left: 3px solid #c99a43;
  border-radius: 5px;
  background: rgba(222, 184, 98, .12);
  color: #d9c39a;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.m2-chat-reply-btn {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(222, 184, 98, .35);
  border-radius: 50%;
  background: rgba(0, 0, 0, .16);
  color: #f1d28b;
  font-size: 13px;
  line-height: 1;
  opacity: .7;
  cursor: pointer;
}
.m2-chat-msg.visitor .m2-chat-reply-btn { right: auto; left: 5px; }
.m2-chat-reply-btn:hover { background: #c99a43; color: #1a1007; opacity: 1; }
.m2-chat-msg:not(.visitor) time { position: relative; z-index: 2; margin-right: 34px; }

/* composer: attach, text, send */
.m2-chat-form {
  display: grid;
  flex: none;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #45331d;
  background: #100c09;
}
.m2-chat-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #574225;
  border-radius: 22px;
  background: #1a1410;
  color: #fff;
  font-size: 15px;
  line-height: 1.3;
  outline: 0;
}
.m2-chat-input::placeholder { color: #8f806a; }
.m2-chat-input:focus { border-color: #d3a55a; box-shadow: 0 0 0 2px rgba(211, 165, 90, .25); }
.m2-chat-attach,
.m2-chat-send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
}
.m2-chat-attach { border: 1px solid #574225; background: #1a1410; color: #d8bd80; }
.m2-chat-attach.has-file { border-color: #d3a55a; background: #2a2118; color: #fff0bd; }
.m2-chat-attach svg { width: 20px; height: 20px; }
.m2-chat-file { display: none; }
.m2-chat-send { border: 0; background: #b1853e; color: #1a1007; }
.m2-chat-send:hover { background: #c99a43; }
.m2-chat-send svg { width: 20px; height: 20px; }
.m2-chat-selected-file {
  display: none;
  grid-column: 1 / -1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid rgba(211, 165, 90, .6);
  border-radius: 8px;
  background: #211812;
  color: #fff0bd;
  font-size: 12px;
  font-weight: 700;
}
.m2-chat-selected-file.show { display: flex; }
.m2-chat-selected-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m2-chat-clear-file { margin-left: auto; padding: 0 4px; border: 0; background: transparent; color: #e9c982; font-size: 18px; line-height: 1; cursor: pointer; }

.m2-chat-image-wrap,
.m2-chat-image-wrap a { display: block; }
.m2-chat-image-wrap img { display: block; max-width: 100%; max-height: 220px; border: 1px solid rgba(240, 207, 125, .28); border-radius: 8px; object-fit: contain; }
.m2-chat-caption { display: block; margin-top: 6px; }

/* social links the bot offers */
.m2-social-msg { width: 100%; max-width: 94%; }
.m2-social-intro { display: block; margin-bottom: 8px; color: #f0dfbd; font-size: 13px; }
.m2-social-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.m2-social-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid rgba(222, 184, 98, .2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .035);
  color: #f5ead5 !important;
  text-decoration: none;
  transition: .18s ease;
}
.m2-social-card:hover { border-color: rgba(222, 184, 98, .5); background: rgba(222, 184, 98, .12); transform: translateY(-1px); }
.m2-social-icon { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; }
.m2-social-icon svg { display: block; width: 19px; height: 19px; fill: currentColor; }
.m2-social-card strong { display: block; color: #fff4d6; font-size: 13px; line-height: 1.15; text-transform: uppercase; }
.m2-social-card small { display: block; margin-top: 3px; color: #baa98d; font-size: 11px; line-height: 1.3; }
.m2-social-instagram .m2-social-icon { background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045); }
.m2-social-whatsapp .m2-social-icon { background: #20b95a; }
.m2-social-telegram .m2-social-icon { background: #229ed9; }
.m2-social-discord .m2-social-icon { background: #5865f2; }
.m2-social-youtube .m2-social-icon { background: #e62117; }
.m2-social-tiktok .m2-social-icon { background: #080808; box-shadow: inset 2px 0 #20f3ef, inset -2px 0 #ff295c; }
.m2-social-facebook .m2-social-icon { background: #1877f2; }

/* ---- phones: a full-screen sheet that follows the keyboard ---- */
html.m2-chat-open { overflow: hidden; }
@media (max-width: 520px), (max-height: 520px) {
  .m2-chat { right: 12px; }
  .m2-chat .m2-chat-panel {
    position: fixed;
    top: var(--m2-vvt, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--m2-vvh, 100dvh);
    min-height: 0;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .m2-chat .m2-chat-panel:not(.m2-chat-hidden) ~ .m2-chat-button { display: none; }
  .m2-chat-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .m2-chat-messages { padding: 12px; }
  .m2-chat-msg { max-width: 90%; }
  .m2-chat-input { font-size: 16px; }
  /* one line is enough for the notification offer */
  .m2-chat-push-copy span { display: none; }
  .m2-social-msg { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .m2-social-card { transition: none; } }
