:root {
  --primary-color: #4a6fa5;
  --secondary-color: #6b8cbc;
  --success-color: #4caf50;
  --danger-color: #f44336;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --gray-color: #e9ecef;
  --border-color: #dee2e6;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --top-height: 70px;
  --bottom-height: 70px;
  --online-color: #4caf50;
  --offline-color: #f44336;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f0f2f5;
  color: #333;
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  height: 100%;
  position: relative;
}

.panel {
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  height: 100%;
}

.header {
  background: var(--primary-color);
  color: white;
  padding: 0;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
}

.tabs {
  display: flex;
  background: #e9ecef;
}

.tab {
  flex: 1;
  padding: 15px;
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.3s;
}

.tab.active {
  background: white;
  font-weight: bold;
}

.form {
  padding: 30px;
  display: none;
}

.form.active {
  display: block;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 1rem;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s;
}

.btn.primary {
  background: var(--primary-color);
  color: white;
}

.btn.primary:hover {
  background: var(--secondary-color);
}

.btn.danger {
  background: var(--danger-color);
  color: white;
}

.btn.small {
  padding: 8px 15px;
  font-size: 0.9rem;
}

.message {
  padding: 10px;
  margin-top: 15px;
  border-radius: 5px;
  font-size: 0.9rem;
}

.message.error {
  background: #ffebee;
  color: var(--danger-color);
}

.message.success {
  background: #e8f5e9;
  color: var(--success-color);
}

.hidden {
  display: none;
}

/* 固定定位元素 */
.fixed-top {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--top-height);
  z-index: 100;
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--bottom-height);
  z-index: 100;
  background: white;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
  padding: 10px;
}

.fixed-bottom .input-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  padding: 0 10px;
}

.message-input input {
  flex: 1;
  margin-right: 10px;
  height: 40px;
  padding: 0 10px;
}

.main-content {
  position: absolute;
  top: var(--top-height);
  bottom: var(--bottom-height);
  left: 0;
  right: 0;
  display: flex;
  overflow: hidden;
}

.message-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #f9f9f9;
}

/* 聊天主面板样式 */
.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.avatar-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #e91e63;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  border: 2px solid white;
}

.user-info h2 {
  font-size: 1.3rem;
}

.ip-info {
  font-size: 0.85rem;
  opacity: 0.8;
}

.sidebar {
  width: 300px;
  background: var(--gray-color);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
  z-index: 99;
}

.section {
  margin-bottom: 25px;
}

.section h3 {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-list, .message-list {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
}

.user-list li, .message-list li {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-list li:hover, .message-list li:hover {
  background: rgba(255, 255, 255, 0.7);
}

.user-list li.active {
  background: white;
  font-weight: bold;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #3f51b5;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.search-box {
  display: flex;
  margin-bottom: 15px;
}

.search-box input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 5px 0 0 5px;
}

.search-box button {
  padding: 10px 15px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.message-container {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message-item {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message-header {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  gap: 10px;
}

.message-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background-color: #2196f3;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.message-username {
  font-weight: bold;
}

.message-time {
  font-size: 0.8rem;
  color: #777;
  margin-left: auto;
}

.message-ip {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 5px;
}

.message-content {
  background: white;
  padding: 12px 15px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
}

.my-message {
  align-self: flex-end;
}

.my-message .message-content {
  background: #d9edf7;
}

.my-message .message-avatar {
  background-color: #4caf50;
}

/* 模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-login-modal {
  max-width: 400px;
}

.modal-header {
  padding: 15px 20px;
  background: var(--primary-color);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 8px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.pagination-container {
  padding: 15px;
  background: #f8f9fa;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.page-info {
  font-weight: 500;
}

.no-results {
  text-align: center;
  padding: 30px;
  color: #777;
}

/* 管理员样式 */
.admin-login-container {
  padding: 20px;
  text-align: center;
  border-top: 1px solid var(--border-color);
}

.btn.admin-btn {
  background: #6c757d;
  color: white;
}

.btn.admin-btn:hover {
  background: #5a6268;
}

.admin-content {
  padding: 20px;
}

.admin-section {
  margin-bottom: 30px;
  padding: 20px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-section h2 {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.setting-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.user-search {
  display: flex;
  margin-bottom: 15px;
}

.user-search input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 5px 0 0 5px;
}

.user-search button {
  padding: 10px 15px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
}

.user-list-container {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 5px;
  padding: 10px;
}

.user-list-container::-webkit-scrollbar {
  width: 8px;
}

.user-list-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.user-list-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.user-list-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#userListTable {
  width: 100%;
  border-collapse: collapse;
}

#userListTable th, 
#userListTable td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

#userListTable th {
  background: var(--gray-color);
  font-weight: 600;
}

#userListTable tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.user-action-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  margin-right: 5px;
}

.admin-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.admin-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.admin-toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .admin-toggle-slider {
  background-color: var(--primary-color);
}

input:checked + .admin-toggle-slider:before {
  transform: translateX(26px);
}

.no-users {
  text-align: center;
  padding: 20px;
  color: #777;
}

.user-status {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
}

.user-status.online {
  background-color: var(--online-color);
}

.user-status.offline {
  background-color: var(--offline-color);
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.reset-password-btn {
  background: #17a2b8;
  color: white;
  margin-left: 5px;
}

/* 移动端优化 */
@media (max-width: 768px) {
  :root {
    --top-height: 60px;
    --bottom-height: 60px;
  }
  
  .app-container {
    padding: 0;
    margin: 0;
    max-width: 100%;
  }
  
  .fixed-top {
    height: var(--top-height);
    padding: 0;
  }
  
  .fixed-top .header-content {
    padding: 0 10px;
  }
  
  .fixed-top .header-content.mobile {
    padding: 5px;
  }
  
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    flex-shrink: 0;
  }
  
  .user-info.mobile {
    flex: 1;
    overflow: hidden;
    gap: 8px;
  }
  
  .user-info.mobile .user-details {
    display: none;
  }
  
  .avatar-circle.mobile {
    width: 35px;
    height: 35px;
    font-size: 1rem;
    flex-shrink: 0;
  }
  
  .btn.danger.mobile,
  .btn.primary.mobile {
    padding: 8px 12px;
    font-size: 0.9rem;
    flex-shrink: 0;
  }
  
  .fixed-bottom {
    height: var(--bottom-height);
    padding: 5px 10px;
  }
  
  .fixed-bottom .input-container {
    padding: 0;
  }
  
  .fixed-bottom input {
    height: 40px;
    margin-right: 5px;
    padding: 0 10px;
  }
  
  .fixed-bottom button {
    height: 40px;
    padding: 0 15px;
    white-space: nowrap;
  }
  
  .main-content {
    top: var(--top-height);
    bottom: var(--bottom-height);
  }
  
  .sidebar {
    width: 80%;
    height: 100%;
    position: fixed;
    top: var(--top-height);
    left: -100%;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  .sidebar.active {
    left: 0;
  }
  
  .chat-area {
    width: 100%;
  }
  
  .message-item {
    max-width: 90%;
  }
  
  /* 键盘弹出时调整 */
  .keyboard-open .fixed-top {
    top: 0;
  }
  
  .keyboard-open .fixed-bottom {
    bottom: 0;
  }
  
  .keyboard-open .main-content {
    height: calc(100vh - var(--top-height) - var(--bottom-height) - env(keyboard-inset-height, 0));
  }
  
  /* 模态框优化 */
  .modal-content {
    width: 95%;
    height: 90vh;
  }
  
  .pagination-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .modal-header h3 {
    font-size: 1.1rem;
  }
  
  /* 管理员响应式 */
  .admin-section {
    padding: 15px;
  }
  
  #userListTable th, 
  #userListTable td {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
  
  .admin-actions {
    flex-direction: column;
    gap: 5px;
  }
  
  .admin-actions .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
  
  /* 用户管理表格操作按钮 */
  .user-action-btn {
    display: block;
    margin-top: 5px;
    width: 100%;
  }
}

/* PC端优化 */
@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none !important;
  }
  
  .sidebar {
    position: relative;
    left: 0;
    width: 300px;
    height: 100%;
  }
  
  .user-info .user-details {
    display: block;
  }
}

/* 在文件末尾添加 */
@media (max-width: 768px) {
  .admin-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
  }
  
  .admin-actions .btn {
    margin: 3px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  
  .user-info h2 {
    font-size: 1.1rem;
  }
}