/* Presence Atelier — Chat Widget
   Uses same CSS variables as site.css:
   --ink, --paper, --paper-2, --brass, --teal, --teal-2, --muted, --line
   --serif: Cormorant Garamond, --sans: Epilogue, --mono: IBM Plex Mono
*/

/* ── Toggle button ── */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--teal-2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(12,17,21,0.22);
  transition: transform 0.18s, background 0.18s;
  padding: 0;
}
.chat-toggle:hover { transform: scale(1.07); background: var(--teal); }
.chat-toggle:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}
.chat-toggle svg { width: 26px; height: 26px; fill: var(--paper); flex-shrink: 0; }

/* ── Panel ── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 900;
  width: min(380px, calc(100vw - 32px));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(12,17,21,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(560px, calc(100vh - 140px));
  font-family: var(--sans);
}

/* ── Header ── */
.chat-header {
  padding: 18px 20px;
  background: var(--teal-2);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header-text h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}
.chat-header-text p {
  font-size: 0.75rem;
  opacity: 0.82;
  margin: 2px 0 0;
  font-family: var(--mono);
  letter-spacing: 0.03em;
}
.chat-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
  display: flex;
  flex-shrink: 0;
}
.chat-close:hover { opacity: 1; }
.chat-close:focus-visible { outline: 2px solid var(--brass); border-radius: 4px; }
.chat-close svg { width: 18px; height: 18px; fill: var(--paper); }

/* ── Messages area ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ── Bubbles ── */
.chat-bubble {
  max-width: 85%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--teal-2);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}
.chat-bubble.bot {
  align-self: flex-start;
  background: var(--paper-2);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--line);
}
.chat-bubble.bot a {
  color: var(--teal-2);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-bubble.bot a:hover { color: var(--teal); }

/* ── Quick-reply chips ── */
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 20px 16px;
  flex-shrink: 0;
}
.chat-chip {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-family: var(--sans);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.12s;
  letter-spacing: 0.01em;
}
.chat-chip:hover { background: var(--paper); border-color: var(--brass); transform: translateY(-1px); }
.chat-chip:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ── WhatsApp CTA button ── */
.chat-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 20px 16px;
  padding: 12px 20px;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.88rem;
  font-family: var(--sans);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.chat-wa-btn:hover { background: #1fb855; transform: translateY(-1px); }
.chat-wa-btn:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.chat-wa-btn svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* ── Input area ── */
.chat-input-row {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: var(--paper);
}
.chat-input-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-family: var(--sans);
  background: var(--paper-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.chat-input-row input:focus { border-color: var(--brass); }
.chat-input-row input::placeholder { color: var(--muted); }
.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--teal-2);
  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(--teal); transform: scale(1.06); }
.chat-send:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.chat-send svg { width: 16px; height: 16px; fill: var(--paper); }

/* ── Hidden state ── */
.chat-panel[hidden] { display: none; }

/* ── Mobile adjustments ── */
@media (max-width: 480px) {
  .chat-toggle { bottom: 20px; right: 16px; }
  .chat-panel { bottom: 88px; right: 12px; width: calc(100vw - 24px); }
}
