/* NudgeWell Chat Widget — Public Support Bot */

#nw-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Bubble Button ── */
#nw-chat-bubble {
  width: 56px;
  height: 56px;
  background: #10B981;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  margin-left: auto;
}

#nw-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(16, 185, 129, 0.55);
}

#nw-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.2s ease;
}

#nw-chat-bubble .nw-close-icon {
  display: none;
}

#nw-chat-widget.nw-open #nw-chat-bubble .nw-chat-icon {
  display: none;
}

#nw-chat-widget.nw-open #nw-chat-bubble .nw-close-icon {
  display: block;
}

/* Pulse badge */
#nw-chat-badge {
  position: absolute;
  bottom: 64px;
  right: 0;
  background: #0B1221;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #F1F5F9;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: nw-fade-in 0.5s ease forwards, nw-pulse-glow 2.5s ease 0.5s infinite;
  cursor: pointer;
  line-height: 1.4;
  max-width: 220px;
}

#nw-chat-badge::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: #0B1221;
  border-right: 1px solid rgba(16, 185, 129, 0.3);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  transform: rotate(45deg);
}

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

@keyframes nw-pulse-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 4px 24px rgba(16, 185, 129, 0.25); }
}

/* ── Panel ── */
#nw-chat-panel {
  width: 360px;
  max-width: calc(100vw - 48px);
  background: #0B1221;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(16, 185, 129, 0.05);
  display: none;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;
  max-height: 520px;
  animation: nw-panel-in 0.25s ease forwards;
}

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

#nw-chat-widget.nw-open #nw-chat-panel {
  display: flex;
}

/* Header */
#nw-chat-header {
  background: linear-gradient(135deg, #111B2E 0%, #0F1C30 100%);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nw-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #10B981, #059669);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.nw-header-text {
  flex: 1;
}

.nw-header-name {
  font-size: 14px;
  font-weight: 600;
  color: #F1F5F9;
  font-family: 'Space Grotesk', sans-serif;
}

.nw-header-status {
  font-size: 11px;
  color: #10B981;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.nw-status-dot {
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  animation: nw-blink 2s ease infinite;
}

@keyframes nw-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Messages */
#nw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 185, 129, 0.2) transparent;
}

#nw-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#nw-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#nw-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.2);
  border-radius: 2px;
}

.nw-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.nw-msg.nw-bot {
  background: #111B2E;
  border: 1px solid rgba(16, 185, 129, 0.12);
  color: #E2E8F0;
  border-radius: 4px 12px 12px 12px;
  align-self: flex-start;
}

.nw-msg.nw-user {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  border-radius: 12px 4px 12px 12px;
  align-self: flex-end;
}

/* Typing indicator */
.nw-typing {
  background: #111B2E;
  border: 1px solid rgba(16, 185, 129, 0.12);
  padding: 12px 16px;
  border-radius: 4px 12px 12px 12px;
  align-self: flex-start;
  display: flex;
  gap: 4px;
  align-items: center;
}

.nw-typing span {
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  animation: nw-bounce 1.2s ease infinite;
}

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

@keyframes nw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Email capture */
.nw-email-capture {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 4px;
  align-self: stretch;
}

.nw-email-capture p {
  font-size: 12.5px;
  color: #94A3B8;
  margin-bottom: 8px;
  line-height: 1.5;
}

.nw-email-row {
  display: flex;
  gap: 6px;
}

.nw-email-input {
  flex: 1;
  background: #0B1221;
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  color: #F1F5F9;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.nw-email-input:focus {
  border-color: rgba(16, 185, 129, 0.5);
}

.nw-email-input::placeholder {
  color: #64748B;
}

.nw-email-btn {
  background: #10B981;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.2s;
}

.nw-email-btn:hover {
  background: #059669;
}

/* Inline links in bot messages */
.nw-msg.nw-bot .nw-link {
  color: #10B981;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.nw-msg.nw-bot .nw-link:hover {
  color: #34D399;
}

/* CTA block */
.nw-cta-block {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 4px;
  align-self: stretch;
  text-align: center;
}

.nw-cta-block p {
  font-size: 12.5px;
  color: #94A3B8;
  margin-bottom: 10px;
  line-height: 1.5;
}

.nw-cta-btn {
  display: inline-block;
  background: #10B981;
  color: #fff;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.2s;
}

.nw-cta-btn:hover {
  background: #059669;
}

/* Input area */
#nw-chat-input-area {
  border-top: 1px solid rgba(16, 185, 129, 0.1);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #0B1221;
  flex-shrink: 0;
}

#nw-chat-input {
  flex: 1;
  background: #111B2E;
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 10px;
  padding: 9px 12px;
  color: #F1F5F9;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.45;
  transition: border-color 0.2s;
}

#nw-chat-input:focus {
  border-color: rgba(16, 185, 129, 0.4);
}

#nw-chat-input::placeholder {
  color: #64748B;
}

#nw-chat-send {
  width: 38px;
  height: 38px;
  background: #10B981;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

#nw-chat-send:hover:not(:disabled) {
  background: #059669;
  transform: scale(1.05);
}

#nw-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#nw-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* Mobile */
@media (max-width: 480px) {
  #nw-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  #nw-chat-panel {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }

  #nw-chat-badge {
    max-width: 180px;
    font-size: 12px;
  }
}
