/* Chat de atendimento do Modão Raiz — visual no tom da loja (creme/dourado/marrom). */
.mr-chat {
  --mr-chat-brown: oklch(24% 0.045 55);
  --mr-chat-brown-soft: oklch(30% 0.05 55);
  --mr-chat-cream: oklch(99% 0.012 80);
  --mr-chat-cream-2: oklch(96% 0.02 82);
  --mr-chat-gold: oklch(72% 0.13 68);
  --mr-chat-gold-dark: oklch(60% 0.12 65);
  --mr-chat-border: oklch(86% 0.035 74);
  --mr-chat-muted: oklch(45% 0.03 55);
  --mr-chat-online: oklch(60% 0.16 150);
  font-family: "Barlow", system-ui, sans-serif;
}

/* Botão flutuante */
.mr-chat-button {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 46;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--mr-chat-brown);
  color: var(--mr-chat-gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.mr-chat-button:active {
  transform: scale(0.96);
}
.mr-chat-button svg {
  width: 26px;
  height: 26px;
}
.mr-chat-button .mr-chat-button-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--mr-chat-cream);
  border-radius: 999px;
  background: var(--mr-chat-online);
}

/* Some quando o checkout abre ou o painel está aberto */
.mr-chat-hidden {
  display: none !important;
}

@media (max-width: 767px) {
  .mr-chat-button {
    bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  }
}

/* Painel */
.mr-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: color-mix(in oklch, var(--mr-chat-brown) 25%, transparent);
}

.mr-chat-panel {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 81;
  display: flex;
  flex-direction: column;
  height: min(540px, calc(100dvh - 24px));
  max-width: 400px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--mr-chat-border);
  border-radius: 14px;
  background: var(--mr-chat-cream);
  color: var(--mr-chat-brown);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

@media (min-width: 768px) {
  .mr-chat-panel {
    left: auto;
    right: 20px;
    bottom: 84px;
    margin: 0;
  }
}

.mr-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mr-chat-border);
  background: var(--mr-chat-brown);
  color: var(--mr-chat-cream);
}

.mr-chat-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--mr-chat-gold);
  color: var(--mr-chat-brown);
}

.mr-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mr-chat-avatar span {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--mr-chat-brown);
  border-radius: 999px;
  background: var(--mr-chat-online);
}

.mr-chat-heading {
  min-width: 0;
  flex: 1;
}

.mr-chat-heading strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.mr-chat-heading em {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  font-style: normal;
  color: oklch(85% 0.05 80);
}

.mr-chat-heading em::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--mr-chat-online);
}

.mr-chat-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--mr-chat-cream);
  cursor: pointer;
}
.mr-chat-close svg {
  width: 20px;
  height: 20px;
}

.mr-chat-log {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.mr-chat-log-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.mr-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 95%;
  width: fit-content;
  font-size: 14px;
  line-height: 1.55;
}

.mr-chat-msg-user {
  align-self: flex-end;
  border-radius: 12px;
  border-top-right-radius: 4px;
  padding: 8px 12px;
  background: var(--mr-chat-gold);
  color: var(--mr-chat-brown);
  font-weight: 500;
}

.mr-chat-msg-assistant {
  align-self: flex-start;
  white-space: pre-wrap;
  word-break: break-word;
}

.mr-chat-typing {
  align-self: flex-start;
  margin: 0;
  padding: 4px 0;
  font-size: 13px;
  color: var(--mr-chat-muted);
  animation: mr-chat-pulse 1.2s ease-in-out infinite;
}

@keyframes mr-chat-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.mr-chat-error {
  border-radius: 10px;
  padding: 8px 12px;
  background: oklch(93% 0.04 30);
  font-size: 12px;
  color: oklch(45% 0.15 30);
}

.mr-chat-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mr-chat-suggestion {
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid var(--mr-chat-border);
  border-radius: 10px;
  background: var(--mr-chat-cream);
  color: var(--mr-chat-brown);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  word-break: break-word;
  cursor: pointer;
}
.mr-chat-suggestion:active {
  background: var(--mr-chat-cream-2);
}

.mr-chat-more {
  align-self: flex-start;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--mr-chat-gold-dark);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.mr-chat-form {
  flex-shrink: 0;
  border-top: 1px solid var(--mr-chat-border);
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  background: var(--mr-chat-cream);
}

.mr-chat-form-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.mr-chat-input {
  min-height: 44px;
  max-height: 112px;
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  background: var(--mr-chat-cream-2);
  color: var(--mr-chat-brown);
  font-family: inherit;
  font-size: 16px;
  outline: none;
}
.mr-chat-input::placeholder {
  color: var(--mr-chat-muted);
}

.mr-chat-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  background: var(--mr-chat-gold);
  color: var(--mr-chat-brown);
  cursor: pointer;
}
.mr-chat-send:disabled {
  opacity: 0.6;
  cursor: default;
}
.mr-chat-send svg {
  width: 20px;
  height: 20px;
}

/* Bolha flutuante fora da loja: o atendimento entra pelo menu ("Atendimento").
   O botão continua montado — é ele que o menu aciona — só fica invisível. */
.mr-chat-button {
  display: none !important;
}
