/* ============ 全局样式 ============ */
:root {
    --bg: #f5f6fa;
    --sidebar-bg: #1e1e2e;
    --card-bg: #ffffff;
    --text: #2d3436;
    --text-muted: #636e72;
    --text-light: #b2bec3;
    --primary: #6c5ce7;
    --primary-hover: #5a4bd1;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;
    --border: #dfe6e9;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
    --shift-morning: #74b9ff;
    --shift-afternoon: #fdcb6e;
    --shift-night: #6c5ce7;
    --shift-rest: #dfe6e9;
    --leave-annual: #a29bfe;
    --leave-personal: #fab1a0;
    --leave-sick: #81ecec;
    --overtime: #ffeaa7;
    --team-colors: #6c5ce7, #00b894, #e17055, #0984e3, #fdcb6e, #55efc4, #a29bfe, #fd79a8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-container { display: flex; min-height: 100vh; }

.sidebar { width: 220px; background: var(--sidebar-bg); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h1 { font-size: 18px; font-weight: 600; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-item { display: flex; align-items: center; padding: 12px 20px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 14px; transition: all 0.2s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(108,92,231,0.2); color: #fff; border-left-color: var(--primary); }

.main-content { flex: 1; overflow-y: auto; padding: 24px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.panel-header h2 { font-size: 22px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.panel-body { background: var(--card-bg); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* ============ 按钮 ============ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; transition: all 0.2s; font-family: inherit; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: rgba(108,92,231,0.08); }
.btn-text { background: transparent; color: var(--text-muted); padding: 6px 12px; }
.btn-text:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); padding: 4px 10px; font-size: 12px; }
.btn-danger:hover { background: rgba(225,112,85,0.1); }
.btn-edit { background: transparent; color: var(--primary); border: none; padding: 2px 6px; font-size: 12px; cursor: pointer; border-radius: 4px; }
.btn-edit:hover { background: rgba(108,92,231,0.1); }

/* ============ 输入框 ============ */
.input { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.2s; }
.input:focus { border-color: var(--primary); }
.input-group { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.input-group .input { flex: 1; }

/* ============ 月份选择器 ============ */
.month-picker { display: flex; align-items: center; gap: 4px; background: var(--card-bg); border-radius: 6px; padding: 2px; }
.month-label { font-weight: 600; padding: 0 8px; min-width: 120px; text-align: center; }

/* ============ 统计栏 ============ */
.stats-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card { background: var(--bg); border-radius: 8px; padding: 10px 16px; text-align: center; min-width: 90px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============ 排班表格 ============ */
.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); max-height: 70vh; overflow-y: auto; }

.schedule-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.schedule-table th, .schedule-table td { border: 1px solid var(--border); padding: 5px 7px; text-align: center; min-width: 44px; }
.schedule-table thead th { background: #f8f9fa; font-weight: 600; position: sticky; top: 0; z-index: 3; }
.schedule-table thead th:first-child { min-width: 70px; position: sticky; left: 0; z-index: 4; background: #f0f1f5; }

/* 日期头显示休假类型 */
.schedule-table thead .col-header small { display: block; font-weight: 400; color: var(--text-muted); }

.schedule-table tbody td:first-child { font-weight: 600; position: sticky; left: 0; background: #fff; z-index: 2; }
.schedule-table tbody tr:hover td:first-child { background: #f0f1f5; }

/* 班组分隔行 */
.team-separator td {
    background: #f0edff !important;
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    text-align: left;
    padding: 8px 12px !important;
    border-bottom: 2px solid var(--primary);
}
.team-separator td .team-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

/* 未分组分隔行 */
.ungrouped-separator td {
    background: #f5f6fa !important;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-align: left;
    padding: 8px 12px !important;
    border-bottom: 2px solid var(--border);
}

/* 统计汇总行 */
.stats-row td:first-child {
    font-weight: 700;
    color: #333;
    background: #fafafa !important;
}
.stats-row td {
    background: #fafafa;
    font-size: 11px;
    color: #555;
    border-top: 2px solid #ddd;
}

/* summary cols */
.summary-header { background: #e8f4e8 !important; color: #27ae60; font-size: 11px; }
.summary-cell { background: #f9fdf9; font-size: 11px; font-weight: 600; }

/* 班次颜色 */
.shift-cell { cursor: pointer; font-weight: 500; border-radius: 2px; transition: transform 0.15s; }
.shift-cell:hover { transform: scale(1.06); box-shadow: 0 1px 4px rgba(0,0,0,0.2); z-index: 1; }
.shift-morning { background: #d4e6ff; color: #2d5a9e; }
.shift-afternoon { background: #fff3cd; color: #8a6d14; }
.shift-night { background: #e0d4ff; color: #4a3a8a; }
.shift-rest { color: #b2bec3; background: #f5f6fa; }
.shift-leave-annual { background: #dfe6fd; color: #5b4cc4; }
.shift-leave-personal { background: #ffe8e0; color: #c0392b; }
.shift-leave-sick { background: #d5f5f5; color: #0a7e8c; }
.shift-overtime { background: #fff3bf; color: #8a6d14; font-weight: 700; }

/* 周末着色 */
.weekend-col { background: #fff8f0 !important; }

/* ============ 班次列表 ============ */
.shift-table { width: 100%; border-collapse: collapse; }
.shift-table th { text-align: left; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--bg); }
.shift-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.shift-table tbody tr:hover { background: #f8f9ff; }
.shift-th-no { width: 36px; text-align: center; }
.shift-td-no { text-align: center; color: var(--text-muted); font-size: 12px; }
.shift-name-badge { font-weight: 600; background: rgba(108,92,231,0.1); color: var(--primary); padding: 2px 10px; border-radius: 10px; font-size: 13px; }
.shift-td-actions { white-space: nowrap; text-align: right; }

/* ============ 班组列表 ============ */
.team-list { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }

.team-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; cursor: default; transition: all 0.2s;
}
.team-row:hover { background: #f8f9ff; border-color: var(--primary); }
.team-row.dragging { opacity: 0.4; background: #f0eefc; }
.team-row.drag-over { border-color: var(--primary); background: rgba(108,92,231,0.06); box-shadow: 0 0 0 2px rgba(108,92,231,0.2); }

.team-drag-handle { cursor: grab; font-size: 20px; color: var(--text-muted); letter-spacing: 1px; user-select: none; padding: 0 4px; line-height: 1; }
.team-drag-handle:active { cursor: grabbing; }

.team-row-order { font-size: 12px; color: var(--text-muted); min-width: 22px; text-align: center; }
.team-row-name { font-weight: 600; font-size: 15px; min-width: 80px; }
.team-row-count { font-size: 13px; color: var(--text-muted); min-width: 36px; }
.team-row-members { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.team-row-empty { font-size: 12px; color: #b2bec3; }
.team-tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(108,92,231,0.1); color: var(--primary); }
.team-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ============ 员工列表 ============ */
.employee-list { margin-top: 16px; }
.emp-table { width: 100%; border-collapse: collapse; }
.emp-table th { text-align: left; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--bg); }
.emp-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.emp-table tbody tr:hover { background: #f8f9ff; }
.emp-th-no { width: 40px; text-align: center; }
.emp-td-no { text-align: center; color: var(--text-muted); font-size: 12px; }
.emp-avatar-sm { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; margin-right: 8px; }
.emp-team-select { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fff; min-width: 100px; }
.emp-td-actions { white-space: nowrap; text-align: right; }

.batch-input { margin-top: 16px; }
.batch-input textarea { width: 100%; margin-bottom: 8px; }

/* ============ 班次列表 ============ */
.shift-form { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-group small { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.form-group .input { width: 160px; }

.shift-list { margin-top: 16px; }
.shift-card { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg); border-radius: 6px; border-left: 4px solid var(--primary); }
.shift-card .shift-info { display: flex; align-items: center; gap: 12px; }
.shift-card .shift-name { font-weight: 600; font-size: 15px; }
.shift-card .shift-time { font-size: 13px; color: var(--text-muted); }
.shift-card .shift-required { font-size: 12px; color: var(--primary); background: rgba(108,92,231,0.1); padding: 2px 8px; border-radius: 10px; }

/* ============ 个人排班 ============ */
.personal-info { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding: 16px; background: var(--bg); border-radius: 8px; }
.personal-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; flex-shrink: 0; }
.personal-name { font-size: 18px; font-weight: 600; }
.personal-stats { display: flex; gap: 16px; margin-left: auto; flex-wrap: wrap; }
.personal-stat { text-align: center; min-width: 50px; }
.personal-stat .val { font-size: 18px; font-weight: 700; color: var(--primary); }
.personal-stat .lbl { font-size: 11px; color: var(--text-muted); }

.personal-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-header { text-align: center; font-weight: 600; font-size: 13px; color: var(--text-muted); padding: 8px 0; }
.calendar-day { background: var(--bg); border-radius: 8px; padding: 10px 8px; text-align: center; min-height: 80px; display: flex; flex-direction: column; gap: 4px; }
.calendar-day .day-num { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.calendar-day .day-shift { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 10px; }
.calendar-day.today { border: 2px solid var(--primary); }
.calendar-day.empty { background: transparent; min-height: auto; }
.calendar-day.weekend { background: #fff8f0; }

/* ============ 弹窗 ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px; min-width: 320px; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.modal h3 { margin-bottom: 12px; }
.modal-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

/* ============ 时间浮层 ============ */
.time-tooltip {
    position: absolute;
    z-index: 200;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    padding: 2px;
    min-width: 180px;
    transform: translateX(-50%);
    pointer-events: auto;
}
.tooltip-content {
    padding: 12px 16px;
    text-align: center;
}
.tooltip-emp { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.tooltip-date { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.tooltip-shift { font-size: 16px; font-weight: 700; color: var(--text); }
.tooltip-time { font-size: 22px; font-weight: 700; color: var(--primary); margin-top: 4px; letter-spacing: 1px; }
.tooltip-edit { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: center; justify-content: center; }
.tooltip-select { font-size: 13px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }

/* ============ 导入弹窗 ============ */
.import-modal { min-width: 520px; max-width: 700px; }
.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
    background: #fafafa;
}
.import-dropzone:hover { border-color: var(--primary); background: #f0edff; }
.dropzone-icon { font-size: 36px; margin-bottom: 8px; }
.dropzone-text { font-size: 14px; color: var(--text-muted); }
.dropzone-hint { font-size: 12px; color: var(--text-muted); opacity: 0.7; margin-top: 6px; }

/* ============ 打印 ============ */
@media print {
    .sidebar, .header-actions, .btn, .input-group, .modal-overlay { display: none !important; }
    .main-content { padding: 0; }
    .tab-panel { display: block !important; }
    .panel-body { box-shadow: none; border: none; padding: 0; }
    .personal-calendar { gap: 3px; }
    .calendar-day { min-height: 60px; padding: 6px; }
    .table-wrapper { max-height: none; }
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; flex-shrink: 1; }
    .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
    .nav-item { padding: 8px 12px; font-size: 12px; border-left: none; border-bottom: 3px solid transparent; }
    .nav-item.active { border-left: none; border-bottom-color: var(--primary); }
    .main-content { padding: 12px; }
    .panel-body { padding: 12px; }
    .form-row { flex-direction: column; }
}

.text-muted { color: var(--text-muted); font-size: 13px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
