.nw-chatbot {
  --chat-bg: rgba(3, 8, 19, 0.88);
  --chat-panel: rgba(10, 20, 43, 0.84);
  --chat-line: var(--line, rgba(135, 159, 255, 0.22));
  --chat-text: var(--text, #f7f9ff);
  --chat-muted: var(--muted, #abb4c7);
  --chat-blue: var(--blue, #111111);
  --chat-purple: var(--purple, rgb(251, 48, 3));
  --chat-green: var(--green, #18d978);
  --chat-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
  color: var(--chat-text);
  font-family: var(--font, "Inter", "Segoe UI", Arial, sans-serif);
  position: fixed;
  right: 28px;
  bottom: 88px;
  z-index: 120;
}

.nw-chatbot * {
  box-sizing: border-box;
}

.nw-chatbot-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 34% 26%,
      rgba(255, 255, 255, 0.28),
      transparent 28px
    ),
    linear-gradient(135deg, rgba(17, 17, 17, 0.98), rgba(251, 48, 3, 0.96));
  box-shadow: 0 18px 48px rgba(251, 48, 3, 0.3);
  cursor: pointer;
  animation: nwChatFloat 4s ease-in-out infinite;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease;
}

.nw-chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 24px 58px rgba(251, 48, 3, 0.38);
}

.nw-chatbot-toggle-glow {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    rgba(251, 48, 3, 0.24),
    rgba(24, 217, 120, 0.18)
  );
  filter: blur(14px);
  z-index: -1;
}

.nw-chatbot-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(2, 7, 18, 0.34);
  color: #fff;
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.nw-chatbot-avatar::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 9px;
  height: 9px;
  border: 2px solid rgba(2, 7, 18, 0.92);
  border-radius: 50%;
  background: var(--chat-green);
}

.nw-chatbot-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  border: 2px solid #020712;
  border-radius: 999px;
  background: #ff4d6d;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.nw-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 84px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(420px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 220px));
  min-height: 440px;
  border: 1px solid var(--chat-line);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(12, 25, 54, 0.78), rgba(2, 8, 20, 0.84)),
    var(--chat-bg);
  box-shadow: var(--chat-shadow);
  backdrop-filter: blur(20px);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.nw-chatbot.is-open .nw-chatbot-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.nw-chatbot.is-open .nw-chatbot-badge {
  display: none;
}

.nw-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(3, 8, 19, 0.58);
}

.nw-chatbot-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.nw-chatbot-logo {
  display: grid;
  place-items: center;
  width: 72px;
  height: 34px;
  border-radius: 10px;
  background: #fff;
  color: rgb(251, 48, 3);
  font-size: 17px;
  font-weight: 950;
  font-style: italic;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nw-chatbot-identity strong,
.nw-chatbot-identity span {
  display: block;
}

.nw-chatbot-identity strong {
  font-size: 15px;
  line-height: 1.2;
}

.nw-chatbot-identity span {
  margin-top: 4px;
  color: var(--chat-muted);
  font-size: 12px;
}

.nw-chatbot-identity i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--chat-green);
  box-shadow: 0 0 12px rgba(24, 217, 120, 0.8);
}

.nw-chatbot-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.nw-chatbot-icon,
.nw-chatbot-send,
.nw-chatbot-secondary {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.nw-chatbot-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.nw-chatbot-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.nw-chatbot-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(135, 159, 255, 0.45) transparent;
}

.nw-chatbot-message {
  display: grid;
  gap: 6px;
  max-width: 86%;
}

.nw-chatbot-message.user {
  align-self: flex-end;
}

.nw-chatbot-message.bot {
  align-self: flex-start;
}

.nw-chatbot-bubble {
  position: relative;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--chat-text);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.nw-chatbot-message.user .nw-chatbot-bubble {
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--chat-blue), var(--chat-purple));
  box-shadow: 0 12px 34px rgba(251, 48, 3, 0.18);
}

.nw-chatbot-message.bot .nw-chatbot-bubble {
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.065);
}

.nw-chatbot-bubble p {
  margin: 0 0 8px;
}

.nw-chatbot-bubble p:last-child {
  margin-bottom: 0;
}

.nw-chatbot-bubble a {
  color: #69bdff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nw-chatbot-bubble pre,
.nw-chatbot-bubble code {
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  font-family: Consolas, "Courier New", monospace;
}

.nw-chatbot-bubble code {
  padding: 2px 5px;
}

.nw-chatbot-bubble pre {
  margin: 8px 0 0;
  padding: 10px;
  overflow-x: auto;
}

.nw-chatbot-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--chat-muted);
  font-size: 11px;
}

.nw-chatbot-message.user .nw-chatbot-meta {
  justify-content: flex-end;
}

.nw-chatbot-copy {
  border: 0;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}

.nw-chatbot-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(3, 8, 19, 0.58);
  padding: 12px;
}

.nw-chatbot-typing {
  align-items: center;
  gap: 5px;
  margin: 0 0 8px;
  color: var(--chat-muted);
  font-size: 12px;
}

.nw-chatbot-typing:not([hidden]) {
  display: flex;
}

.nw-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: nwChatTyping 1s ease-in-out infinite;
}

.nw-chatbot-typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.nw-chatbot-typing span:nth-child(3) {
  animation-delay: 0.24s;
}

.nw-chatbot-form {
  display: grid;
  gap: 9px;
}

.nw-chatbot-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.nw-chatbot-form textarea {
  width: 100%;
  min-height: 48px;
  max-height: 126px;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  outline: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
  padding: 13px 14px;
  font: inherit;
  line-height: 1.4;
}

.nw-chatbot-form textarea::placeholder {
  color: #7f8aa1;
}

.nw-chatbot-form textarea:focus {
  border-color: rgba(251, 48, 3, 0.6);
  box-shadow: 0 0 0 3px rgba(251, 48, 3, 0.12);
}

.nw-chatbot-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--chat-muted);
  font-size: 12px;
}

.nw-chatbot-secondary {
  margin-left: auto;
  padding: 0 10px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
}

.nw-chatbot-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-blue), var(--chat-purple));
  box-shadow: 0 10px 28px rgba(188, 194, 201, 0.25);
}

.nw-chatbot-send:disabled,
.nw-chatbot-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

@keyframes nwChatTyping {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (prefers-color-scheme: light) {
  .nw-chatbot {
    --chat-bg: rgba(246, 249, 255, 0.9);
    --chat-panel: rgba(255, 255, 255, 0.82);
    --chat-text: #071426;
    --chat-muted: #5c687d;
    --chat-shadow: 0 28px 90px rgba(17, 32, 62, 0.22);
  }

  .nw-chatbot-panel,
  .nw-chatbot-header,
  .nw-chatbot-footer {
    background-color: var(--chat-panel);
  }

  .nw-chatbot-message.bot .nw-chatbot-bubble,
  .nw-chatbot-icon,
  .nw-chatbot-secondary,
  .nw-chatbot-form textarea {
    background: rgba(7, 20, 38, 0.06);
  }
}

@media (max-width: 640px) {
  .nw-chatbot {
    right: 14px;
    bottom: 76px;
  }

  .nw-chatbot-toggle {
    width: 56px;
    height: 56px;
  }

  .nw-chatbot-avatar {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .nw-chatbot-badge {
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
  }

  .nw-chatbot-panel {
    position: fixed;
    left: 50%;
    right: auto;
    top: 112px;
    bottom: 76px;
    width: min(92vw, 440px);
    height: auto;
    min-height: 0;
    border-radius: 16px;
    transform: translateX(-50%) translateY(16px) scale(0.96);
    transform-origin: bottom right;
  }

  .nw-chatbot.is-open .nw-chatbot-panel {
    transform: translateX(-50%) translateY(0) scale(1);
  }

  .nw-chatbot-logo {
    width: 82px;
    height: 28px;
  }

  .nw-chatbot-header {
    padding: 10px;
    gap: 8px;
  }

  .nw-chatbot-identity {
    gap: 8px;
  }

  .nw-chatbot-identity strong {
    font-size: 14px;
  }

  .nw-chatbot-identity span {
    font-size: 11px;
  }

  .nw-chatbot-actions {
    gap: 6px;
  }

  .nw-chatbot-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .nw-chatbot-body {
    gap: 11px;
    padding: 12px;
  }

  .nw-chatbot-message {
    max-width: 90%;
  }

  .nw-chatbot-bubble {
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
  }

  .nw-chatbot-footer {
    padding: 10px;
  }

  .nw-chatbot-form textarea {
    min-height: 44px;
    max-height: 96px;
    padding: 11px 12px;
    border-radius: 12px;
    font-size: 14px;
  }

  .nw-chatbot-form-row {
    gap: 6px;
    font-size: 11px;
  }

  .nw-chatbot-secondary {
    min-height: 30px;
    padding: 0 9px;
    font-size: 11px;
  }

  .nw-chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
}

@media (max-width: 380px) {
  .nw-chatbot-panel {
    left: 50%;
    right: auto;
    top: 96px;
    bottom: 70px;
    width: min(90vw, 330px);
  }

  .nw-chatbot-logo {
    display: none;
  }

  .nw-chatbot-icon {
    width: 32px;
    height: 32px;
  }

  .nw-chatbot-message {
    max-width: 92%;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .nw-chatbot-panel {
    width: min(440px, calc(100vw - 48px));
    height: min(600px, calc(100vh - 190px));
  }
}
