.chat-widget-root {
  --chat-z: 9999;
  font-family: 'Open Sans', sans-serif;
}

.chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: var(--chat-z);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary, #00a651);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 166, 81, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.chat-launcher:hover {
  transform: scale(1.06);
}

.chat-launcher svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.chat-launcher.is-hidden-btn {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: calc(var(--chat-z) + 1);
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 2rem));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

.chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background: var(--secondary, #1a1a1a);
  color: #fff;
}

.chat-header h2 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  color: #fff;
}

.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: chatMsgIn 0.25s ease;
}

@keyframes chatMsgIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--primary, #00a651);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg a {
  color: var(--primary, #00a651);
  font-weight: 600;
  text-decoration: underline;
}

.chat-msg--user a {
  color: #fff;
}

.chat-msg ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: chatDot 1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chatDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #eee;
  background: #fff;
}

.chat-form input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.chat-form input:focus {
  outline: 2px solid var(--primary, #00a651);
  outline-offset: 1px;
}

.chat-form button {
  border: none;
  background: var(--primary, #00a651);
  color: #fff;
  border-radius: 8px;
  padding: 0 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: background 0.2s ease;
}

.chat-form button:hover {
  background: #008542;
}

@media (max-width: 767px) {
  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .chat-launcher {
    right: 1rem;
    bottom: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .chat-launcher,
  .chat-msg {
    transition: none;
    animation: none;
  }
}
