/* ============================================================
   Floating help button (bottom-right): WhatsApp + FAQ assistant
   Loaded from app/views/partials/footer.php — public pages only.
   ============================================================ */

.hw {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 25; /* below the category sidenav (29/30) so that still covers it */
  font-family: var(--font-body, 'Archivo', sans-serif);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.7rem;
}

/* ---- Round buttons ---- */
.hw__fab,
.hw__mini {
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.hw__fab:hover,
.hw__mini:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28); }

.hw__fab {
  width: 58px;
  height: 58px;
  background: var(--color-footer-header, #151d3c);
  color: var(--color-white, #fffdf9);
}
.hw__fab svg { transition: transform 0.25s ease; }
.hw__fab .hw__icon-close { display: none; }
.hw.is-open .hw__fab .hw__icon-open { display: none; }
.hw.is-open .hw__fab .hw__icon-close { display: block; }

.hw__minis {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  margin-right: 5px;
}
.hw__mini-row { display: flex; align-items: center; gap: 0.55rem; }
.hw__label {
  background: var(--color-white, #fffdf9);
  color: var(--color-ink, #000);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}
.hw__mini { width: 48px; height: 48px; }
.hw__mini--wa { background: #25d366; color: #fff; }
.hw__mini--ai {
  background: var(--color-oxblood, #6b2737);
  color: var(--color-white, #fffdf9);
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

/* Hidden state with a small pop animation */
.hw__mini-row {
  opacity: 0;
  transform: translateY(12px) scale(0.85);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.hw.is-open .hw__mini-row { opacity: 1; transform: none; pointer-events: auto; }
.hw.is-open .hw__mini-row:nth-child(1) { transition-delay: 0.05s; }
.hw__minis[hidden] { display: none; }

/* ---- Chat panel ---- */
.hw-chat {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + 58px + 0.8rem);
  width: min(370px, calc(100vw - 2rem));
  height: min(540px, calc(100vh - 8rem));
  background: var(--color-white, #fffdf9);
  color: var(--color-ink, #000);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 26;
  font-family: var(--font-body, 'Archivo', sans-serif);
}
.hw-chat[hidden] { display: none; }

.hw-chat__head {
  background: var(--color-footer-header, #151d3c);
  color: var(--color-white, #fffdf9);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.hw-chat__avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-oxblood, #6b2737);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, monospace); font-weight: 600; font-size: 0.8rem;
  flex: none;
}
.hw-chat__title { margin: 0; font-weight: 600; font-size: 0.98rem; line-height: 1.2; }
.hw-chat__sub { margin: 0; font-size: 0.72rem; opacity: 0.75; }
.hw-chat__close {
  margin-left: auto;
  background: transparent; border: 0; color: inherit;
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0.2rem 0.4rem;
}

.hw-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #faf6ef;
  scrollbar-width: thin;
}

.hw-msg {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-line;
}
.hw-msg p { margin: 0 0 0.4em; }
.hw-msg p:last-child { margin: 0; }
.hw-msg a { color: var(--color-oxblood, #6b2737); font-weight: 600; }
.hw-msg--bot { background: #fff; border: 1px solid #ece3d3; align-self: flex-start; border-bottom-left-radius: 4px; }
.hw-msg--user {
  background: var(--color-footer-header, #151d3c);
  color: var(--color-white, #fffdf9);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.hw-msg--typing { color: #888; font-style: italic; }

/* Product cards inside a bot reply */
.hw-products { display: flex; flex-direction: column; gap: 0.5rem; align-self: stretch; }
.hw-product {
  display: flex; gap: 0.65rem; align-items: center;
  background: #fff; border: 1px solid #ece3d3; border-radius: 10px;
  padding: 0.5rem; text-decoration: none; color: inherit;
  transition: border-color 0.15s ease;
}
.hw-product:hover { border-color: var(--color-brass-dark, #a9832f); }
.hw-product__img {
  width: 54px; height: 54px; border-radius: 6px; object-fit: cover; flex: none;
  background: var(--color-parchment-dim, #e2d9c8);
}
.hw-product__name { margin: 0; font-weight: 600; font-size: 0.88rem; line-height: 1.25; }
.hw-product__meta { margin: 0.15rem 0 0; font-size: 0.78rem; color: #6b6257; }
.hw-product__price { color: var(--color-oxblood, #6b2737); font-weight: 600; }

/* Quick-reply chips */
.hw-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; align-self: flex-start; }
.hw-chip {
  border: 1px solid var(--color-footer-header, #151d3c);
  background: transparent;
  color: var(--color-footer-header, #151d3c);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}
.hw-chip:hover { background: var(--color-footer-header, #151d3c); color: var(--color-white, #fffdf9); }
.hw-chip--wa { border-color: #1da851; color: #1da851; }
.hw-chip--wa:hover { background: #25d366; color: #fff; border-color: #25d366; }

.hw-chat__form {
  display: flex; gap: 0.5rem; padding: 0.7rem;
  border-top: 1px solid #ece3d3; background: #fff;
}
.hw-chat__input {
  flex: 1; border: 1px solid #d9cfbf; border-radius: 999px;
  padding: 0.6rem 0.9rem; font-size: 16px; /* 16px stops iOS zooming in */
  font-family: inherit; color: var(--color-ink, #000); background: #fff;
  min-width: 0;
}
.hw-chat__input:focus { outline: none; border-color: var(--color-footer-header, #151d3c); }
.hw-chat__send {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: var(--color-oxblood, #6b2737); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.hw-chat__note {
  margin: 0; padding: 0 0.9rem 0.55rem; background: #fff;
  font-size: 0.68rem; color: #8a8175; text-align: center;
}

@media (max-width: 480px) {
  .hw { right: 0.9rem; bottom: 0.9rem; }
  .hw-chat {
    right: 0.5rem; left: 0.5rem; width: auto;
    bottom: calc(0.9rem + 58px + 0.6rem);
    height: min(520px, calc(100vh - 7rem));
  }
}

@media print { .hw, .hw-chat { display: none !important; } }

/* "Load previous chat" button in the header + divider after restored messages */
.hw-chat__restore {
  margin-left: auto;
  background: transparent; border: 1px solid rgba(255, 253, 249, 0.35); color: inherit;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.hw-chat__restore:hover { background: rgba(255, 253, 249, 0.12); }
.hw-chat__restore[hidden] { display: none; }
.hw-chat__restore:not([hidden]) + .hw-chat__close { margin-left: 0.2rem; }
.hw-divider {
  align-self: stretch; text-align: center; font-size: 0.7rem; color: #8a8175;
  text-transform: uppercase; letter-spacing: 0.08em; margin: 0.3rem 0;
  display: flex; align-items: center; gap: 0.6rem;
}
.hw-divider::before, .hw-divider::after { content: ''; flex: 1; border-top: 1px solid #e2d9c8; }
