/* ============================
   Polis - Chat de Atendimento
   ============================ */

#polis-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* Launcher button */
#polis-launcher {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, hsl(82, 52%, 45%), hsl(82, 52%, 33%));
  box-shadow: 0 10px 30px hsla(82, 52%, 30%, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  animation: polis-launcher-pop 0.4s ease;
}

#polis-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 36px hsla(82, 52%, 30%, 0.5);
}

#polis-launcher svg {
  width: 28px;
  height: 28px;
}

#polis-launcher .polis-launcher-icon-close {
  display: none;
}

#polis-widget.polis-open #polis-launcher .polis-launcher-icon-chat {
  display: none;
}
#polis-widget.polis-open #polis-launcher .polis-launcher-icon-close {
  display: block;
}

#polis-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: hsl(0, 75%, 58%);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

#polis-widget.polis-open #polis-launcher-badge,
#polis-widget.polis-dismissed #polis-launcher-badge {
  display: none;
}

@keyframes polis-launcher-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes polis-launcher-pulse {
  0%,
  100% {
    box-shadow: 0 10px 30px hsla(82, 52%, 30%, 0.4);
  }
  50% {
    box-shadow:
      0 10px 30px hsla(82, 52%, 30%, 0.4),
      0 0 0 8px hsla(82, 52%, 55%, 0.15);
  }
}

#polis-launcher.polis-pulse {
  animation: polis-launcher-pulse 2.2s infinite;
}

/* Teaser bubble above the launcher */
#polis-teaser {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 230px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid hsl(150, 20%, 90%);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 14px;
  font-size: 0.82rem;
  color: hsl(150, 30%, 20%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  animation: polis-teaser-in 0.35s ease both;
  cursor: pointer;
}

#polis-teaser button.polis-teaser-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid hsl(150, 20%, 88%);
  background: #fff;
  color: hsl(150, 15%, 45%);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes polis-teaser-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat panel */
#polis-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: polis-panel-in 0.28s ease both;
}

.polis-hidden {
  display: none !important;
}

@keyframes polis-panel-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.polis-header {
  background: linear-gradient(135deg, hsl(82, 52%, 40%), hsl(150, 40%, 28%));
  padding: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.polis-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.polis-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.polis-name {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.2;
}

.polis-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 2px;
}

.polis-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(82, 70%, 62%);
  display: inline-block;
}

#polis-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#polis-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Messages area */
#polis-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  background: hsl(150, 30%, 98%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.polis-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: polis-msg-in 0.25s ease both;
}

.polis-msg-row.polis-user {
  flex-direction: row-reverse;
}

.polis-msg-row.polis-align-top {
  align-items: flex-start;
}

@keyframes polis-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.polis-msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 0.68rem;
  color: #fff;
  background: linear-gradient(135deg, hsl(82, 52%, 42%), hsl(82, 52%, 32%));
}

.polis-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.polis-bubble.polis-bot {
  background: #fff;
  border: 1px solid hsl(150, 20%, 90%);
  color: hsl(150, 30%, 20%);
  border-bottom-left-radius: 4px;
}

.polis-bubble.polis-user {
  background: hsl(82, 52%, 40%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.polis-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid hsl(150, 20%, 90%);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.polis-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(150, 15%, 65%);
  animation: polis-typing-bounce 1.1s infinite;
}

.polis-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.polis-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes polis-typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* Final CTA buttons */
.polis-cta-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  max-width: 90%;
}

.polis-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 10px;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
}

.polis-cta-primary {
  background: hsl(82, 52%, 42%);
  color: #fff;
}

.polis-cta-primary:hover {
  background: hsl(82, 52%, 36%);
  transform: translateY(-1px);
}

.polis-cta-whatsapp {
  background: #25d366;
  color: #fff;
}

.polis-cta-whatsapp:hover {
  background: #1ebe5b;
  transform: translateY(-1px);
}

/* Input row */
#polis-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid hsl(150, 20%, 92%);
  flex-shrink: 0;
  background: #fff;
}

#polis-input {
  flex: 1;
  border: 1px solid hsl(150, 20%, 88%);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  min-width: 0;
}

#polis-input:focus {
  border-color: hsl(82, 52%, 55%);
}

#polis-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: hsl(82, 52%, 42%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#polis-send:hover {
  background: hsl(82, 52%, 36%);
}

#polis-send:disabled,
#polis-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.polis-field-error {
  font-size: 0.72rem;
  color: hsl(0, 65%, 50%);
  padding: 0 14px 6px;
  background: #fff;
}

@media (max-width: 420px) {
  #polis-panel {
    width: calc(100vw - 24px);
    right: -8px;
    height: 66vh;
  }

  #polis-widget {
    right: 14px;
    bottom: 14px;
  }
}
