/* ========== 排班大师 - 样式表 ========== */

/* —— 基础重置 —— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4A90D9;
  --primary-dark: #357ABD;
  --success: #5CB85C;
  --danger: #D9534F;
  --warning: #F0AD4E;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --border: #E1E5EB;
  --text: #333333;
  --text-secondary: #777777;
  --text-light: #999999;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 6px;
  --font: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-width: 800px;
}

/* —— 头部 —— */
.header {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  height: 100%;
  align-items: stretch;
}

.tab {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 0 20px;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab:hover { color: #fff; background: rgba(255,255,255,0.1); }

.tab.active {
  color: #fff;
  border-bottom-color: #fff;
  font-weight: 600;
}

/* —— 主内容区 —— */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* —— 工具栏 —— */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar h2 {
  font-size: 18px;
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.month-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-label {
  font-size: 18px;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
}

/* —— 按钮 —— */
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:hover { background: #eef1f5; }

.btn-sm { padding: 4px 10px; font-size: 13px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover { background: #4a9e4a; }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover { background: #fce8e6; }

.btn-xs {
  padding: 2px 8px;
  font-size: 12px;
}

.btn-outline {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: #e8f0fe;
}

.btn-move-up, .btn-move-down {
  padding: 1px 4px;
  font-size: 10px;
  line-height: 1;
}

.btn-move-up:disabled, .btn-move-down:disabled {
  opacity: 0.3;
  cursor: default;
}

/* —— 表格容器 —— */
.table-wrapper {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

/* —— 排班表 —— */
.schedule-table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border);
  padding: 0;
  text-align: center;
  white-space: nowrap;
  min-width: 62px;
  height: 36px;
}

.schedule-table thead th {
  padding: 6px 4px;
}

.schedule-table thead th {
  background: #f0f4f8;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
}

.schedule-table .col-name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f8fafc;
  font-weight: 600;
  min-width: 80px;
}

.schedule-table thead .col-name {
  z-index: 3;
}

.schedule-table .weekend {
  background: #fff5f5;
}

.schedule-table .weekend.col-name {
  background: #f8fafc;
}

.schedule-table .cell-shift {
  cursor: pointer;
  padding: 0;
}

.schedule-table .cell-shift:hover {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  z-index: 1;
}

.schedule-table .cell-rest {
  color: var(--text-light);
  font-style: italic;
  cursor: pointer;
}

.schedule-table .cell-rest:hover {
  background: #f0f0f0 !important;
}

.schedule-table .cell-fixed .shift-block {
  border: 2px dashed rgba(0,0,0,0.2);
}

.schedule-table .cell-empty {
  color: #ddd;
  cursor: default;
}

/* 班次块：占满单元格 */
.shift-block {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 32px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 2px;
  box-sizing: border-box;
}

/* —— 统计表 —— */
.stats-section { margin-top: 32px; }

.stats-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--text);
}

.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: center;
}

.stats-table thead th {
  background: #f0f4f8;
  font-weight: 600;
}

.stats-table .col-name {
  text-align: left;
  font-weight: 600;
  background: #f8fafc;
}

.stats-table .highlight-rest { color: var(--text-light); }
.stats-table .highlight-work { color: var(--primary); font-weight: 600; }

/* —— 数据管理表 —— */
.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  text-align: left;
}

.data-table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.data-table tbody tr:hover { background: #f5f8fc; }

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.type-badge.regular    { background: #e3f2fd; color: #1565C0; }
.type-badge.thirdParty { background: #fff3e0; color: #E65100; }
.type-badge.intern     { background: #e8f5e9; color: #2E7D32; }

.table-actions { display: flex; gap: 6px; }

/* —— 提示信息 —— */
.schedule-hint {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
  font-size: 15px;
}

/* —— 弹窗 —— */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-sm { width: 380px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-light);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* —— 表单 —— */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--font);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(74,144,217,0.2);
}

.fixed-shift-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.fixed-shift-row select { flex: 1; }

.weekday-checkboxes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.weekday-checkboxes label {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: normal;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.weekday-checkboxes input[type="checkbox"] {
  margin: 0;
}

.weekday-checkboxes label.has-check {
  background: #e3f2fd;
  border-color: var(--primary);
}

/* —— 下拉菜单 —— */
.dropdown-menu {
  position: fixed;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  min-width: 160px;
  max-height: 320px;
  overflow-y: auto;
}

.dropdown-header {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.dropdown-item {
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

.dropdown-item:hover { background: #e8f0fe; }

.dropdown-item.rest-item {
  color: var(--text-light);
  font-style: italic;
  border-top: 1px solid var(--border);
}

.dropdown-item.selected {
  background: #e3f2fd;
  color: var(--primary);
  font-weight: 600;
}

/* —— 响应式 —— */
@media (max-width: 900px) {
  .main { padding: 12px; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .schedule-table th, .schedule-table td { padding: 4px 2px; font-size: 12px; }
}
