#aiChatWidget,
#aiChatWidget * {
  box-sizing: border-box;
}

#aiChatWidget {
  --chat-accent: #0e8f59;
  --chat-accent-2: #0a7a4b;
  --chat-bg: #ffffff;
  --chat-text: #1f2b2c;
  --chat-border: #d7e5de;
  --chat-bubble-bot: #f2f8f5;
  --chat-bubble-user: #0f7d4f;
  --chat-shadow: 0 16px 40px rgba(19, 68, 49, 0.22);
  --chat-ring: 0 0 0 3px rgba(14, 143, 89, 0.2);
  position: fixed !important;
  right: 20px !important;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 99999 !important;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#aiChatWidget .ai-chat-teaser {
  border: 0;
  border-radius: 999px;
  background: #ffffff;
  color: #0e7f50;
  box-shadow: 0 8px 20px rgba(19, 68, 49, 0.18);
  padding: 8px 14px;
  margin: 0;
  display: block !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  animation: aiChatTeaserPulse 3.8s ease-in-out infinite;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#aiChatWidget .ai-chat-teaser.is-hiding {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
}

#aiChatWidget .ai-chat-toggle {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-2));
  color: #fff;
  height: 52px;
  padding: 0 18px 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  width: auto;
  justify-content: flex-start;
  transition: opacity 0.24s ease, transform 0.24s ease, width 0.28s ease, border-radius 0.28s ease, padding 0.28s ease;
  margin: 0;
}

#aiChatWidget .ai-chat-toggle__dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  position: relative;
}

#aiChatWidget .ai-chat-toggle__dot::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff;
}

#aiChatWidget .ai-chat-toggle__mini {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#aiChatWidget .ai-chat-toggle.is-compact {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
  gap: 0;
  background: radial-gradient(circle at 30% 25%, #21b07a, #0d8454);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow:
    0 12px 24px rgba(11, 88, 56, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

#aiChatWidget .ai-chat-toggle.is-compact .ai-chat-toggle__dot,
#aiChatWidget .ai-chat-toggle.is-compact .ai-chat-toggle__text {
  display: none;
}

#aiChatWidget .ai-chat-toggle.is-compact .ai-chat-toggle__mini {
  display: inline-flex;
}

#aiChatWidget .ai-chat-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: min(610px, calc(100vh - 94px));
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 18px;
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#aiChatWidget.is-open .ai-chat-panel {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
  bottom: 0;
}

#aiChatWidget.is-open .ai-chat-toggle,
#aiChatWidget.is-open .ai-chat-teaser {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

#aiChatWidget .ai-chat-header {
  background: linear-gradient(135deg, #0e8f59, #219b71);
  color: #fff;
  padding: 14px 14px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#aiChatWidget .ai-chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

#aiChatWidget .ai-chat-brand__logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 3px;
  object-fit: contain;
}

#aiChatWidget .ai-chat-title {
  display: block;
  font-size: 15px;
  line-height: 1.1;
}

#aiChatWidget .ai-chat-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.92;
}

#aiChatWidget .ai-chat-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 30px;
  padding: 0;
}

#aiChatWidget .ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background:
    radial-gradient(circle at 92% 0%, rgba(13, 143, 86, 0.08), transparent 50%),
    #f8fcfa;
}

#aiChatWidget .ai-chat-messages::-webkit-scrollbar {
  width: 8px;
}

#aiChatWidget .ai-chat-messages::-webkit-scrollbar-thumb {
  background: #c9ddd2;
  border-radius: 99px;
}

#aiChatWidget .ai-chat-message {
  max-width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

#aiChatWidget .ai-chat-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #b9d8c8;
  padding: 3px;
  box-shadow: 0 4px 10px rgba(17, 77, 53, 0.2);
}

#aiChatWidget .ai-chat-message--bot {
  margin-right: auto;
  color: var(--chat-text);
  background: var(--chat-bubble-bot);
  border: 1px solid #dcebe3;
  max-width: 86%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#aiChatWidget .ai-chat-message__text {
  display: block;
}

#aiChatWidget .ai-chat-phone-link {
  color: #0b7c4d;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-weight: 600;
}

#aiChatWidget .ai-chat-phone-link:hover,
#aiChatWidget .ai-chat-phone-link:focus-visible {
  color: #0a6d44;
}

#aiChatWidget .ai-chat-link {
  color: #0b7c4d;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

#aiChatWidget .ai-chat-link:hover,
#aiChatWidget .ai-chat-link:focus-visible {
  color: #0a6d44;
}

#aiChatWidget .ai-chat-message--user {
  margin-left: auto;
  color: #fff;
  background: var(--chat-bubble-user);
}

#aiChatWidget .ai-chat-message--system {
  margin-right: auto;
  color: #5c4016;
  background: #fff8e8;
  border: 1px solid #f3e0b9;
}

#aiChatWidget .ai-chat-source {
  margin: 0 auto 10px 0;
  max-width: 86%;
}

#aiChatWidget .ai-chat-source__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #0f6f47;
  text-decoration: none;
  background: #ecf7f1;
  border: 1px solid #cbe6d8;
  border-radius: 999px;
  padding: 6px 10px;
}

#aiChatWidget .ai-chat-source__link:hover,
#aiChatWidget .ai-chat-source__link:focus-visible {
  text-decoration: underline;
}

#aiChatWidget .ai-chat-quick {
  border-top: 1px solid var(--chat-border);
  background: #fbfefd;
  padding: 8px 10px 10px;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #c9ddd2 transparent;
}

#aiChatWidget .ai-chat-quick.is-hidden {
  display: none;
}

#aiChatWidget .ai-chat-quick__btn {
  flex: 0 0 auto;
  border: 1px solid #c7dfd1;
  border-radius: 999px;
  background: #ffffff;
  color: #0e7d50;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 600;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI", Tahoma, Arial, sans-serif;
  cursor: pointer;
}

#aiChatWidget .ai-chat-quick__btn:hover,
#aiChatWidget .ai-chat-quick__btn:focus-visible {
  background: #f3fbf7;
}

#aiChatWidget .ai-chat-quick::-webkit-scrollbar {
  height: 6px;
}

#aiChatWidget .ai-chat-quick::-webkit-scrollbar-thumb {
  background: #c9ddd2;
  border-radius: 99px;
}

#aiChatWidget .ai-chat-form {
  border-top: 1px solid var(--chat-border);
  background: #fff;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 8px;
  align-items: center;
}

#aiChatWidget .ai-chat-input {
  resize: none;
  min-height: 44px;
  height: 44px;
  max-height: 44px;
  border: 1px solid #c9ddd2;
  border-radius: 11px;
  padding: 10px 11px;
  color: var(--chat-text);
  font: inherit;
  line-height: 1.2;
  overflow-y: auto;
}

#aiChatWidget .ai-chat-input:focus {
  outline: none;
  border-color: #5da886;
  box-shadow: var(--chat-ring);
}

#aiChatWidget .ai-chat-send {
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #0d8a57, #17a06d);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  width: 112px;
  padding: 0 10px;
  cursor: pointer;
  letter-spacing: 0.1px;
  box-shadow: 0 8px 16px rgba(14, 127, 80, 0.26);
}

#aiChatWidget .ai-chat-send:disabled {
  opacity: 0.68;
  cursor: default;
  box-shadow: none;
}

#aiChatWidget .ai-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

#aiChatWidget .ai-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #80a895;
  animation: aiChatTyping 1.05s infinite ease-in-out;
}

#aiChatWidget .ai-chat-typing span:nth-child(2) {
  animation-delay: 0.13s;
}

#aiChatWidget .ai-chat-typing span:nth-child(3) {
  animation-delay: 0.26s;
}

#aiChatWidget .ai-chat-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}

@keyframes aiChatTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

@keyframes aiChatTeaserPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@media (max-width: 640px) {
  #aiChatWidget {
    right: 10px !important;
    left: 10px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
    align-items: flex-end;
  }

  #aiChatWidget .ai-chat-teaser {
    max-width: min(78vw, 280px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #aiChatWidget .ai-chat-toggle {
    height: 48px;
    padding-right: 14px;
  }

  #aiChatWidget .ai-chat-toggle__text {
    font-size: 14px;
  }

  #aiChatWidget .ai-chat-toggle.is-compact {
    width: 52px;
    height: 52px;
  }

  #aiChatWidget .ai-chat-panel {
    right: 0;
    left: 0;
    width: 100%;
    bottom: 58px;
    height: min(72vh, 620px);
  }

  #aiChatWidget.is-open .ai-chat-panel {
    bottom: 0;
  }
}
