/* ============================================================
   MAKHANZA — customer assistant
   Uses the brand tokens only; no raw hex beyond the shadows.
   ============================================================ */

.mkz-chat__launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-forest);
  color: var(--gold-100);
  box-shadow: 0 10px 30px rgba(26, 74, 46, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-lift) var(--ease-out), background var(--dur) var(--ease);
}
.mkz-chat__launcher:hover { transform: translateY(-3px); background: var(--color-forest-deep); }
.mkz-chat__launcher:focus-visible { outline: 3px solid var(--color-gold); outline-offset: 3px; }

.mkz-chat__launcher svg { width: 27px; height: 27px; fill: currentColor; }
.mkz-chat__launcher-close { display: none; }
.mkz-chat__launcher.is-open .mkz-chat__launcher-icon { display: none; }
.mkz-chat__launcher.is-open .mkz-chat__launcher-close { display: block; }

/*
 * CRITICAL: `.mkz-chat { display: flex }` outranks the browser's own
 * `[hidden] { display: none }`, so the panel rendered open on every page
 * load and the close button did nothing — it set the attribute the CSS was
 * already ignoring. The hidden state has to be stated explicitly.
 */
.mkz-chat[hidden] { display: none !important; }

.mkz-chat {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);
  /* An explicit height, not just a cap — with only max-height the panel
     collapses around its (initially empty) log and the conversation gets
     a 100px window to live in. */
  height: min(600px, calc(100vh - 140px));
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: var(--surface-page);
  border: var(--border-width) solid var(--border-gold-soft);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 60px rgba(26, 74, 46, 0.28);
  overflow: hidden;
}

.mkz-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-xl);
  background: var(--color-forest);
  color: var(--gold-100);
}
.mkz-chat__brand { display: flex; align-items: center; gap: var(--space-md); }
.mkz-chat__brand strong { display: block; font-family: var(--font-body); font-size: 15px; font-weight: var(--fw-semibold); }
.mkz-chat__brand small { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.7); }

.mkz-chat__avatar {
  width: 38px; height: 38px;
  border-radius: var(--radius-pill);
  background: var(--color-gold);
  color: var(--forest-900);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 19px;
  display: inline-flex; align-items: center; justify-content: center;
}

.mkz-chat__min {
  background: none; border: none; padding: 0;
  width: 32px; height: 32px;
  color: var(--gold-100);
  font-size: 26px; line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-pill);
}
.mkz-chat__min:hover { background: rgba(255, 255, 255, 0.12); color: var(--gold-100); }

.mkz-chat__log {
  flex: 1 1 auto;
  min-height: 190px;
  overflow-y: auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  scroll-behavior: smooth;
}

.mkz-chat__msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.55;
}
.mkz-chat__msg p { max-width: none; margin: 0; }
.mkz-chat__msg--bot {
  align-self: flex-start;
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  color: var(--text-body);
  border-bottom-left-radius: var(--radius-sm, 6px);
}
.mkz-chat__msg--me {
  align-self: flex-end;
  background: var(--color-forest);
  color: rgba(255, 255, 255, 0.95);
  border-bottom-right-radius: var(--radius-sm, 6px);
}
.mkz-chat__msg--bot a { color: var(--color-gold-dark); text-decoration: underline; text-underline-offset: 2px; }
.mkz-chat__msg--bot a:hover { color: var(--color-forest); }

.mkz-chat__typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.mkz-chat__typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-gold);
  animation: mkzBlink 1.1s infinite ease-in-out;
}
.mkz-chat__typing i:nth-child(2) { animation-delay: 0.18s; }
.mkz-chat__typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes mkzBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.mkz-chat__cards {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  scroll-snap-type: x mandatory;
}
.mkz-chat__card {
  flex: 0 0 132px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-sm);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: transform var(--dur-lift) var(--ease-out), box-shadow var(--dur-lift) var(--ease-out);
}
.mkz-chat__card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.mkz-chat__card.is-out { opacity: 0.55; }
.mkz-chat__card-img {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
  background: var(--surface-muted);
}
.mkz-chat__card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mkz-chat__card-name {
  font-size: 12.5px;
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
  line-height: 1.3;
}
.mkz-chat__card-price { font-size: 12.5px; color: var(--color-forest); font-weight: var(--fw-bold); }
.mkz-chat__card-out { font-size: 11px; color: var(--brown-warm); text-transform: uppercase; letter-spacing: var(--ls-nav); }

/* One scrollable row, not a wrapping block — eight wrapped chips ate
   175px of a 512px panel and squeezed the conversation into a slot. */
.mkz-chat__chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: var(--space-sm);
  padding: 0 var(--space-xl) var(--space-md);
}
.mkz-chat__chips::-webkit-scrollbar { display: none; }
.mkz-chat__chip { flex: 0 0 auto; white-space: nowrap; }
.mkz-chat__chips:empty { display: none; }
.mkz-chat__chip {
  border: var(--border-width) solid var(--color-forest);
  background: transparent;
  color: var(--color-forest);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.mkz-chat__chip:hover { background: var(--color-forest); color: var(--gold-100); }
.mkz-chat__chip:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }

.mkz-chat__form {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  border-top: var(--border-width) solid var(--border-hairline);
  background: var(--surface-card);
}
.mkz-chat__form input {
  flex: 1;
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-pill);
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--surface-page);
  color: var(--text-body);
}
.mkz-chat__form input:focus { outline: none; border-color: var(--color-forest); }
.mkz-chat__form button {
  flex: 0 0 42px;
  width: 42px; height: 42px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-forest);
  color: var(--gold-100);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mkz-chat__form button:hover { background: var(--color-gold); color: var(--forest-900); }
.mkz-chat__form button svg { width: 19px; height: 19px; fill: currentColor; }

.mkz-chat__foot {
  margin: 0;
  padding: 0 var(--space-xl) var(--space-md);
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  background: var(--surface-card);
  max-width: none;
}

/* The WhatsApp float and the launcher must not stack on top of each other. */
.mkz-whatsapp-float { bottom: 96px !important; }

@media (max-width: 480px) {
  .mkz-chat {
    right: 8px;
    left: 8px;
    bottom: 84px;
    width: auto;
    height: calc(100vh - 120px);
    max-height: calc(100vh - 120px);
  }
  .mkz-chat__launcher { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .mkz-chat__log { padding: var(--space-lg); }
  .mkz-chat__chips { padding: 0 var(--space-lg) var(--space-sm); }
  .mkz-chat__form { padding: var(--space-sm) var(--space-lg); }
  .mkz-chat__foot { padding: 0 var(--space-lg) var(--space-sm); }
}

@media (prefers-reduced-motion: reduce) {
  .mkz-chat__typing i { animation: none; opacity: 0.6; }
  .mkz-chat__log { scroll-behavior: auto; }
}


/* ---------- Product FAQ (answer-first block) ---------- */
.mkz-faq {
  margin: var(--space-3xl) 0 var(--space-2xl);
  padding-top: var(--space-2xl);
  border-top: var(--border-width) solid var(--border-hairline);
}
.mkz-faq__title { font-size: var(--fs-section); margin: 0 0 var(--space-xl); }
.mkz-faq__list { display: flex; flex-direction: column; gap: var(--space-md); }
.mkz-faq__item {
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-xl);
}
.mkz-faq__q {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-card);
  color: var(--text-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.mkz-faq__q::-webkit-details-marker { display: none; }
.mkz-faq__q::after {
  content: "+";
  font-size: 22px;
  line-height: 1;
  color: var(--color-gold-dark);
  flex: 0 0 auto;
  transition: transform var(--dur) var(--ease);
}
.mkz-faq__item[open] .mkz-faq__q::after { content: "\2212"; }
.mkz-faq__a { padding-top: var(--space-md); }
.mkz-faq__a p { margin: 0; color: var(--text-body); font-size: var(--fs-card); line-height: var(--lh-body); max-width: 72ch; }
.mkz-faq__a a { color: var(--color-gold-dark); }

/* Storefront shows a sticky handheld footer bar (account / search / cart)
   below 768px. The launcher has to clear it or the two overlap. */
@media (max-width: 768px) {
  .mkz-chat__launcher { bottom: 76px; }
  .mkz-chat { bottom: 142px; height: calc(100vh - 200px); max-height: calc(100vh - 200px); }
  .mkz-whatsapp-float { bottom: 142px !important; }
}
