/* ============================================
   CHAT/MESSAGING STYLES
   ============================================ */

.chat-page {
  padding-top: 80px;
  height: 100vh;
  overflow: hidden;
}

.chat-container {
  display: flex;
  height: calc(100vh - 80px);
  max-width: 1400px;
  margin: 0 auto;
}

/* Chat Sidebar */
.chat-sidebar {
  width: 350px;
  background: rgba(15, 23, 42, 0.8);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
}

.chat-sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-sidebar-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.chat-search {
  position: relative;
}

.chat-search input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition-normal);
}

.chat-search input:focus {
  border-color: var(--primary);
  outline: none;
}

.chat-search .icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
}

.chat-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-normal);
}

.chat-item:hover {
  background: rgba(99, 102, 241, 0.1);
}

.chat-item.active {
  background: rgba(99, 102, 241, 0.2);
}

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

.chat-item-avatar img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-item-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.chat-item-status.online {
  background: var(--success);
}

.chat-item-status.offline {
  background: var(--text-muted);
}

.chat-item-status.away {
  background: var(--warning);
}

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

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

.chat-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.chat-item-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-item-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.chat-item-message.unread {
  color: var(--text-primary);
  font-weight: 500;
}

.chat-item-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-item-typing {
  font-size: 0.8rem;
  color: var(--primary-light);
  font-style: italic;
}

/* Chat Main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.5);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chat-header-avatar {
  position: relative;
}

.chat-header-avatar img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  background: var(--success);
}

.chat-header-details h4 {
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-header-details p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-header-actions {
  display: flex;
  gap: var(--space-sm);
}

.chat-header-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  transition: var(--transition-normal);
}

.chat-header-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.chat-date-divider {
  text-align: center;
  margin: var(--space-md) 0;
}

.chat-date-divider span {
  display: inline-block;
  padding: 0.25rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.message {
  display: flex;
  gap: var(--space-md);
  max-width: 70%;
  animation: fadeInUp 0.3s ease;
}

.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.message-avatar img {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.sent .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.message.received .message-bubble {
  background: rgba(30, 41, 59, 0.8);
  border-bottom-left-radius: 4px;
}

.message.sent .message-bubble {
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.message.sent .message-time {
  color: rgba(255, 255, 255, 0.7);
}

.message-status {
  display: flex;
  align-items: center;
}

.message-status.read {
  color: var(--accent);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  animation: fadeInUp 0.3s ease;
}

.typing-indicator-avatar img {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}

.typing-indicator-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-md) var(--space-lg);
  background: rgba(30, 41, 59, 0.8);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.typing-indicator-bubble span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease infinite;
}

.typing-indicator-bubble span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-5px);
  }
}

/* Chat Input */
.chat-input-container {
  padding: var(--space-md) var(--space-lg);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: var(--space-sm) var(--space-md);
}

.chat-input-actions {
  display: flex;
  gap: var(--space-xs);
}

.chat-input-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  transition: var(--transition-normal);
}

.chat-input-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: none;
  max-height: 100px;
  padding: var(--space-sm) 0;
}

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

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  border-radius: 50%;
  color: white;
  transition: var(--transition-normal);
}

.chat-send-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Empty Chat State */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.chat-empty-icon {
  width: 120px;
  height: 120px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: var(--space-lg);
}

.chat-empty-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.chat-empty-text {
  color: var(--text-secondary);
  max-width: 400px;
}

.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow);
  z-index: 40;
}

/* ============================================
   RESPONSIVE CHAT
   ============================================ */

@media (max-width: 992px) {
  .chat-sidebar {
    width: 300px;
  }
  
  .message {
    max-width: 85%;
  }
}

@media (max-width: 768px) {
  .chat-page {
    padding-top: 0;
  }

  .chat-container {
    position: relative;
    flex-direction: column;
    height: calc(100vh - 66px);
  }
  
  .chat-sidebar {
    width: 100%;
    height: 100%;
    position: relative;
    transform: none;
    z-index: 1;
    border-right: 0;
  }
  
  .chat-main {
    width: 100%;
    height: 100%;
    display: none;
  }

  .chat-container.mobile-chat-open .chat-sidebar {
    display: none;
  }

  .chat-container.mobile-chat-open .chat-main {
    display: flex;
  }

  .chat-container.mobile-chat-open .chat-fab {
    display: none;
  }
  
  .message {
    max-width: 90%;
  }
  
  .chat-back-btn {
    display: flex;
  }

  .chat-header-actions {
    display: none;
  }

  .chat-empty {
    display: none;
  }

  .chat-fab {
    display: flex;
    right: 18px;
    bottom: 18px;
  }
}

@media (min-width: 769px) {
  .chat-back-btn,
  .chat-fab {
    display: none !important;
  }
}
