/* 杆杆响智慧助手 — 人员管理样式 */
/* 与 dashboard.css 保持统一的深色主题设计风格 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* 继承深色主题配色 */
  --bg: #1a1a2e;
  --bg-surface: #16213e;
  --bg-card: #0f3460;
  --text: #e6e6e6;
  --text-muted: #a0a0b0;
  --accent: #e94560;
  --accent-light: #ff6b81;
  --border: #2a2a4a;
  
  /* 状态颜色 */
  --status-active: #10b981;
  --status-probation: #f59e0b;
  --status-left: #6b7280;
  --status-suspended: #ef4444;
}

html, body { 
  height: 100%; 
  font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; 
  background: var(--bg); 
  color: var(--text); 
  overflow: hidden;
}

/* ===== 布局 ===== */
.hr-layout {
  display: flex;
  height: calc(100vh - 52px);
}

/* ===== Header / Navigation ===== */
#header {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  height: 52px; 
  padding: 0 16px;
  background: var(--bg-surface); 
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

#header h1 { 
  font-size: 16px; 
  font-weight: 600; 
  white-space: nowrap; 
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-nav { display: flex; gap: 4px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.nav-link {
  padding: 8px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--bg-card); }
.nav-link.active { 
  color: var(--accent); 
  background: rgba(233, 69, 96, 0.15); 
  font-weight: 500;
}

/* ===== 侧边栏 ===== */
.hr-sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.dept-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.dept-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.dept-item:hover {
  background: rgba(233, 69, 96, 0.1);
}

.dept-item.active {
  background: rgba(233, 69, 96, 0.15);
  border-left-color: var(--accent);
}

.dept-item .dept-name {
  font-size: 14px;
  color: var(--text);
}

.dept-item .dept-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===== 主内容区 ===== */
.hr-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 工具栏 ===== */
.hr-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}

.search-box input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--accent);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 14px;
  color: var(--text-muted);
}

.filter-group select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.filter-group select:focus {
  border-color: var(--accent);
}

/* ===== Tab 切换 ===== */
.hr-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.hr-tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.hr-tab-btn:hover {
  color: var(--text);
}

.hr-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.hr-tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.hr-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ===== 员工表格 ===== */
.employee-table-container {
  flex: 1;
  overflow: auto;
  padding: 0 20px 20px;
}

.employee-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
}

.employee-table thead th {
  background: rgba(15, 52, 96, 0.6);
  padding: 14px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.employee-table thead th:hover {
  background: rgba(233, 69, 96, 0.1);
}

.employee-table thead th.sortable::after {
  content: '⇅';
  margin-left: 6px;
  opacity: 0.4;
  font-size: 12px;
}

.employee-table thead th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--accent);
}

.employee-table thead th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--accent);
}

.employee-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}

.employee-table tbody tr {
  cursor: pointer;
  transition: background 0.2s;
}

.employee-table tbody tr:hover {
  background: rgba(233, 69, 96, 0.1);
}

/* ===== 状态标签 ===== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: var(--status-active);
}

.status-badge.probation {
  background: rgba(245, 158, 11, 0.2);
  color: var(--status-probation);
}

.status-badge.left {
  background: rgba(107, 114, 128, 0.2);
  color: var(--status-left);
}

.status-badge.suspended {
  background: rgba(239, 68, 68, 0.2);
  color: var(--status-suspended);
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== 员工详情弹窗 ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item.full-width {
  grid-column: span 2;
}

.detail-item label {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-item .value {
  font-size: 15px;
  color: var(--text);
}

/* ===== 任务列表 ===== */
.task-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.task-section h3 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.task-item .task-name {
  font-size: 14px;
  color: var(--text);
}

.task-item .task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-item .task-status {
  font-size: 12px;
  color: var(--text-muted);
}

.task-item .task-priority {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.task-priority.high {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.task-priority.medium {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.task-priority.low {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.task-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 14px;
}

/* ===== 组织架构图 ===== */
.org-chart-container {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

.org-chart-container canvas {
  display: block;
}

/* ===== KPI 卡片（部门概览用） ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
}

.kpi-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 14px;
}

/* ===== 加载状态 ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.loading-spinner::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Scrollbar ===== */
.employee-table-container::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.dept-tree::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.employee-table-container::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.dept-tree::-webkit-scrollbar-track {
  background: transparent;
}

.employee-table-container::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.dept-tree::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.employee-table-container::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.dept-tree::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 响应式布局 ===== */
@media (max-width: 1024px) {
  .hr-sidebar {
    width: 200px;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  .detail-item.full-width {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .hr-layout {
    flex-direction: column;
  }
  
  .hr-sidebar {
    width: 100%;
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .dept-tree {
    display: flex;
    overflow-x: auto;
    padding: 8px 16px;
    gap: 8px;
  }
  
  .dept-item {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: 6px;
  }
  
  .dept-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  
  .header-nav {
    display: none;
  }
  
  .hr-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-box {
    max-width: none;
  }
  
  .filter-group {
    justify-content: space-between;
  }
  
  .employee-table {
    font-size: 13px;
  }
  
  .employee-table thead th,
  .employee-table tbody td {
    padding: 10px 12px;
  }
  
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  
  .kpi-card {
    padding: 16px;
  }
  
  .kpi-value {
    font-size: 28px;
  }
  
  .employee-table-container {
    padding: 0 12px 12px;
  }
  
  .pagination {
    flex-wrap: wrap;
  }
}

/* 员工名字链接样式 */
.employee-name-link {
  color: #4fc3f7;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.employee-name-link:hover {
  text-decoration: underline;
  color: #81d4fa;
}
