/* CHAT.CSS - Telegram-style chat interface */

.chat-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid var(--stroke);
}

/* SIDEBAR - Список водителей */
.chat-sidebar {
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-sidebar-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.chat-online-count {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.chat-drivers-list {
  overflow-y: auto;
  flex: 1;
}

.chat-drivers-list::-webkit-scrollbar {
  width: 6px;
}

.chat-drivers-list::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-drivers-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.chat-driver-item {
  padding: 8px 16px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-driver-item:hover {
  background: #fff;
}

.chat-driver-item.active {
  background: #fff;
  border-left: 3px solid var(--indigo);
}

.chat-driver-item.unread {
  background: #eff6ff;
}

.chat-driver-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-driver-avatar.online::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #fff;
  border-radius: 50%;
  bottom: 2px;
  right: 2px;
}

.chat-driver-details {
  flex: 1;
  min-width: 0;
}

.chat-driver-name-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-driver-name-text {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.chat-last-message-time {
  font-size: 11px;
  color: var(--muted);
}

.chat-last-message {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread-badge {
  background: var(--indigo);
  color: #fff;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

/* MAIN CHAT */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
}

.chat-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 9px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.chat-driver-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-driver-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.chat-driver-status {
  font-size: 13px;
  color: #10b981;
}

.chat-driver-status.offline {
  color: var(--muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.chat-message {
  display: flex;
  margin-bottom: 16px;
  animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.incoming {
  justify-content: flex-start;
}

.chat-message.outgoing {
  justify-content: flex-end;
}

.chat-message-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.incoming .chat-message-bubble {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chat-message.outgoing .chat-message-bubble {
  background: var(--indigo);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message-time {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.7;
}

.chat-message.incoming .chat-message-time {
  color: var(--muted);
}

.chat-message.outgoing .chat-message-time {
  color: rgba(255,255,255,0.8);
  text-align: right;
}

.chat-message-status {
  display: inline-block;
  margin-left: 4px;
}

.chat-input-container {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  transition: all 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: var(--indigo);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: #6366f1;
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Date separator */
.chat-date-separator {
  text-align: center;
  margin: 20px 0;
}

.chat-date-separator span {
  background: #e5e7eb;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

/* System message */
.chat-system-message {
  text-align: center;
  margin: 16px 0;
  font-size: 13px;
  color: var(--muted);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 12px;
  width: fit-content;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* Responsive */
@media (max-width: 960px) {
  .chat-container {
    grid-template-columns: 280px 1fr;
  }
}

@media (max-width: 640px) {
  .chat-container {
    grid-template-columns: 1fr;
  }
  
  .chat-sidebar {
    display: none;
  }
  
  .chat-sidebar.mobile-visible {
    display: flex;
  }
  
  .chat-main {
    display: none;
  }
  
  .chat-main.mobile-visible {
    display: flex;
  }
}
