:root {
  --tedeclaro-chat-bg: #2f2a24;
  --tedeclaro-chat-primary: #c94a1e;
  --tedeclaro-chat-accent: #f4a23a;
  --tedeclaro-chat-text: #2c2925;
  --tedeclaro-chat-muted: #766f67;
  --tedeclaro-chat-panel: #ffffff;
  --tedeclaro-chat-border: rgba(47, 42, 36, 0.14);
}

.tedeclaro-chat-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99999;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tedeclaro-chat-root [hidden] {
  display: none !important;
}

.tedeclaro-chat-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 20px 28px;
  background: linear-gradient(135deg, var(--tedeclaro-chat-bg), var(--tedeclaro-chat-primary));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(47, 42, 36, 0.22);
  cursor: pointer;
}

.tedeclaro-chat-button-dot {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: var(--tedeclaro-chat-accent);
  box-shadow: 0 0 0 5px rgba(244, 162, 58, 0.18);
  animation: tedeclaroDotPulse 1.8s infinite ease-in-out;
}

@keyframes tedeclaroDotPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 5px rgba(244, 162, 58, 0.16);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 9px rgba(244, 162, 58, 0.06);
  }
}

.tedeclaro-chat-panel {
  width: min(430px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 96px));
  margin-bottom: 12px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--tedeclaro-chat-panel);
  color: var(--tedeclaro-chat-text);
  box-shadow: 0 24px 80px rgba(47, 42, 36, 0.28);
  border: 1px solid var(--tedeclaro-chat-border);
  transform-origin: bottom right;
  animation: tedeclaroPanelIn .28s ease-out;
}

@keyframes tedeclaroPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tedeclaro-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, var(--tedeclaro-chat-bg), var(--tedeclaro-chat-primary));
  color: #fff;
}

.tedeclaro-chat-header strong,
.tedeclaro-chat-header span {
  display: block;
}

.tedeclaro-chat-header strong {
  font-size: 17px;
}

.tedeclaro-chat-header span {
  opacity: .85;
  font-size: 13px;
}

.tedeclaro-chat-close {
  width: 34px;
  height: 34px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.tedeclaro-chat-messages {
  height: calc(100% - 174px);
  overflow-y: auto;
  padding: 16px;
  background: #faf7f4;
}

.tedeclaro-chat-message {
  max-width: 86%;
  margin: 0 0 10px;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.tedeclaro-chat-message.bot {
  background: #fff;
  border: 1px solid var(--tedeclaro-chat-border);
  border-top-left-radius: 6px;
}

.tedeclaro-chat-message.bot a {
  color: #c94a1e;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tedeclaro-chat-message.bot a:hover {
  color: #9f3514;
}

.tedeclaro-chat-message.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  min-width: 54px;
  min-height: 39px;
}

.tedeclaro-chat-message.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--tedeclaro-chat-muted);
  opacity: .35;
  animation: tedeclaroTypingPulse 1.05s infinite ease-in-out;
}

.tedeclaro-chat-message.typing span:nth-child(2) {
  animation-delay: .16s;
}

.tedeclaro-chat-message.typing span:nth-child(3) {
  animation-delay: .32s;
}

@keyframes tedeclaroTypingPulse {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: .35;
  }
  40% {
    transform: translateY(-4px);
    opacity: .9;
  }
}

.tedeclaro-chat-message.user {
  margin-left: auto;
  background: var(--tedeclaro-chat-primary);
  color: #fff;
  border-top-right-radius: 6px;
}

.tedeclaro-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--tedeclaro-chat-border);
  background: #fff;
}

.tedeclaro-chat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--tedeclaro-chat-border);
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  min-height: 46px;
}

.tedeclaro-chat-form button {
  align-self: stretch;
  border: 0;
  border-radius: 14px;
  padding: 0 15px;
  background: var(--tedeclaro-chat-bg);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.tedeclaro-chat-form button:disabled {
  opacity: .55;
  cursor: wait;
}

.tedeclaro-chat-privacy {
  margin: 0;
  padding: 0 14px 12px;
  font-size: 11px;
  color: var(--tedeclaro-chat-muted);
  background: #fff;
}

@media (max-width: 520px) {
  .tedeclaro-chat-root {
    right: 0;
    bottom: 0;
  }

  .tedeclaro-chat-button {
    padding: 19px 25px;
    font-size: 17px;
    box-shadow: 0 18px 42px rgba(47, 42, 36, 0.26);
  }

  .tedeclaro-chat-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    margin-bottom: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    animation: none;
  }

  .tedeclaro-chat-header {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }

  .tedeclaro-chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .tedeclaro-chat-privacy {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
