/* ========== Chat Popup ========== */

.wk-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1050;
}

.wk-chat-backdrop[hidden],
.wk-chat[hidden] {
  display: none !important;
}

.wk-chat {
  position: fixed;
  z-index: 1051;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  inset: 0;
}

@media (min-width: 768px) {
  .wk-chat {
    inset: auto;
    bottom: 16px;
    right: 16px;
    width: 400px;
    height: 600px;
    border-radius: 24px;
  }

  .wk-chat-backdrop {
    display: none !important;
  }
}

.wk-chat-header {
  background: linear-gradient(90deg, #9333ea, #2563eb);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.wk-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wk-chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.wk-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.125rem;
}

.wk-chat-online {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: #4ade80;
  border: 2px solid #fff;
  border-radius: 50%;
}

.wk-chat-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-chat-status {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}

.wk-chat-status svg {
  fill: #4ade80;
  color: #4ade80;
}

.wk-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.wk-chat-icon-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.wk-chat-icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.wk-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wk-chat-msg {
  display: flex;
}

.wk-chat-msg--seller {
  justify-content: flex-start;
}

.wk-chat-msg--user {
  justify-content: flex-end;
}

.wk-chat-bubble {
  max-width: 75%;
  padding: 12px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.wk-chat-msg--seller .wk-chat-bubble {
  background: #fff;
  color: #111827;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.wk-chat-msg--user .wk-chat-bubble {
  background: linear-gradient(90deg, #9333ea, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.wk-chat-bubble p {
  margin: 0;
}

.wk-chat-time {
  display: block;
  text-align: right;
  font-size: 0.6875rem;
  margin-top: 4px;
  opacity: 0.7;
}

.wk-chat-typing {
  padding: 0 16px 8px;
  background: #f9fafb;
}

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

.wk-chat-bubble--typing {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  border-bottom-left-radius: 4px;
}

.wk-chat-bubble--typing span {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: wk-chat-bounce 1.2s infinite ease-in-out;
}

.wk-chat-bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.wk-chat-bubble--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes wk-chat-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.wk-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.wk-chat-input-icon {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 8px 4px;
  display: inline-flex;
  transition: color 0.15s;
}

.wk-chat-input-icon:hover {
  color: #9333ea;
}

.wk-chat-input-wrap {
  flex: 1;
  background: #f3f4f6;
  border-radius: 16px;
  padding: 8px 16px;
  transition: background 0.15s;
}

.wk-chat-input-wrap:focus-within {
  background: #e5e7eb;
}

.wk-chat-input-wrap textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 0.875rem;
  font-family: var(--wk-font, 'Inter', sans-serif);
  max-height: 96px;
  line-height: 1.4;
}

.wk-chat-send {
  background: linear-gradient(90deg, #9333ea, #2563eb);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.wk-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wk-chat-send:not(:disabled):hover {
  box-shadow: 0 10px 15px -3px rgba(147, 51, 234, 0.35);
}
