/* ==========================================================================
   Live chat dock — right rail on every page (desktop + mobile)
   Uses the Giga design tokens, so it follows the dark/light theme.
   ========================================================================== */

.bckchat {
  --chat-w: 348px;
  position: fixed;
  top: var(--h-main, 64px);
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 120;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  font-family: inherit;
  contain: layout style;
}

/* ---------------------------------------------------------------- panel */

.bckchat__panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: var(--chat-w);
  max-width: 100vw;
  height: 100%;
  background: var(--velvet);
  border-left: 1px solid var(--line);
  box-shadow: -28px 0 70px -30px rgba(var(--shade-rgb), calc(0.75 * var(--shade-k)));
  transform: translateX(calc(100% + 10px));
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

.bckchat[data-state="open"] .bckchat__panel {
  transform: none;
}

.bckchat__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 54px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-top), var(--velvet));
}

.bckchat__title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bckchat__title-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.bckchat__title-txt b {
  font-size: 14px;
  font-weight: 700;
  color: var(--tx-hi);
  letter-spacing: 0.01em;
}

.bckchat__title-txt small {
  font-size: 11px;
  color: var(--tx-3);
  font-weight: 500;
}

.bckchat__live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 214, 166, 0.6);
  animation: bckchat-pulse 2.2s ease-out infinite;
  flex: 0 0 auto;
}

@keyframes bckchat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 214, 166, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(52, 214, 166, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 214, 166, 0); }
}

.bckchat__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--tx-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.bckchat__icon:hover {
  background: var(--velvet-2);
  color: var(--tx-hi);
}

/* ---------------------------------------------------------------- body */

.bckchat__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.bckchat__body::-webkit-scrollbar { width: 8px; }
.bckchat__body::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 99px;
}
.bckchat__body::-webkit-scrollbar-track { background: transparent; }

.bckchat__list {
  list-style: none;
  margin: 0;
  padding: 0 0 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: filter 0.25s, opacity 0.25s;
}

.bckchat__list.is-locked {
  filter: blur(3.5px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.bckchat__empty {
  margin: 22px 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--tx-3);
}

/* ------------------------------------------------------------- message */

.bckchat__msg {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  padding: 3px 2px;
  border-radius: 8px;
}

.bckchat__msg:hover {
  background: var(--velvet-2);
}

.bckchat__av {
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 800;
  color: #fff;
  background: hsl(var(--av-h, 320deg) 62% 46%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  user-select: none;
}

.bckchat__bubble {
  min-width: 0;
}

.bckchat__meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.bckchat__name {
  font-size: 12px;
  font-weight: 700;
  color: var(--tx-2);
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bckchat__msg.is-cont .bckchat__av {
  visibility: hidden;
}

.bckchat__msg.is-cont .bckchat__name {
  display: none;
}

.bckchat__staff {
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--grad-gold);
  color: #2a1a00;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}

.bckchat__time {
  font-size: 10.5px;
  color: var(--tx-3);
  flex: 0 0 auto;
}

.bckchat__del {
  margin-left: auto;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: var(--tx-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.bckchat__msg:hover .bckchat__del,
.bckchat__del:focus-visible {
  opacity: 1;
}

.bckchat__del:hover { color: var(--bad); }

.bckchat__text {
  margin: 1px 0 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--tx);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bckchat__msg.is-cont .bckchat__text {
  margin-top: 0;
}

.bckchat__text a {
  color: var(--mag-l);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bckchat__text a:hover { color: var(--link-hover); }

/* -------------------------------------------------------- staff menu */

.bckchat__menu {
  position: absolute;
  z-index: 5;
  top: 22px;
  left: 34px;
  min-width: 148px;
  padding: 5px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--velvet-3);
  box-shadow: var(--sh-2);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bckchat__menu button {
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--tx-2);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.bckchat__menu button:hover {
  background: var(--velvet-2);
  color: var(--tx-hi);
}

/* ---------------------------------------------------------------- gate */

.bckchat__gate {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 22px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(var(--velvet-rgb), 0.72), rgba(var(--velvet-rgb), 0.94) 55%);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.bckchat__gate[hidden] { display: none; }

.bckchat__gate-ico {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--mag-l);
  background: rgba(var(--mag-rgb), 0.12);
  box-shadow: inset 0 0 0 1px rgba(var(--mag-rgb), 0.28);
  margin-bottom: 2px;
}

.bckchat__gate b {
  font-size: 15px;
  color: var(--tx-hi);
}

.bckchat__gate p {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--tx-2);
  max-width: 250px;
}

.bckchat__gate .btn {
  width: 100%;
  max-width: 250px;
  font-size: 12.5px;
  padding: 9px 12px;
}

/* ---------------------------------------------------------------- form */

.bckchat__form {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--velvet);
}

.bckchat__form[hidden] { display: none; }

.bckchat__input {
  flex: 1 1 auto;
  min-height: 38px;
  max-height: 96px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--field);
  color: var(--tx);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bckchat__input::placeholder { color: var(--tx-3); }

.bckchat__input:focus {
  border-color: rgba(var(--mag-rgb), 0.65);
  box-shadow: 0 0 0 3px rgba(var(--mag-rgb), 0.14);
}

.bckchat__send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--grad-cta);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--glow-mag);
  transition: transform 0.12s, filter 0.15s;
}

.bckchat__send:hover { filter: brightness(1.08); }
.bckchat__send:active { transform: scale(0.94); }
.bckchat__send:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

.bckchat__note {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 8px;
  font-size: 11.5px;
  color: var(--bad-tx);
  background: var(--velvet);
}

.bckchat__note[hidden] { display: none; }

/* ----------------------------------------------------------------- fab */

.bckchat__fab {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--grad-cta);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(var(--mag-rgb), 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  pointer-events: auto;
  transition: transform 0.18s, opacity 0.18s, box-shadow 0.18s;
}

.bckchat__fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px -10px rgba(var(--mag-rgb), 0.85), 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.bckchat[data-state="open"] .bckchat__fab {
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
}

.bckchat__fab-label { line-height: 1; }

.bckchat__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--ink);
}

.bckchat__badge[hidden] { display: none; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 1023px) {
  .bckchat {
    --chat-w: 100%;
    top: var(--h-main, 56px);
  }

  /* Keep the bottom tab bar usable while the chat is open. */
  body:has(.tabbar) .bckchat { bottom: 60px; }

  .bckchat__panel {
    border-left: 0;
    box-shadow: none;
  }

  .bckchat__fab {
    right: 14px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
  }

  .bckchat__fab-label { display: none; }

  body.bckchat-lock { overflow: hidden; }

  .bckchat__text { font-size: 14px; }
  .bckchat__name { font-size: 12.5px; }
}

@media (min-width: 1024px) and (max-height: 620px) {
  .bckchat__head { height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .bckchat__panel,
  .bckchat__fab { transition: none; }
  .bckchat__live { animation: none; }
}
