/* ============================================
   Private Messaging Styles
   ============================================ */

/* Private Chat Container */
#privateChat, #privateChatsList {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  z-index: 1000;
  background: var(--bg-secondary);
  overflow: hidden;
}

/* ============================================
   Bottom Tab Navigation
   ============================================ */

.bottom-tab-navigation {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 70px;
  display: none; /* Hidden - using FAB instead */
  border-top: 1px solid #e0e0e0;
  background: white;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.tab-button {
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: #999;
  transition: all 0.3s ease;
  position: relative;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.tab-button svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.tab-button.active {
  color: #667eea;
}

.tab-button.active svg {
  stroke-width: 2.5;
}

.unread-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  min-width: 18px;
  min-height: 18px;
}

/* ============================================
   Private Chats List
   ============================================ */

.private-chats-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-secondary);
}

.chats-list-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chats-list-header .back-button {
  background: none;
  border: none;
  color: #667eea;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 50%;
  margin-left: -8px;
}

.chats-list-header .back-button:hover {
  background: rgba(102, 126, 234, 0.1);
}

.chats-list-header .back-button:active {
  transform: scale(0.9);
}

.chats-list-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.chats-list-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  text-align: center;
  padding: 40px 20px;
  gap: 12px;
}

.empty-icon {
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  font-size: 16px;
  color: var(--text-secondary);
}

.empty-subtext {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* Chat Item */
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  margin: 0 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-radius: 12px;
}

.chat-item:hover {
  background: var(--bg-tertiary);
}

.chat-item.unread {
  background: rgba(102, 126, 234, 0.1);
}

.chat-item-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0e0e0;
}

.chat-unread-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  border: 2px solid var(--bg-secondary);
  min-width: 20px;
  min-height: 20px;
}

.chat-item-content {
  flex: 1;
  min-width: 0;
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-item-name {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-item-message {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.chat-item.unread .chat-item-message {
  color: var(--text-primary);
  font-weight: 500;
}

.chat-item-arrow {
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* ============================================
   Private Chat View
   ============================================ */

.private-chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for mobile */
  background: var(--bg-secondary);
  overflow: hidden;
}

.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.chat-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #667eea;
  transition: background 0.2s ease;
  border-radius: 8px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.chat-back-btn:active {
  background: rgba(102, 126, 234, 0.1);
}

.chat-back-btn svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.5;
}

.chat-header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Chat Photo Section */
.chat-photo-section {
  flex-shrink: 0;
  padding: 12px 16px;
  display: flex;
  justify-content: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.chat-user-photo {
  width: 120px;
  height: 150px;
  object-fit: cover;
  border-radius: 12px;
  background: #f5f5f5;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  background: var(--bg-secondary);
  min-height: 0; /* Important for flex scroll */
}

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  font-size: 14px;
}

.message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.message.sent {
  justify-content: flex-end;
}

.message.received {
  justify-content: flex-start;
}

.message.hide-avatar {
  margin-top: -4px;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #e0e0e0;
  flex-shrink: 0;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 70%;
}

.message.sent .message-content {
  align-items: flex-end;
}

.message.received .message-content {
  align-items: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 19px;
}

.message.sent .message-bubble {
  background: #667eea;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Chat Input */
.chat-input-area {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  min-height: 64px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-sizing: border-box;
}

.chat-message-input {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px; /* 16px prevents zoom on iOS */
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 40px;
  box-sizing: border-box;
}

.chat-message-input:focus {
  border-color: #667eea;
}

.chat-send-btn {
  background: #667eea;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.chat-send-btn:active {
  transform: scale(0.92);
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
  .chat-item-content {
    min-width: 0;
  }

  .message-content {
    max-width: 85%;
  }

  .tab-button span {
    font-size: 11px;
  }

  .tab-button svg {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding-bottom: 60px;
  }

  .bottom-tab-navigation {
    height: 60px;
  }

  .tab-button {
    gap: 2px;
  }

  .tab-button span {
    font-size: 10px;
  }

  .tab-button svg {
    width: 20px;
    height: 20px;
  }

  .message-content {
    max-width: 90%;
  }

  .chat-item {
    padding: 10px 10px;
  }

  .chat-item-name {
    font-size: 15px;
  }

  .chat-item-message {
    font-size: 13px;
  }

  .avatar-img {
    width: 58px;
    height: 58px;
  }
}
