/* ==========================================================================
   Unboxkey — chat.css: the support chat widget (assets/js/chat.js).
   Tokens come from site.css (:root). Everything is position: fixed, so the
   widget never shifts the page layout. Class prefix: .ukc-
   Layers: header 50, buy bar 45, launcher 90, panel 95, drawer 100.
   ========================================================================== */

/* ---------- Launcher ---------- */
.ukc-launcher {
  --ukc-lift: 0px;
  position: fixed; z-index: 90;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 56px; height: 56px; padding: 0;
  border: 0; border-radius: var(--r-pill);
  background: var(--ink); color: #fff;
  font: 700 15.5px/1 var(--f-head); font-stretch: 105%; letter-spacing: .005em;
  box-shadow: 0 10px 28px rgba(20, 20, 20, .28), 0 2px 6px rgba(20, 20, 20, .18);
  cursor: pointer;
  transform: translateY(calc(var(--ukc-lift) * -1));
  transition: transform .25s var(--ease), opacity .2s var(--ease), visibility .2s, background-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.ukc-launcher:hover { background: #000; }
.ukc-launcher:focus-visible { box-shadow: 0 0 0 3px var(--white), 0 0 0 6px var(--ink); border-radius: var(--r-pill); }
.ukc-launcher svg { width: 26px; height: 26px; flex: none; }
.ukc-launcher .ukc-ico-close { display: none; }
.ukc-launcher[aria-expanded="true"] .ukc-ico-chat { display: none; }
.ukc-launcher[aria-expanded="true"] .ukc-ico-close { display: block; }
.ukc-launcher-label { display: none; }
.ukc-dot {
  position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--red); border: 2.5px solid var(--white);
}
/* Over a primary button or footer links: step aside until they scroll past. */
.ukc-launcher.is-tucked {
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(calc(var(--ukc-lift) * -1 + 12px)) scale(.9);
}
@media (min-width: 600px) {
  .ukc-launcher {
    right: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: auto; height: 52px; padding: 0 20px 0 16px;
  }
  .ukc-launcher svg { width: 22px; height: 22px; }
  .ukc-launcher-label { display: inline; }
  .ukc-dot { top: -3px; right: -3px; }
}

/* ---------- Panel ---------- */
.ukc-panel {
  position: fixed; z-index: 95; inset: 0;
  display: flex; flex-direction: column;
  width: 100%; height: 100%; height: 100dvh;
  background: var(--white); color: var(--ink);
  font: 400 15px/1.5 var(--f-body);
  overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(16px);
  transition: opacity .2s var(--ease), transform .25s var(--ease), visibility 0s linear .25s;
}
.ukc-panel.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.ukc-panel[hidden] { display: none !important; }
@media (max-width: 599px) {
  /* Full-height sheet: the launcher steps away, the page behind does not scroll. */
  .ukc-open .ukc-launcher { opacity: 0; visibility: hidden; pointer-events: none; }
  html.ukc-lock, html.ukc-lock body { overflow: hidden; }
}
@media (min-width: 600px) {
  .ukc-panel {
    --ukc-lift: 0px;
    inset: auto;
    right: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + 52px + 12px + env(safe-area-inset-bottom, 0px) + var(--ukc-lift));
    width: 384px;
    height: min(620px, calc(100vh - 136px - var(--ukc-lift)));
    height: min(620px, calc(100dvh - 136px - var(--ukc-lift)));
    border: 1px solid var(--rule); border-radius: 16px;
    box-shadow: var(--shadow-lg);
    transform-origin: 100% 100%;
    transform: translateY(12px) scale(.98);
  }
  .ukc-panel.is-open { transform: none; }
}

/* Header */
.ukc-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 12px 8px 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: var(--ink); color: #fff;
}
.ukc-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: #262624; }
.ukc-mark svg { width: 24px; height: 24px; }
.ukc-titles { min-width: 0; flex: 1; display: grid; gap: 1px; }
.ukc-title { font: 800 17px/1.2 var(--f-head); font-stretch: 106%; letter-spacing: -.01em; color: #fff; margin: 0; }
.ukc-sub { font-size: 13px; line-height: 1.35; color: #cfcdc6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ukc-close {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: #fff; cursor: pointer;
}
.ukc-close:hover { background: rgba(255, 255, 255, .1); }
.ukc-close:focus-visible, .ukc-head :focus-visible { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--yellow); }
.ukc-close svg { width: 20px; height: 20px; }

/* Offline banner */
.ukc-offline {
  flex: none; display: grid; gap: 6px;
  padding: 12px 16px; border-bottom: 1px solid #f0d9a8;
  background: var(--warn-tint); color: var(--ink); font-size: 14px; line-height: 1.45;
}
.ukc-offline strong { font-weight: 700; }
.ukc-offline a { color: var(--red-dark); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ukc-offline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ukc-linkbtn {
  padding: 4px 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* Conversation */
.ukc-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; background: var(--shelf);
  scroll-behavior: smooth;
}
.ukc-m {
  max-width: 86%; padding: 9px 13px; border-radius: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
  font-size: 15px; line-height: 1.45;
}
.ukc-m a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ukc-user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.ukc-bot, .ukc-agent {
  align-self: flex-start; background: var(--white); color: var(--ink);
  border: 1px solid var(--rule); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm);
}
.ukc-bot a, .ukc-agent a { color: var(--red-dark); }
.ukc-agent { border-left: 3px solid var(--yellow); }
.ukc-who { display: block; margin-bottom: 2px; font: 700 12.5px/1.3 var(--f-head); letter-spacing: .01em; color: var(--grey); white-space: normal; }

.ukc-note {
  align-self: stretch; display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.45;
  background: var(--warn-tint); color: var(--ink); border: 1px solid #f0d9a8;
}
.ukc-note a { color: var(--red-dark); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ukc-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--warn); }
.ukc-note--human { background: var(--yellow-tint); border-color: #f3df94; }
.ukc-note--human svg { color: var(--ink); }

.ukc-chips { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 100%; }
.ukc-chip {
  min-height: 38px; padding: 7px 14px;
  border: 1.5px solid var(--rule-2); border-radius: var(--r-pill);
  background: var(--white); color: var(--ink);
  font: 600 14px/1.25 var(--f-body); text-align: left; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.ukc-chip:hover { border-color: var(--ink); }
.ukc-chip:disabled { opacity: .55; cursor: default; }

.ukc-typing {
  align-self: flex-start; display: flex; gap: 5px; padding: 13px 14px;
  background: var(--white); border: 1px solid var(--rule); border-radius: 14px; border-bottom-left-radius: 4px;
}
.ukc-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--grey); opacity: .35; animation: ukc-dots 1.2s infinite ease-in-out; }
.ukc-typing i:nth-child(2) { animation-delay: .15s; }
.ukc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ukc-dots { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: .9; } }
.ukc-m, .ukc-note, .ukc-typing, .ukc-chips { animation: ukc-in .22s var(--ease) both; }
@keyframes ukc-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Composer */
.ukc-form {
  flex: none; display: grid; gap: 6px;
  padding: 10px 12px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--rule); background: var(--white);
}
.ukc-row { display: flex; align-items: flex-end; gap: 8px; }
.ukc-input {
  flex: 1; min-width: 0; resize: none; box-sizing: border-box;
  height: 44px; min-height: 44px; max-height: 128px;
  padding: 11px 13px; border: 1.5px solid var(--rule-2); border-radius: var(--r-ctl);
  background: var(--white); color: var(--ink);
  font: 400 16px/1.35 var(--f-body);   /* 16px: no zoom-in on iOS */
}
.ukc-input::placeholder { color: var(--grey); opacity: 1; }
.ukc-input:focus, .ukc-input:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20, 20, 20, .1); border-radius: var(--r-ctl); }
.ukc-send {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: var(--r-ctl); background: var(--red); color: #fff; cursor: pointer;
  transition: background-color .15s, opacity .15s;
}
.ukc-send:hover { background: var(--red-dark); }
.ukc-send:disabled { background: var(--rule-2); color: var(--grey); cursor: default; }
.ukc-send svg { width: 20px; height: 20px; }
.ukc-fine { margin: 0; font-size: 12px; line-height: 1.4; color: var(--grey); }

@media (prefers-reduced-motion: reduce) {
  .ukc-launcher, .ukc-panel, .ukc-chip, .ukc-send { transition: none; }
  .ukc-m, .ukc-note, .ukc-typing, .ukc-chips, .ukc-typing i { animation: none; }
  .ukc-log { scroll-behavior: auto; }
}
@media print { .ukc-launcher, .ukc-panel { display: none !important; } }
