/* Chat toggle button (sits directly under the opening-hours section) */

.chat-toggle-btn {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.75rem 1.6rem;
  background: var(--color-terracotta);
  color: var(--color-cream);
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(184, 85, 47, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-toggle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(184, 85, 47, 0.42);
}

/* Backdrop: tapping anywhere outside the panel closes it - a large,
   hard-to-miss alternative to the small close button. */
.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 32, 24, 0.25);
  z-index: 999;
}

/* Chat panel */

.chat-panel {
  position: fixed;
  inset-inline-end: 1rem;
  inset-block-end: 1rem;
  width: min(360px, calc(100vw - 2rem));
  /* dvh accounts for the mobile browser's address bar; vh alone can make
     a "100%"-ish height element appear to cover the full screen on phones. */
  height: min(520px, calc(100vh - 2rem));
  height: min(520px, calc(100dvh - 2rem));
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(43, 32, 24, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  font-family: var(--font-body);
}

/* This is the actual root cause of the panel appearing to ignore open/close:
   the [hidden] attribute's default display:none has the same specificity as
   .chat-panel's own "display: flex" above, and author CSS always wins that
   tie over the browser's default stylesheet - so hidden was doing nothing
   and the panel was visible at all times regardless of its hidden state.
   [hidden] as an attribute selector here outranks the plain class rule
   above, so this correctly takes over. */
.chat-panel[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0.9rem;
  background: var(--color-olive);
  color: var(--color-cream);
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--color-cream);
  flex-shrink: 0;
  background: var(--color-cream-dark);
}

.chat-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1;
}

.chat-header-text strong {
  font-family: var(--font-heading);
  font-size: 1.05rem;
}

.chat-header-text span {
  font-size: 0.8rem;
  opacity: 0.85;
}

.chat-close-btn {
  background: none;
  border: none;
  color: var(--color-cream);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  width: 44px;
  height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.chat-close-btn:hover {
  background: rgba(245, 237, 219, 0.15);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.chat-bubble {
  max-width: 82%;
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-bot {
  align-self: flex-start;
  background: var(--color-cream-dark);
  color: var(--color-ink);
  border-bottom-left-radius: 4px;
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--color-olive);
  color: var(--color-cream);
  border-bottom-right-radius: 4px;
}

.chat-bubble-typing {
  opacity: 0.65;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
}

.chat-input {
  flex: 1;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: var(--color-cream);
  color: var(--color-ink);
}

.chat-input:focus {
  outline: 2px solid var(--color-olive);
  outline-offset: 1px;
}

.chat-send-btn {
  padding: 0.55rem 1.1rem;
  background: var(--color-terracotta);
  color: var(--color-cream);
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
}

.chat-send-btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 480px) {
  .chat-panel {
    inset-inline-end: 0.5rem;
    inset-inline-start: 0.5rem;
    inset-block-end: 0.5rem;
    width: auto;
    /* Deliberately capped below full height so part of the page stays
       visible/reachable behind the chat, and the backdrop is always
       tappable to close it. */
    height: min(75vh, 520px);
    height: min(75dvh, 520px);
  }
}
