/* Sanders AI chat widget — scoped under #sanders-chat-root.
   Matches site palette: navy #1B365D, bone #F6F3EC, ink #151822.
   Float-bottom-right bubble + slide-up panel. */

#sanders-chat-root {
  --schat-navy: #1B365D;
  --schat-navy-hover: #14263F;
  --schat-bone: #F6F3EC;
  --schat-ink: #151822;
  --schat-graphite: #3F4654;
  --schat-rule: rgba(21, 24, 34, 0.09);
  --schat-bg: #ffffff;
  --schat-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  --schat-radius: 14px;
  --schat-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  font-family: var(--schat-font);
  color: var(--schat-ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#sanders-chat-bubble {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--schat-navy);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--schat-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999998;
  transition: transform 0.18s ease, background 0.18s ease;
}
#sanders-chat-bubble:hover {
  background: var(--schat-navy-hover);
  transform: translateY(-2px);
}
#sanders-chat-bubble.sanders-chat-bubble-open {
  transform: rotate(8deg) scale(0.92);
}

#sanders-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--schat-bg);
  border-radius: var(--schat-radius);
  box-shadow: var(--schat-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 999999;
  overflow: hidden;
}
#sanders-chat-panel.sanders-chat-panel-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sanders-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--schat-navy);
  color: white;
  border-top-left-radius: var(--schat-radius);
  border-top-right-radius: var(--schat-radius);
}
.sanders-chat-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.sanders-chat-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.sanders-chat-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
}
.sanders-chat-close:hover { opacity: 1; }

.sanders-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--schat-bone);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sanders-chat-msg {
  display: flex;
  width: 100%;
}
.sanders-chat-msg-user { justify-content: flex-end; }
.sanders-chat-msg-assistant { justify-content: flex-start; }

.sanders-chat-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sanders-chat-msg-user .sanders-chat-msg-bubble {
  background: var(--schat-navy);
  color: white;
  border-bottom-right-radius: 4px;
}
.sanders-chat-msg-assistant .sanders-chat-msg-bubble {
  background: white;
  color: var(--schat-ink);
  border: 1px solid var(--schat-rule);
  border-bottom-left-radius: 4px;
}
.sanders-chat-msg-bubble a {
  color: var(--schat-navy);
  text-decoration: underline;
  font-weight: 600;
}
.sanders-chat-msg-user .sanders-chat-msg-bubble a {
  color: #b5d2ff;
}

.sanders-chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.sanders-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--schat-graphite);
  opacity: 0.4;
  animation: sanders-chat-typing 1.2s infinite ease-in-out;
}
.sanders-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.sanders-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sanders-chat-typing {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.sanders-chat-composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--schat-rule);
  background: white;
  align-items: flex-end;
}
.sanders-chat-input {
  flex: 1;
  border: 1px solid var(--schat-rule);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--schat-font);
  font-size: 14.5px;
  line-height: 1.4;
  resize: none;
  outline: none;
  background: white;
  color: var(--schat-ink);
  transition: border-color 0.15s ease;
  max-height: 120px;
}
.sanders-chat-input:focus { border-color: var(--schat-navy); }
.sanders-chat-input:disabled { opacity: 0.55; }

.sanders-chat-send {
  background: var(--schat-navy);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--schat-font);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sanders-chat-send:hover:not(:disabled) { background: var(--schat-navy-hover); }
.sanders-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.sanders-chat-closed {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--schat-graphite);
  padding: 14px;
}

@media (max-width: 480px) {
  #sanders-chat-panel {
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    max-width: none;
    height: calc(100vh - 100px);
  }
  #sanders-chat-bubble {
    right: 14px;
    bottom: 14px;
  }
}
