/* Chats List Styles */
.chats-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.chats-header {
  margin-bottom: 24px;
}

.chats-header h1 {
  font-size: 28px;
}

.chats-list {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
}

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

.chat-item:hover {
  background: var(--bg-light);
}

.chat-item.unread {
  background: #eff6ff;
}

.chat-avatar {
  flex-shrink: 0;
}

.avatar-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

.chat-info {
  flex: 1;
  min-width: 0;
}

.chat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-user-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-color);
}

.chat-time {
  font-size: 12px;
  color: #4b5563;
  font-weight: 500;
}

.chat-ad-title {
  font-size: 13px;
  color: #374151;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.chat-last-message {
  font-size: 14px;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-prefix {
  font-weight: 600;
  color: var(--text-color);
}

.unread-badge {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Chat Show Styles */
.chat-show-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 84px);
  max-width: 1000px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: white;
  flex-shrink: 0;
}

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

.back-button {
  color: var(--text-color);
  text-decoration: none;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.back-button:hover {
  background: var(--bg-light);
}

.back-button .icon {
  width: 24px;
  height: 24px;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h2 {
  font-size: 18px;
  margin: 0 0 4px 0;
  color: var(--text-color);
}

.chat-ad-link {
  font-size: 13px;
  color: #6b7280;
}

.ad-title-link {
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
}

.ad-title-link:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.chat-header-right {
  flex-shrink: 0;
  margin-left: 16px;
}

.language-toggle-btn {
  padding: 8px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.language-toggle-btn:hover {
  background: var(--border-color);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  background: #f9fafb;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.message {
  display: flex;
  margin-bottom: 8px;
}

.message-sent {
  justify-content: flex-end;
}

.message-received {
  justify-content: flex-start;
}

.message-sent .message-bubble {
  max-width: 70%;
}

.message-received .message-bubble {
  max-width: 70%;
}

.message-bubble {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  word-wrap: break-word;
}

.message-sent .message-bubble {
  background: var(--primary-color);
  color: white;
}

.message-content {
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 15px;
}

.message-content p {
  margin: 0;
}

.message-translation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  font-style: italic;
  opacity: 0.9;
  font-size: 14px;
}

.message-sent .message-translation {
  border-top-color: rgba(255, 255, 255, 0.3);
}

.message-attachment {
  margin-top: 8px;
}

.attachment-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  display: block;
}

.attachment-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  padding: 8px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  font-size: 14px;
}

.message-sent .attachment-link {
  background: rgba(255, 255, 255, 0.2);
}

.attachment-link:hover {
  background: rgba(0, 0, 0, 0.1);
}

.attachment-link .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.message-meta {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.message-input-container {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: white;
  flex-shrink: 0;
}

.message-form {
  display: flex;
  gap: 12px;
}

.message-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-light);
  border-radius: 24px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
}

.message-input {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
  padding: 4px 0;
}

.message-input:focus {
  outline: none;
}

.message-input::placeholder {
  color: #6b7280;
  font-weight: 500;
}

.send-button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.send-button:hover {
  background: var(--primary-hover);
}

.send-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.send-button .icon {
  width: 20px;
  height: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .chats-container {
    padding: 12px;
  }

  .chats-header h1 {
    font-size: 22px;
  }

  .chat-item {
    padding: 12px;
    gap: 12px;
  }

  .avatar-circle {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .chat-user-name {
    font-size: 15px;
  }

  .chat-time {
    font-size: 11px;
  }

  .chat-ad-title {
    font-size: 12px;
  }

  .chat-last-message {
    font-size: 13px;
  }

  .chat-show-container {
    height: calc(100vh - 64px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .message-sent .message-bubble,
  .message-received .message-bubble {
    max-width: 85%;
  }

  .chat-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .chat-header-left {
    width: 100%;
    margin-bottom: 0;
  }

  .chat-header-right {
    width: 100%;
    margin-left: 0;
  }

  .chat-header-info h2 {
    font-size: 16px;
  }

  .messages-container {
    padding: 12px;
  }

  .message-input-container {
    padding: 12px;
  }

  .message-form {
    gap: 8px;
  }

  .message-input-wrapper {
    padding: 6px 10px;
  }

  .message-input {
    font-size: 14px;
  }

  .send-button {
    width: 32px;
    height: 32px;
  }

  .send-button .icon {
    width: 18px;
    height: 18px;
  }

  .language-toggle-btn {
    width: 100%;
    padding: 10px 12px;
    font-size: 12px;
  }

  .back-button {
    padding: 6px;
  }

  .back-button .icon {
    width: 20px;
    height: 20px;
  }

  .message-bubble {
    padding: 10px 12px;
  }

  .message-content {
    font-size: 14px;
  }

  .message-meta {
    font-size: 10px;
  }

  .attachment-image {
    max-height: 250px;
  }
}

@media (max-width: 480px) {
  .chats-container {
    padding: 8px;
  }

  .chats-header h1 {
    font-size: 20px;
    margin-bottom: 16px;
  }

  .chat-item {
    padding: 10px;
    gap: 10px;
  }

  .avatar-circle {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .chat-user-name {
    font-size: 14px;
  }

  .chat-time {
    font-size: 10px;
  }

  .chat-ad-title {
    font-size: 11px;
  }

  .chat-last-message {
    font-size: 12px;
  }

  .message-sent .message-bubble,
  .message-received .message-bubble {
    max-width: 90%;
  }

  .chat-header {
    padding: 10px 12px;
  }

  .chat-header-info h2 {
    font-size: 15px;
  }

  .chat-header-left {
    gap: 8px;
  }

  .messages-container {
    padding: 8px;
  }

  .message-input-container {
    padding: 8px;
  }

  .message-bubble {
    padding: 8px 10px;
    border-radius: 10px;
  }

  .message-content {
    font-size: 13px;
  }

  .message-input {
    font-size: 13px;
  }

  .send-button {
    width: 30px;
    height: 30px;
  }

  .send-button .icon {
    width: 16px;
    height: 16px;
  }

  .language-toggle-btn {
    padding: 8px 10px;
    font-size: 11px;
  }

  .attachment-image {
    max-height: 200px;
  }

  .message-meta {
    font-size: 9px;
  }
}
