/* Chat Widget — Savoy Place Memory Care
   Uses site design tokens from styles.css */

/* Floating button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--honey, #D69A3A);
  color: var(--spruce-deep, #1E362E);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,0.24);
}
.chat-fab:focus-visible {
  outline: 3px solid var(--honey, #D69A3A);
  outline-offset: 3px;
}
.chat-fab svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}
.chat-fab[aria-expanded="true"] .chat-fab-icon { display: none; }
.chat-fab[aria-expanded="false"] .chat-fab-close { display: none; }
.chat-fab[aria-expanded="true"] .chat-fab-close { display: block; }
.chat-fab[aria-expanded="false"] .chat-fab-icon { display: block; }

/* Panel */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 400px;
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--paper, #FBF8F1);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--body, 'Nunito Sans', 'Segoe UI', sans-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink, #2B2A26);
}
.chat-panel[hidden] {
  display: none;
}

/* Header */
.chat-header {
  background: var(--spruce, #29473C);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-header-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}
.chat-header-text {
  flex: 1;
}
.chat-header-title {
  font-weight: 700;
  font-size: 16px;
}
.chat-header-sub {
  font-size: 12px;
  opacity: 0.8;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink, #2B2A26);
  border: 1px solid var(--line, #E2DCCB);
  border-bottom-left-radius: 4px;
}
.chat-msg-user {
  align-self: flex-end;
  background: var(--spruce, #29473C);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--line, #E2DCCB);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft, #5A574E);
  opacity: 0.4;
  animation: chatBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Follow-up buttons (Did that help?) */
.chat-followup {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-self: flex-start;
}
.chat-followup button {
  font-family: inherit;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line, #E2DCCB);
  background: #fff;
  color: var(--ink, #2B2A26);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chat-followup button:hover {
  background: var(--mist, #E7EDE4);
  border-color: var(--spruce, #29473C);
}
.chat-followup button:focus-visible {
  outline: 3px solid var(--honey, #D69A3A);
  outline-offset: 2px;
}

/* Lead capture inline form */
.chat-lead-form {
  align-self: flex-start;
  background: var(--honey-soft, #F3E3C4);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
  max-width: 85%;
  animation: chatFadeIn 0.2s ease;
}
.chat-lead-form p {
  font-size: 14px;
  margin: 0 0 10px;
  color: var(--ink, #2B2A26);
}
.chat-lead-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink, #2B2A26);
}
.chat-lead-form input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line, #E2DCCB);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 8px;
  background: #fff;
  box-sizing: border-box;
}
.chat-lead-form input:focus {
  outline: 2px solid var(--honey, #D69A3A);
  outline-offset: 1px;
  border-color: var(--honey, #D69A3A);
}
.chat-lead-form button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: var(--honey, #D69A3A);
  color: var(--spruce-deep, #1E362E);
  cursor: pointer;
  transition: background 0.15s;
}
.chat-lead-form button:hover {
  background: #c48a2e;
}

/* Input area */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line, #E2DCCB);
  background: #fff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line, #E2DCCB);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  resize: none;
  min-height: 20px;
  max-height: 80px;
  background: var(--paper, #FBF8F1);
  color: var(--ink, #2B2A26);
}
.chat-input:focus {
  outline: 2px solid var(--honey, #D69A3A);
  outline-offset: 1px;
  border-color: var(--honey, #D69A3A);
}
.chat-input::placeholder {
  color: var(--ink-soft, #5A574E);
  opacity: 0.7;
}
.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--spruce, #29473C);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s;
}
.chat-send:hover {
  background: var(--spruce-deep, #1E362E);
}
.chat-send:focus-visible {
  outline: 3px solid var(--honey, #D69A3A);
  outline-offset: 2px;
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Suggestion chips */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  align-self: flex-start;
  animation: chatFadeIn 0.2s ease;
}
.chat-suggestion-chip {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--honey, #D69A3A);
  background: #fff;
  color: var(--ink, #2B2A26);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.chat-suggestion-chip:hover {
  background: var(--honey-soft, #F3E3C4);
  border-color: #c48a2e;
}
.chat-suggestion-chip:focus-visible {
  outline: 3px solid var(--honey, #D69A3A);
  outline-offset: 2px;
}

/* Mobile responsive */
@media (max-width: 560px) {
  .chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    bottom: 80px;
    right: 8px;
    border-radius: 14px;
  }
  .chat-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}
