.mchat-root {
  --mchat-color: #d9779b;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: #2b2b2b;
}
.mchat-root *,
.mchat-root *::before,
.mchat-root *::after {
  box-sizing: border-box;
}
.mchat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--mchat-color);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  margin-left: auto;
  padding: 0;
}
.mchat-launcher:hover,
.mchat-launcher:focus-visible {
  filter: brightness(0.94);
  outline: 2px solid #fff;
  outline-offset: -5px;
}
.mchat-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mchat-panel[hidden] {
  display: none;
}
.mchat-header {
  background: var(--mchat-color);
  color: #fff;
  padding: 12px 8px 12px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.mchat-title {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
}
.mchat-badge {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  padding: 2px 8px;
}
.mchat-iconbtn {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.mchat-iconbtn:hover,
.mchat-iconbtn:focus-visible {
  background: rgba(255, 255, 255, 0.2);
}
.mchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #faf7f8;
}
.mchat-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.mchat-user {
  align-self: flex-end;
  background: var(--mchat-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.mchat-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #ece4e7;
  border-bottom-left-radius: 4px;
}
.mchat-bot a {
  color: var(--mchat-color);
  font-weight: 600;
  text-decoration: underline;
}
.mchat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.mchat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b8aeb2;
  animation: mchat-bounce 1.2s infinite ease-in-out;
}
.mchat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.mchat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes mchat-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}
.mchat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
  background: #faf7f8;
}
.mchat-chips:empty {
  display: none;
}
.mchat-chip {
  background: #fff;
  border: 1px solid var(--mchat-color);
  color: var(--mchat-color);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.mchat-chip:hover,
.mchat-chip:focus-visible {
  background: var(--mchat-color);
  color: #fff;
}
.mchat-wa {
  font-size: 12.5px;
  padding: 6px 14px;
  background: #faf7f8;
  border-top: 1px solid #f0e9ec;
  color: #555;
}
.mchat-wa a {
  color: #1a8f4c;
  font-weight: 600;
}
.mchat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0e9ec;
  background: #fff;
}
.mchat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #ddd2d6;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 16px; /* evita el zoom en iOS */
  font-family: inherit;
  margin: 0;
  height: auto;
}
.mchat-input:focus {
  outline: 2px solid var(--mchat-color);
  outline-offset: 0;
  border-color: transparent;
}
.mchat-send {
  background: var(--mchat-color);
  color: #fff;
  border: 0;
  border-radius: 20px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.mchat-send:disabled {
  opacity: 0.55;
  cursor: default;
}
.mchat-note {
  font-size: 11px;
  color: #8a8085;
  text-align: center;
  padding: 0 12px 8px;
  background: #fff;
}
/* Celular/tablet: el tema tiene una barra de navegación fija abajo (~60px); el botón se sube para no taparla
   y quedar a la misma altura que el de WhatsApp. */
@media (max-width: 768px) {
  .mchat-root {
    right: 16px;
    bottom: 68px;
  }
}
@media (max-width: 480px) {
  .mchat-open .mchat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .mchat-open .mchat-launcher {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mchat-typing span {
    animation: none;
  }
}

/* Tarjetas de producto */
.mchat-cards {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 2px;
}
.mchat-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid #ece4e7;
  border-radius: 12px;
  padding: 7px;
}
.mchat-card-img {
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: none;
  object-fit: cover;
  border-radius: 8px;
  background: #f3edf0;
  margin: 0;
}
.mchat-card-body {
  flex: 1;
  min-width: 0;
}
.mchat-card-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mchat-card-meta {
  display: flex;
  flex-wrap: wrap;
  column-gap: 8px;
  font-size: 13px;
  margin-top: 2px;
}
.mchat-card-stock {
  font-size: 12px;
  align-self: center;
}
.mchat-stock-in {
  color: #2e7d4f;
}
.mchat-stock-back {
  color: #b36b00;
}
.mchat-stock-out {
  color: #b3261e;
}
.mchat-card-btn {
  flex: none;
  background: var(--mchat-color);
  color: #fff !important;
  text-decoration: none !important;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.mchat-card-btn:hover,
.mchat-card-btn:focus-visible {
  filter: brightness(0.94);
}

/* Blindaje: los temas suelen pintar TODOS los botones e inputs (color, mayúsculas, bordes). Esto mantiene el aspecto del chat. */
.mchat-root button,
.mchat-root input {
  text-transform: none !important;
  letter-spacing: normal !important;
  text-shadow: none !important;
  font-family: inherit !important;
  min-height: 0 !important;
  margin: 0;
}
.mchat-root .mchat-launcher,
.mchat-root .mchat-launcher:hover,
.mchat-root .mchat-launcher:focus {
  background: var(--mchat-color) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 50% !important;
  width: 58px !important;
  height: 58px !important;
  padding: 0 !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22) !important;
}
.mchat-root .mchat-iconbtn,
.mchat-root .mchat-iconbtn:focus {
  background: transparent !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 8px !important;
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
  font-size: 24px !important;
  line-height: 1 !important;
  box-shadow: none !important;
}
.mchat-root .mchat-iconbtn:hover,
.mchat-root .mchat-iconbtn:focus-visible {
  background: rgba(255, 255, 255, 0.2) !important;
}
.mchat-root .mchat-chip,
.mchat-root .mchat-chip:focus {
  background: #fff !important;
  color: var(--mchat-color) !important;
  border: 1px solid var(--mchat-color) !important;
  border-radius: 16px !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  line-height: 1.3 !important;
  height: auto !important;
  box-shadow: none !important;
}
.mchat-root .mchat-chip:hover,
.mchat-root .mchat-chip:focus-visible {
  background: var(--mchat-color) !important;
  color: #fff !important;
}
.mchat-root .mchat-send,
.mchat-root .mchat-send:hover,
.mchat-root .mchat-send:focus {
  background: var(--mchat-color) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 20px !important;
  padding: 0 16px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  height: auto !important;
  box-shadow: none !important;
}
.mchat-root .mchat-send:hover {
  filter: brightness(0.94);
}
.mchat-root .mchat-input,
.mchat-root .mchat-input:focus {
  background: #fff !important;
  color: #2b2b2b !important;
  border: 1px solid #ddd2d6 !important;
  border-radius: 20px !important;
  padding: 9px 14px !important;
  font-size: 16px !important;
  line-height: 1.3 !important;
  height: auto !important;
  box-shadow: none !important;
}
.mchat-root a.mchat-card-btn,
.mchat-root a.mchat-card-btn:hover {
  background: var(--mchat-color) !important;
  color: #fff !important;
  border-radius: 999px !important;
  text-decoration: none !important;
  text-transform: none !important;
  border: 0 !important;
}

/* Mensaje flotante junto al botón */
.mchat-teaser {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: max-content;
  max-width: min(250px, calc(100vw - 32px));
  background: #fff;
  color: #2b2b2b;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  padding: 10px 30px 10px 14px;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
  animation: mchat-pop 0.3s ease-out;
}
.mchat-teaser::after {
  content: '';
  position: absolute;
  right: 22px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.08);
}
.mchat-open .mchat-teaser {
  display: none;
}
.mchat-root .mchat-teaser-x,
.mchat-root .mchat-teaser-x:focus {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px !important;
  height: 22px !important;
  background: transparent !important;
  color: #8a8085 !important;
  border: 0 !important;
  border-radius: 50% !important;
  padding: 0 !important;
  font-size: 17px !important;
  line-height: 1 !important;
  cursor: pointer;
  box-shadow: none !important;
}
.mchat-root .mchat-teaser-x:hover {
  background: #f0e9ec !important;
}
@keyframes mchat-pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mchat-teaser {
    animation: none;
  }
}
