/* ============================================================
   NOAH WIRE — Sales Chat Widget
   Floating assistant widget, slide-up panel, message stream.
   ============================================================ */

/* --- Variables (inherits from style.css) --- */
:root {
  --chat-width: 380px;
  --chat-height: 560px;
  --chat-radius: 16px;
  --chat-z: 9000;
}

/* ---- Floating trigger button ---- */
.chat-trigger {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: var(--chat-z);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(13, 148, 136, 0.45);
  transition: transform 0.2s var(--ease-out),
              box-shadow 0.2s var(--ease-out),
              background 0.2s var(--ease-out);
  outline: none;
}

.chat-trigger:hover {
  transform: scale(1.08);
  background: var(--accent-light);
  box-shadow: 0 6px 28px rgba(13, 148, 136, 0.55);
}

.chat-trigger:active {
  transform: scale(0.96);
}

.chat-trigger svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity 0.15s;
}

.chat-trigger .chat-trigger__icon-open  { display: block; }
.chat-trigger .chat-trigger__icon-close { display: none;  }

.chat-trigger.is-open .chat-trigger__icon-open  { display: none;  }
.chat-trigger.is-open .chat-trigger__icon-close { display: block; }

/* Pulse ring when closed */
.chat-trigger:not(.is-open)::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: chat-pulse 2.8s ease-out infinite;
}

@keyframes chat-pulse {
  0%   { opacity: 0.6; transform: scale(1);    }
  70%  { opacity: 0;   transform: scale(1.35); }
  100% { opacity: 0;   transform: scale(1.35); }
}

/* ---- Chat panel ---- */
.chat-panel {
  position: fixed;
  bottom: calc(1.75rem + 56px + 0.75rem);
  right: 1.75rem;
  z-index: var(--chat-z);
  width: var(--chat-width);
  height: var(--chat-height);
  max-height: calc(100dvh - 140px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--chat-radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  transform: translateY(12px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s var(--ease-out),
              opacity 0.22s var(--ease-out);
  overflow: hidden;
}

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

@media (max-width: 480px) {
  .chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: calc(1.75rem + 56px + 0.5rem);
  }

  .chat-trigger {
    bottom: 1.25rem;
    right: 1.25rem;
  }
}

/* ---- Panel header ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.chat-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header__avatar svg {
  width: 18px;
  height: 18px;
  fill: var(--accent-light);
}

.chat-header__info {
  flex: 1;
  min-width: 0;
}

.chat-header__name {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.chat-header__status {
  font-size: var(--text-xs);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.1rem;
}

.chat-header__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-light);
  display: inline-block;
  flex-shrink: 0;
}

.chat-header__clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
  font-size: 0.75rem;
  transition: color 0.15s;
}

.chat-header__clear:hover {
  color: var(--text-secondary);
}

/* ---- Messages ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1rem;
  gap: 0.75rem;
}

.chat-welcome__logo {
  font-family: var(--font-logo);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-primary);
  text-transform: uppercase;
}

.chat-welcome__tagline {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.chat-welcome__suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  width: 100%;
  margin-top: 0.5rem;
}

.chat-suggestion-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1.4;
}

.chat-suggestion-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--accent-subtle);
}

/* Individual messages */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 88%;
  animation: chat-msg-in 0.18s var(--ease-out);
}

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

.chat-message--user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message__bubble {
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  font-size: var(--text-sm);
  line-height: 1.65;
  word-break: break-word;
}

.chat-message--user .chat-message__bubble {
  background: var(--accent);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}

.chat-message--assistant .chat-message__bubble {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
}

.chat-message--assistant .chat-message__bubble strong {
  color: var(--text-primary);
}

.chat-message--assistant .chat-message__bubble a {
  color: var(--accent-light);
  text-decoration: none;
}

.chat-message--assistant .chat-message__bubble a:hover {
  text-decoration: underline;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.625rem 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  align-self: flex-start;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: chat-dot 1.1s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes chat-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ---- Input area ---- */
.chat-input-wrap {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
  scrollbar-width: none;
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}

.chat-send:hover  { background: var(--accent-light); }
.chat-send:active { transform: scale(0.93); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.chat-send svg {
  width: 17px;
  height: 17px;
  fill: #fff;
}

.chat-footer-note {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 0.375rem;
}

/* ---- Inline "Ask about this" context buttons ---- */
.chat-ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-size: var(--text-sm);
  color: var(--accent-light);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  font-family: var(--font-body);
  text-decoration: none;
  white-space: nowrap;
}

.chat-ask-btn:hover {
  background: rgba(13, 148, 136, 0.18);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.chat-ask-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

.chat-ask-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ---- Homepage CTA variant ---- */
.chat-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  padding: 0.625rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent-light);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.12s;
  font-family: var(--font-body);
  text-decoration: none;
}

.chat-cta-btn:hover {
  background: var(--accent-subtle);
  transform: translateY(-1px);
}

.chat-cta-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}
