.live-chat [hidden] {
  display: none !important;
}

body.cart-open .live-chat {
  display: none !important;
}

.live-chat__panel:not([hidden]) {
  display: flex;
  flex-direction: column;
}

/* Sit the open panel closer to the bottom edge (launcher is hidden while open). */
.live-chat__panel {
  bottom: 16px;
}

/* When the chat panel is open, hide the floating launcher entirely. */
html.live-chat-open .live-chat__launcher,
.live-chat:has(.live-chat__panel:not([hidden])) .live-chat__launcher {
  display: none !important;
}

.live-chat__panel > header {
  flex: 0 0 auto;
  min-height: 62px;
  background: #17233b !important;
}

.live-chat__panel > header small {
  max-width: 300px;
  font-size: 12px;
  line-height: 1.35;
}

.live-chat__messages {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.live-chat__guest {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.live-chat__guest > button[type="submit"] {
  align-self: flex-end;
  margin-top: auto;
}

.live-chat__composer {
  flex: 0 0 auto;
}

.live-chat__new {
  margin: 14px auto;
}

.live-chat__launcher-icon {
  position: relative;
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 11px;
  color: #17233b;
  background: linear-gradient(145deg, #fff, #dbeafe);
  box-shadow: 0 5px 14px rgba(15, 23, 42, .2);
  animation: live-chat-icon-float 2.8s ease-in-out infinite;
}

.live-chat__launcher-icon svg {
  width: 21px;
  height: 21px;
  overflow: visible;
  fill: currentColor;
}

.live-chat__launcher-icon svg circle {
  fill: #2b8cff;
  animation: live-chat-dot-wave 1.4s ease-in-out infinite;
}

.live-chat__launcher-icon svg circle:nth-of-type(2) { animation-delay: .14s; }
.live-chat__launcher-icon svg circle:nth-of-type(3) { animation-delay: .28s; }

.live-chat__launcher-icon i {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, .5);
  animation: live-chat-status-pulse 1.8s ease-out infinite;
}

.live-chat.is-online .live-chat__launcher-icon {
  color: #08705a;
  background: linear-gradient(145deg, #fff, #d1fae5);
}

.live-chat.is-online .live-chat__launcher-icon i {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .5);
}

@keyframes live-chat-icon-float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-2px) rotate(-2deg); }
}

@keyframes live-chat-dot-wave {
  0%, 60%, 100% { opacity: .45; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-1.5px); }
}

@keyframes live-chat-status-pulse {
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .live-chat__launcher-icon,
  .live-chat__launcher-icon svg circle,
  .live-chat__launcher-icon i { animation: none; }
}

.live-chat__field-error {
  display: block;
  min-height: 16px;
  margin-top: 4px;
  color: #dc2626;
  font-size: 11px;
  font-weight: 700;
}

.live-chat__guest input[aria-invalid="true"] {
  border-color: #ef4444;
  background: #fffafa;
}

.live-chat__guest input[aria-invalid="true"]:focus {
  outline-color: #f87171;
}

.live-chat--staff .live-chat__launcher {
  background: linear-gradient(135deg, #17233b, #2b8cff);
}

.live-chat__message {
  position: relative;
}

.live-chat__message-reply {
  margin: 3px 0 7px;
  padding: 6px 8px;
  border-left: 3px solid #2b8cff;
  border-radius: 6px;
  color: #334155;
  background: rgba(239, 246, 255, .92);
}

.live-chat__message-reply strong,
.live-chat__message-reply small {
  display: block;
}

.live-chat__message-reply strong { font-size: 10px; }

.live-chat__message-reply small {
  max-width: 250px;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-chat__message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 5px;
}

.live-chat__message-actions button {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  color: #526277;
  background: transparent;
  font-size: 10px;
  cursor: pointer;
}

.live-chat__message-actions button:hover,
.live-chat__message-actions button:focus-visible {
  color: #0b6bd3;
  background: #e8f2ff;
}

.live-chat__composer {
  flex-wrap: wrap;
}

.live-chat__reply-preview {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border-left: 3px solid #2b8cff;
  border-radius: 8px;
  color: #334155;
  background: #eff6ff;
}

.live-chat__reply-preview span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.live-chat__reply-preview strong { font-size: 11px; }

.live-chat__reply-preview small {
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-chat__reply-preview button {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  padding: 0 !important;
  border-radius: 50% !important;
  color: #64748b !important;
  background: #fff !important;
  font-size: 18px;
}

.live-chat__message-sender {
  display: block;
  margin-bottom: 5px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

.live-chat__message.is-own .live-chat__message-sender {
  color: #08705a;
  text-align: right;
}

.live-chat__message.is-operator {
  margin-right: auto;
  border: 1px solid #dbe4ee;
  background: #fff;
}

/* Compact floating launcher so it does not cover catalog quick-actions. */
@media (max-width: 768px) {
  .live-chat {
    right: 12px;
    bottom: max(82px, calc(env(safe-area-inset-bottom) + 70px));
  }

  .live-chat__launcher {
    gap: 0;
    justify-content: center;
    min-width: 52px;
    min-height: 52px;
    padding: 11px;
  }

  .live-chat__status,
  .live-chat--staff .live-chat__launcher > span:not([aria-hidden="true"]) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .live-chat--staff .live-chat__launcher {
    font-size: 1.25rem;
    line-height: 1;
  }
}

@media (max-width: 520px) {
  html.live-chat-open,
  html.live-chat-open body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .live-chat {
    right: 12px;
    bottom: max(82px, calc(env(safe-area-inset-bottom) + 70px));
  }

  .live-chat__panel {
    inset: auto;
    top: var(--live-chat-viewport-offset-top, 0px);
    right: auto;
    bottom: auto;
    left: var(--live-chat-viewport-offset-left, 0px);
    width: var(--live-chat-viewport-width, 100vw);
    max-width: none;
    height: var(--live-chat-viewport-height, 100dvh);
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .live-chat__panel > header {
    padding-top: max(15px, env(safe-area-inset-top));
  }

  .live-chat__messages {
    width: 100%;
    min-width: 0;
    height: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .live-chat__composer {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .live-chat__composer .live-chat__reply-preview {
    grid-column: 1 / -1;
  }

  .live-chat__composer textarea {
    width: 100%;
    min-width: 0;
  }

  .live-chat__composer > button[type="submit"] {
    min-width: 72px;
    white-space: nowrap;
  }
}
