/* ── NWS Chat Assistant ── */

/* Floating bubble */
.nws-chat-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--signal);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(12, 17, 28, 0.25);
  transition: transform 0.2s, opacity 0.2s, background 0.15s;
  z-index: 9998;
}
.nws-chat-bubble:hover {
  background: var(--signal-hover);
  transform: scale(1.05);
}
.nws-chat-bubble--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Chat panel */
.nws-chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 500px;
  max-width: calc(100vw - 2rem);
  height: 780px;
  max-height: calc(100vh - 4rem);
  background: white;
  border-radius: 1rem;
  box-shadow: 0 12px 40px rgba(12, 17, 28, 0.2), 0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s, transform 0.25s;
  overflow: hidden;
}
.nws-chat-panel--open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.nws-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--ink);
  color: white;
  flex-shrink: 0;
}
.nws-chat-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nws-chat-header__left > i {
  font-size: 1.25rem;
  color: var(--signal);
}
.nws-chat-header__title {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.nws-chat-header__sub {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: 0.125rem;
}
.nws-chat-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  font-size: 1rem;
}
.nws-chat-close:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* Messages area */
.nws-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f8f7f4;
}

/* Welcome state */
.nws-chat-welcome {
  text-align: center;
  padding: 1rem 1rem 1rem;
}
.nws-chat-welcome__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--signal-soft);
  color: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.25rem;
}
.nws-chat-welcome__title {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
.nws-chat-welcome__sub {
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.nws-chat-welcome__disclaimer {
  font-size: 0.625rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Bottom input bar is always visible */

/* Suggestion pills — 2-column grid */
.nws-chat-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375rem;
}
.nws-chat-suggestions__label {
  grid-column: 1 / -1;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.625rem;
  margin-bottom: 0.125rem;
}
.nws-chat-suggestions__label:first-child {
  margin-top: 0;
}
.nws-chat-suggestions__divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0.25rem;
}
.nws-chat-suggestions__divider::before,
.nws-chat-suggestions__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule, #e2e8f0);
}
.nws-chat-suggestions__divider span {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #94a3b8;
  white-space: nowrap;
}
.nws-chat-suggestion {
  font-size: 0.75rem;
  padding: 0.4375rem 0.625rem;
  border-radius: 99px;
  border: 1px solid var(--rule);
  background: white;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: 'IBM Plex Sans', sans-serif;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nws-chat-suggestion:hover {
  border-color: var(--signal);
  color: var(--signal);
}

/* Message bubbles */
.nws-chat-msg {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  animation: nws-chat-fade 0.2s ease;
}
.nws-chat-msg--user {
  justify-content: flex-end;
}
.nws-chat-msg--user .nws-chat-msg__body {
  background: var(--ink);
  color: white;
  border-radius: 1rem 1rem 0.25rem 1rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 85%;
}
.nws-chat-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--signal-soft);
  color: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.nws-chat-msg--assistant .nws-chat-msg__body {
  background: white;
  color: var(--ink);
  border-radius: 1rem 1rem 1rem 0.25rem;
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  max-width: 85%;
  border: 1px solid #e8e5de;
}
.nws-chat-msg--assistant .nws-chat-msg__body p {
  margin-bottom: 0.5rem;
}
.nws-chat-msg--assistant .nws-chat-msg__body p:last-child {
  margin-bottom: 0;
}
.nws-chat-msg--assistant .nws-chat-msg__body ul {
  margin: 0.375rem 0;
  padding-left: 1.25rem;
}
.nws-chat-msg--assistant .nws-chat-msg__body li {
  margin-bottom: 0.25rem;
}
.nws-chat-msg--assistant .nws-chat-msg__body strong {
  font-weight: 600;
  color: var(--ink);
}
.nws-chat-answer-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

/* Error message */
.nws-chat-error {
  color: var(--signal);
  font-style: italic;
}

/* Typing indicator */
.nws-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.25rem 0;
}
.nws-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: nws-chat-bounce 1.2s ease-in-out infinite;
}
.nws-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.nws-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes nws-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
@keyframes nws-chat-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Input area */
.nws-chat-input-area {
  padding: 0.75rem 1rem 1rem;
  background: white;
  border-top: 1px solid #e8e5de;
  flex-shrink: 0;
}
.nws-chat-disclaimer {
  font-size: 0.625rem;
  color: #94a3b8;
  text-align: center;
  margin-bottom: 0.5rem;
}
.nws-chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.nws-chat-form input {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 99px;
  font-size: 0.875rem;
  background: #f8f7f4;
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.nws-chat-form input:focus {
  border-color: var(--signal);
}
.nws-chat-form input::placeholder {
  color: #94a3b8;
}
.nws-chat-form button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--signal);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  transition: background 0.15s;
  flex-shrink: 0;
}
.nws-chat-form button:hover {
  background: var(--signal-hover);
}
.nws-chat-form button:disabled {
  cursor: not-allowed;
}

/* Suggested page links */
.nws-chat-links {
  margin-top: 0.625rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e8e5de;
}
.nws-chat-links__label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nws-chat-link {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.3rem 0;
  transition: color 0.15s;
}
.nws-chat-link:hover {
  color: var(--signal);
}
.nws-chat-link i {
  font-size: 0.625rem;
  margin-right: 0.25rem;
  color: var(--signal);
}

/* Tablet: slightly smaller panel */
@media (min-width: 481px) and (max-width: 1024px) {
  .nws-chat-panel {
    width: 440px;
    height: 700px;
  }
}

/* Mobile: full-width panel */
@media (max-width: 480px) {
  .nws-chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

/* Mobile: chat bubble matches State circle size and safe-area offset */
@media (max-width: 768px) {
  .nws-chat-bubble {
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nws-chat-panel { transition: opacity 0.1s; transform: none !important; }
  .nws-chat-bubble { transition: none; }
  .nws-chat-typing span { animation: none; }
  .nws-chat-msg { animation: none; }
}
