/* Widget de chat BJ — site bjvasos.com.br */
:root {
  --bj-chat-panel-w: min(26.5rem, calc(100vw - 1.5rem));
  --bj-chat-panel-h: min(40rem, calc(100dvh - 6.5rem));
  --bj-chat-fab-size: 3.75rem;
  --bj-chat-offset-bottom: 5.75rem;
}

.bj-site-chat-fab {
  position: fixed;
  right: 1.25rem;
  bottom: var(--bj-chat-offset-bottom);
  z-index: 9000;
  width: var(--bj-chat-fab-size);
  height: var(--bj-chat-fab-size);
  border: none;
  border-radius: 9999px;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(26, 26, 46, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.bj-site-chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(26, 26, 46, 0.34);
}

body.bj-catalog .bj-site-chat-fab {
  bottom: calc(9.1rem + env(safe-area-inset-bottom));
}

.bj-site-chat-fab svg {
  width: 1.65rem;
  height: 1.65rem;
}

.bj-site-chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: var(--bj-chat-offset-bottom);
  z-index: 9001;
  width: var(--bj-chat-panel-w);
  height: var(--bj-chat-panel-h);
  max-height: var(--bj-chat-panel-h);
  display: none;
  flex-direction: column;
  border-radius: 1.125rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.bj-site-chat-panel.is-open {
  display: flex;
}

.bj-site-chat-fab.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.bj-site-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.125rem;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  flex-shrink: 0;
}

.bj-site-chat-panel__head strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.25;
}

.bj-site-chat-panel__head span {
  display: block;
  font-size: 0.8rem;
  opacity: 0.88;
  margin-top: 0.2rem;
}

.bj-site-chat-panel__close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.bj-site-chat-prechat,
.bj-site-chat-body {
  padding: 1.125rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.bj-site-chat-prechat p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #475569;
  line-height: 1.5;
}

.bj-site-chat-field {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  font: inherit;
  font-size: 1rem;
}

.bj-site-chat-field:focus {
  outline: 2px solid rgba(26, 26, 46, 0.18);
  border-color: #1a1a2e;
}
.bj-site-chat-field.is-invalid {
  border-color: #b42318;
  background: #fff7f6;
}

.bj-site-chat-btn {
  width: 100%;
  border: none;
  border-radius: 9999px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #1a1a2e;
  color: #fff;
}

.bj-site-chat-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bj-site-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.125rem;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bj-site-chat-msg-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 85%;
  gap: 0.2rem;
}

.bj-site-chat-msg-wrap--out {
  align-self: flex-end;
}

.bj-site-chat-msg-wrap .bj-site-chat-msg {
  max-width: 100%;
}

.bj-site-chat-msg-sign {
  font-size: 0.72rem;
  line-height: 1.2;
  color: #64748b;
  padding: 0 0.15rem;
}

.bj-site-chat-msg {
  max-width: 85%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.95rem;
  font-size: 0.95rem;
  line-height: 1.45;
  word-break: break-word;
}

.bj-site-chat-msg--in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

.bj-site-chat-msg--out {
  align-self: flex-end;
  background: #1a1a2e;
  color: #fff;
}

.bj-site-chat-compose {
  display: flex;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}

.bj-site-chat-compose input {
  flex: 1;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 1rem;
}

.bj-site-chat-compose button {
  border: none;
  border-radius: 9999px;
  padding: 0.75rem 1.15rem;
  background: #1a1a2e;
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.bj-site-chat-error {
  margin: 0 1rem 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.bj-site-chat-privacy {
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

.bj-site-chat-privacy a {
  color: inherit;
}

.bj-site-chat-error.hidden {
  display: none;
}

/* Tablet: painel um pouco mais largo */
@media (min-width: 768px) {
  :root {
    --bj-chat-panel-w: min(28rem, calc(100vw - 2rem));
    --bj-chat-panel-h: min(42rem, calc(100dvh - 6rem));
  }
}

/* Mobile: painel em tela cheia; FABs acima da barra de orçamento */
@media (max-width: 767px) {
  :root {
    --bj-chat-offset-bottom: max(0.75rem, env(safe-area-inset-bottom));
    --bj-chat-panel-w: 100%;
    --bj-chat-panel-h: 100dvh;
    --bj-chat-fab-size: 3.25rem;
  }

  .bj-site-chat-fab {
    right: 1rem;
    left: auto;
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }

  body.bj-catalog .bj-site-chat-fab {
    bottom: calc(8.75rem + env(safe-area-inset-bottom));
  }

  .bj-site-chat-panel {
    inset: 0;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .bj-site-chat-compose {
    padding-bottom: calc(0.9rem + env(safe-area-inset-bottom));
  }

  .bj-site-chat-prechat,
  .bj-site-chat-body {
    padding: 1rem;
  }
}

@media (max-width: 640px) {
  .bj-site-chat-compose button {
    padding: 0.75rem 0.9rem;
  }
}

/* Telas muito baixas (landscape mobile) */
@media (max-height: 520px) and (max-width: 900px) {
  :root {
    --bj-chat-panel-h: calc(100dvh - 4rem - env(safe-area-inset-bottom));
  }
}
