/* SHOPxSHOP customer chat widget */
#chat-widget-root {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 10050;
  font-family: 'Montserrat', sans-serif;
}

.chat-widget-toggle {
  position: fixed;
  bottom: 20px;
  right: 10px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: #FFCEE5;
  color: #131313;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10051;
}

#chat-widget-root.chat-widget-open .chat-widget-toggle {
  display: none !important;
}

/* Scroll-to-top sits above chat launcher */
body:has(#chat-widget-root) .page_up_btn {
  bottom: 84px;
  right: 10px;
  z-index: 1000;
}

body.chat-widget-panel-open .page_up_btn {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none;
}

.chat-widget-toggle:hover {
  transform: scale(1.05);
  background: #ffb8d9;
}

.chat-widget-panel {
  position: fixed;
  bottom: 84px;
  right: 10px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 10050;
}

.chat-widget-panel.open {
  display: flex;
}

.chat-widget-header {
  background: #FFCEE5;
  color: #131313;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-widget-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.chat-widget-header p {
  margin: 2px 0 0;
  font-size: 11px;
  opacity: 0.8;
}

.chat-widget-close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #131313;
  line-height: 1;
  padding: 4px;
}

.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #F6F6F6;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-widget-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-widget-bubble.customer {
  align-self: flex-end;
  background: #00980B;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-widget-bubble.ai,
.chat-widget-bubble.staff {
  align-self: flex-start;
  background: #fff;
  color: #131313;
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
}

.chat-widget-bubble .sender-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
  opacity: 0.65;
  text-transform: uppercase;
}

.chat-widget-typing {
  align-self: flex-start;
  font-size: 12px;
  color: #666;
  padding: 4px 8px;
  font-style: italic;
}

.chat-widget-bubble.ai .chat-widget-link,
.chat-widget-bubble.staff .chat-widget-link {
  color: var(--primary, #00980b);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-widget-bubble.ai .chat-widget-link:hover,
.chat-widget-bubble.staff .chat-widget-link:hover {
  opacity: 0.85;
}

.chat-widget-input-area {
  padding: 12px;
  border-top: 1px solid #eee;
  background: #fff;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.chat-widget-input-area textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  height: 44px;
  line-height: 1.4;
}

.chat-widget-input-area textarea:focus {
  outline: none;
  border-color: #FFCEE5;
}

.chat-widget-send {
  background: #00980B;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.chat-widget-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-widget-welcome {
  text-align: center;
  color: #666;
  font-size: 13px;
  padding: 24px 12px;
}

@media (max-width: 768px) {
  .chat-widget-toggle {
    bottom: 62px;
    right: 10px;
  }

  body:has(#chat-widget-root) .page_up_btn {
    bottom: 118px;
    right: 10px;
  }

  .chat-widget-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 70vh;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}
