/* ── Chat sheet (slides from right) ── */
.chat-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 28rem;
  background: var(--bg);
  backdrop-filter: var(--blur-xl);
  -webkit-backdrop-filter: var(--blur-xl);
  border-left: 1px solid rgba(0, 0, 0, 0.04);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition);
}

[data-theme="dark"] .chat-sheet {
  background: rgba(10, 10, 10, 0.95);
  border-left-color: rgba(255, 255, 255, 0.04);
}

.chat-sheet.open {
  transform: translateX(0);
}

/* Views layout */
#chatListView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#chatThreadView {
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .chat-header {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.chat-header-title {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Seller location bar */
.seller-location-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 14px;
  flex-shrink: 0;
}

[data-theme="dark"] .seller-location-bar {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.seller-location-bar svg {
  width: 14px;
  height: 14px;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.seller-location-bar .location-city {
  font-weight: 500;
  color: var(--fg);
}

.seller-location-bar .location-region,
.seller-location-bar .location-country {
  color: var(--fg-muted);
}

.seller-location-bar .location-loading {
  color: var(--fg-muted);
  font-size: 14px;
}

/* Conversations list */
.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
  background: none;
  font-family: var(--font);
}

[data-theme="dark"] .conversation-item {
  border-bottom-color: rgba(255, 255, 255, 0.03);
}

.conversation-item:last-child { border-bottom: none; }

.conversation-item:hover {
  background: rgba(248, 248, 248, 0.50);
}

[data-theme="dark"] .conversation-item:hover {
  background: rgba(38, 38, 38, 0.50);
}

.conversation-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background: var(--secondary);
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  opacity: 0.8;
  flex-shrink: 0;
}

.conversation-details {
  flex: 1;
  min-width: 0;
}

.conversation-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--primary-fg);
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.conversation-item-title {
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.conversation-preview {
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* Messages */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: var(--radius-2xl);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.sent {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-fg);
  border-bottom-right-radius: 6px;
}

.message.received {
  align-self: flex-start;
  background: var(--secondary);
  opacity: 0.8;
  color: var(--fg);
  border-bottom-left-radius: 6px;
}

.message-time {
  font-size: 10px;
  margin-top: 4px;
}

.message.sent .message-time {
  text-align: right;
  opacity: 0.5;
}

.message.received .message-time {
  color: var(--fg-faint);
  opacity: 0.5;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--fg-faint);
}

.typing-indicator.active { display: flex; }

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fg-faint);
  animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  background: rgba(255, 255, 255, 0.80);
}

[data-theme="dark"] .chat-input-area {
  border-top-color: rgba(255, 255, 255, 0.04);
  background: rgba(10, 10, 10, 0.80);
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-xl);
  background: var(--secondary);
  color: var(--fg);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition-fast);
}

[data-theme="dark"] .chat-input {
  border-color: rgba(255, 255, 255, 0.04);
}

.chat-input:focus {
  border-color: var(--border-focus);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-xl);
  background: var(--primary);
  color: var(--primary-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast);
  flex-shrink: 0;
}

.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Empty */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.chat-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: var(--secondary);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-icon svg {
  width: 24px;
  height: 24px;
  color: var(--fg-muted);
}

.chat-empty p {
  font-size: 14px;
  color: var(--fg-muted);
}

.chat-thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-thread-empty p {
  font-size: 14px;
  color: var(--fg-faint);
  opacity: 0.6;
}

/* Translation toggle */
.msg-translate-toggle {
  display: inline-block;
  font-size: 10px;
  color: var(--fg-faint);
  cursor: pointer;
  margin-top: 2px;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.msg-translate-toggle:hover {
  color: var(--fg-muted);
}

.message.sent .msg-translate-toggle {
  opacity: 0.6;
  color: var(--primary-fg);
}

@media (max-width: 640px) {
  .chat-sheet { max-width: 100vw; }
}
