/* Hayakel Baalbek — appointment-booking chatbot (Phase 4 Task 4)
 *
 * Floating button + slide-in panel + slot-fill conversation. Reuses
 * the design tokens from style.css (--burgundy, --paper, --sand,
 * --rule, --ink, --ink-deep). Mirrors the cookie-banner's slide-in
 * pattern (transform: translateY(100%) → 0 on .is-open).
 *
 * Z-index 999 — the cookie banner (.hb-consent) is 1000, so when both
 * are visible the banner wins. JS also hides the FAB while the banner
 * is open to avoid stacking entirely.
 */

/* ===================== Floating action button ============================ */
.hb-chat-fab {
  position: fixed;
  inset-inline-end: 24px;
  bottom: 24px;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--burgundy);
  color: var(--paper);
  border: 1px solid var(--burgundy);
  box-shadow: 0 8px 24px rgba(31, 22, 14, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
  padding: 0;
}
.hb-chat-fab:hover,
.hb-chat-fab:focus-visible {
  background: #25D366; /* WhatsApp green */
  border-color: #25D366;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(31, 22, 14, 0.22);
}
.hb-chat-fab:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
.hb-chat-fab__icon {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

@media (max-width: 600px) {
  .hb-chat-fab { inset-inline-end: 16px; bottom: 16px; }
}

/* ===================== Panel container =================================== */
.hb-chat-panel {
  position: fixed;
  inset-inline-end: 24px;
  bottom: 24px;
  z-index: 999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(600px, 80vh);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(31, 22, 14, 0.22);
  display: flex;
  flex-direction: column;
  font-family: "Inter", sans-serif;
  color: var(--ink);
  transform: translateY(100%);
  opacity: 0;
  transition: transform .25s ease-out, opacity .25s ease-out;
  overflow: hidden;
}
.hb-chat-panel.is-open {
  transform: translateY(0);
  opacity: 1;
}

/* ===================== Header ============================================ */
.hb-chat-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ink-deep);
  color: var(--paper);
  border-bottom: 1px solid var(--rule);
  flex: 0 0 auto;
}
.hb-chat-panel__logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.hb-chat-panel__titles {
  flex: 1 1 auto;
  min-width: 0;
}
.hb-chat-panel__title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 15px;
  letter-spacing: .04em;
  margin: 0;
  color: var(--paper);
  line-height: 1.2;
}
.hb-chat-panel__subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: rgba(251, 247, 238, 0.7);
}
.hb-chat-panel__close {
  background: rgba(251, 247, 238, 0.12);
  border: 1px solid rgba(251, 247, 238, 0.4);
  color: var(--paper);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.hb-chat-panel__close:hover,
.hb-chat-panel__close:focus-visible {
  background: rgba(251, 247, 238, 0.22);
  border-color: var(--paper);
  transform: scale(1.06);
  outline: none;
}
.hb-chat-panel__close:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}
.hb-chat-panel__close-x {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  color: var(--paper);
  display: block;
  margin-top: -2px; /* optical center for the × glyph */
}

/* ===================== Body / messages =================================== */
.hb-chat-panel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hb-chat-msg {
  display: flex;
  max-width: 100%;
}
.hb-chat-msg--bot { justify-content: flex-start; }
.hb-chat-msg--user { justify-content: flex-end; }

.hb-chat-msg__inner {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
}
.hb-chat-msg--bot .hb-chat-msg__inner {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-start-start-radius: 4px;
}
.hb-chat-msg--user .hb-chat-msg__inner {
  background: var(--sand);
  border: 1px solid var(--rule);
  border-start-end-radius: 4px;
}
.hb-chat-msg__text {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===================== Inline error / hints ============================== */
.hb-chat-error {
  margin: 4px 0 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--burgundy);
  background: rgba(138, 58, 31, 0.08);
  border: 1px solid rgba(138, 58, 31, 0.25);
  border-radius: 6px;
}
.hb-chat-input__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ===================== Input area ======================================== */
.hb-chat-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.hb-chat-input__row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.hb-chat-input__field {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
.hb-chat-input__field:focus-visible {
  outline: 2px solid var(--burgundy);
  outline-offset: 1px;
  border-color: var(--burgundy);
}
.hb-chat-input__field--textarea {
  resize: vertical;
  min-height: 60px;
}
.hb-chat-input__send {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--burgundy);
  color: var(--paper);
  border: 1px solid var(--burgundy);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}
.hb-chat-input__send:hover,
.hb-chat-input__send:focus-visible {
  background: transparent;
  color: var(--burgundy);
}
.hb-chat-input__skip {
  align-self: flex-start;
  background: transparent;
  border: 0;
  padding: 4px 0;
  font-size: 12px;
  color: var(--ink-muted);
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}
.hb-chat-input__skip:hover { color: var(--burgundy); }
.hb-chat-input__close {
  margin-top: 8px;
  align-self: flex-start;
}

/* ===================== Consent block ===================================== */
.hb-chat-consent {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--sand);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.hb-chat-consent__body {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
}
.hb-chat-consent__body a { color: var(--burgundy); }
.hb-chat-consent__row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.hb-chat-consent__row input { width: 16px; height: 16px; accent-color: var(--burgundy); }
.hb-chat-consent__btn {
  align-self: flex-start;
  font-size: 12px;
  padding: 8px 12px;
}
.hb-chat-consent__btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* ===================== Slot grid ========================================= */
.hb-chat-slot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.hb-chat-slot-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  min-height: 56px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.hb-chat-slot-card:hover:not(:disabled),
.hb-chat-slot-card:focus-visible {
  border-color: var(--burgundy);
  box-shadow: 0 0 0 1px var(--burgundy);
  outline: none;
}
.hb-chat-slot-card.is-selected {
  background: var(--burgundy);
  color: var(--paper);
  border-color: var(--burgundy);
}
.hb-chat-slot-card:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.hb-chat-slot-card__label {
  display: block;
  line-height: 1.35;
}

/* ===================== Review (summary) card ============================= */
.hb-chat-review {
  margin: 8px 0 4px;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 13px;
}
.hb-chat-review dt {
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 11px;
  align-self: center;
}
.hb-chat-review dd {
  margin: 0;
  color: var(--ink);
  word-wrap: break-word;
  min-width: 0;
}
.hb-chat-review__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.hb-chat-review__actions .button {
  font-size: 13px;
  padding: 8px 14px;
}

/* ===================== Mobile takeover =================================== */
@media (max-width: 600px) {
  .hb-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    border-radius: 0;
    border: 0;
  }
  .hb-chat-slot-grid { grid-template-columns: 1fr 1fr; }
}

/* Lock body scroll while the panel is open on mobile. */
html.hb-chat-html-locked,
html.hb-chat-html-locked body {
  overflow: hidden;
}

/* RTL: inset-inline-end already does the right thing for the FAB +
   panel position. Force the chat-msg radii to flip too. The
   start/end logical radii above already handle this. */

/* Reduced motion: skip the slide-in transition. */
@media (prefers-reduced-motion: reduce) {
  .hb-chat-panel { transition: none; }
  .hb-chat-fab { transition: none; }
}
