Files
hr-position-system/styles/components.css
DonaldFang 方士碩 8069f1b628 feat: 實作三個錦囊 AI 功能
- 新增 AI 錦囊 CSS 樣式到 components.css
- 創建 js/ai-bags.js 模組,包含:
  * 5個模組各3個錦囊的預設 prompt 模板
  * executeAIBag() - 執行 AI 生成並填充表單
  * editBagPrompt() - 編輯自定義 prompt
  * LocalStorage 管理自定義 prompt
- 更新 index.html:
  * 替換 5 處 AI 按鈕為三個錦囊(崗位基礎、招聘要求、職務、部門職責、崗位描述)
  * 新增 Prompt 編輯模態框
- 更新 main.js 引入 ai-bags.js 並初始化
- 新增設計文檔:三個錦囊設計.md
- 新增欄位對照文檔:表單欄位清單.md、更新欄位名稱.md、ID重命名對照表.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 01:19:54 +08:00

643 lines
12 KiB
CSS

/**
* Components Styles - 元件樣式
* 包含按鈕、表單、卡片、頁籤、彈窗、Toast 等可重用元件
*/
/* ==================== Tabs ==================== */
.tabs {
display: flex;
background: #f8fafc;
border-bottom: 2px solid var(--border);
}
.tab-btn {
padding: 16px 32px;
border: none;
background: transparent;
font-family: inherit;
font-size: 0.95rem;
font-weight: 500;
color: var(--text-secondary);
cursor: pointer;
position: relative;
transition: all 0.3s ease;
}
.tab-btn:hover {
color: var(--primary);
background: rgba(26, 82, 118, 0.05);
}
.tab-btn.active {
color: var(--primary);
background: var(--bg-card);
}
.tab-btn.active::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
right: 0;
height: 3px;
background: var(--primary);
border-radius: 2px 2px 0 0;
}
.tab-content {
display: none;
padding: 28px;
animation: fadeIn 0.3s ease;
}
.tab-content.active {
display: block;
}
/* ==================== Form Elements ==================== */
.form-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px 32px;
}
.form-grid.three-cols {
grid-template-columns: repeat(3, 1fr);
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-group.full-width {
grid-column: 1 / -1;
}
.form-group label {
font-size: 0.875rem;
font-weight: 500;
color: var(--text-secondary);
display: flex;
align-items: center;
gap: 4px;
}
.form-group label .required {
color: var(--danger);
font-weight: 600;
}
.input-wrapper {
display: flex;
gap: 8px;
align-items: center;
}
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
width: 100%;
padding: 10px 14px;
border: 1.5px solid var(--border);
border-radius: 6px;
font-family: inherit;
font-size: 0.9rem;
color: var(--text-primary);
background: #fafbfc;
transition: all 0.2s ease;
}
input:focus,
select:focus,
textarea:focus {
outline: none;
border-color: var(--primary-light);
background: #ffffff;
box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}
input:read-only {
background: #f0f3f5;
color: var(--text-secondary);
cursor: default;
}
textarea {
min-height: 100px;
resize: vertical;
}
select {
cursor: pointer;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235d6d7e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
padding-right: 36px;
}
/* ==================== Buttons ==================== */
.btn {
padding: 12px 24px;
border: none;
border-radius: 6px;
font-family: inherit;
font-size: 0.9rem;
font-weight: 500;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.2s ease;
}
.btn-primary {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
color: white;
box-shadow: 0 2px 8px rgba(26, 82, 118, 0.3);
}
.btn-primary:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(26, 82, 118, 0.4);
}
.btn-secondary {
background: white;
color: var(--primary);
border: 1.5px solid var(--primary);
}
.btn-secondary:hover {
background: rgba(26, 82, 118, 0.05);
}
.btn-cancel {
background: #f0f3f5;
color: var(--text-secondary);
}
.btn-cancel:hover {
background: #e5e9ec;
}
.btn svg {
width: 18px;
height: 18px;
fill: currentColor;
}
.btn-lookup {
padding: 10px 16px;
border: 1.5px solid var(--border);
border-radius: 6px;
background: #f8fafc;
color: var(--text-secondary);
font-size: 0.85rem;
cursor: pointer;
transition: all 0.2s ease;
white-space: nowrap;
}
.btn-lookup:hover {
background: var(--primary);
color: white;
border-color: var(--primary);
}
.btn-icon {
width: 38px;
height: 38px;
border: 1.5px solid var(--border);
border-radius: 6px;
background: #f8fafc;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.btn-icon:hover {
background: var(--primary);
color: white;
border-color: var(--primary);
}
.btn-icon svg {
width: 18px;
height: 18px;
fill: currentColor;
}
.nav-buttons {
display: flex;
gap: 8px;
}
.nav-btn {
width: 36px;
height: 36px;
border: 1.5px solid var(--border);
border-radius: 6px;
background: white;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.nav-btn:hover {
border-color: var(--primary);
color: var(--primary);
}
.nav-btn svg {
width: 16px;
height: 16px;
fill: currentColor;
}
/* ==================== AI Bags (Three Fortune Bags) ==================== */
.ai-bags-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 24px;
}
.ai-bag {
position: relative;
padding: 20px;
background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
border-radius: var(--radius);
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
text-align: center;
}
.ai-bag:hover {
transform: translateY(-4px);
box-shadow: 0 6px 20px rgba(155, 89, 182, 0.5);
}
.ai-bag:active {
transform: translateY(-2px);
}
.ai-bag .bag-icon {
font-size: 2rem;
margin-bottom: 8px;
}
.ai-bag .bag-title {
color: white;
font-weight: 600;
font-size: 0.95rem;
margin-bottom: 4px;
}
.ai-bag .bag-subtitle {
color: rgba(255, 255, 255, 0.8);
font-size: 0.75rem;
margin-top: 4px;
}
.ai-bag .bag-edit-btn {
position: absolute;
top: 8px;
right: 8px;
background: rgba(255, 255, 255, 0.2);
border: none;
border-radius: 4px;
padding: 4px 8px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.2s ease;
line-height: 1;
}
.ai-bag .bag-edit-btn:hover {
background: rgba(255, 255, 255, 0.3);
transform: scale(1.1);
}
.ai-bag.loading {
pointer-events: none;
opacity: 0.7;
}
.ai-bag .spinner {
width: 20px;
height: 20px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin: 8px auto;
}
/* ==================== Old AI Button (Deprecated) ==================== */
.ai-generate-btn {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
margin-bottom: 24px;
background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
color: white;
border: none;
border-radius: var(--radius);
font-family: inherit;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
transition: all 0.3s ease;
}
.ai-generate-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}
.ai-generate-btn:disabled {
opacity: 0.7;
cursor: not-allowed;
transform: none;
}
.ai-generate-btn svg {
width: 20px;
height: 20px;
fill: currentColor;
}
.ai-generate-btn .spinner {
width: 20px;
height: 20px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
/* ==================== Form Actions ==================== */
.form-actions {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 28px;
background: #f8fafc;
border-top: 1px solid var(--border);
}
.action-buttons {
display: flex;
gap: 12px;
}
/* ==================== Toggle Switch ==================== */
.toggle-group {
display: flex;
align-items: center;
gap: 12px;
}
.toggle-switch {
position: relative;
width: 52px;
height: 28px;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.toggle-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: 0.3s;
border-radius: 28px;
}
.toggle-slider:before {
position: absolute;
content: "";
height: 22px;
width: 22px;
left: 3px;
bottom: 3px;
background-color: white;
transition: 0.3s;
border-radius: 50%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked + .toggle-slider {
background-color: var(--success);
}
.toggle-switch input:checked + .toggle-slider:before {
transform: translateX(24px);
}
.toggle-label {
font-size: 0.9rem;
color: var(--text-secondary);
}
/* ==================== Toast Notification ==================== */
.toast {
position: fixed;
top: 24px;
right: 24px;
padding: 16px 24px;
background: var(--success);
color: white;
border-radius: var(--radius);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
display: flex;
align-items: center;
gap: 12px;
transform: translateX(120%);
transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 1000;
}
.toast.show {
transform: translateX(0);
}
.toast svg {
width: 24px;
height: 24px;
fill: currentColor;
}
/* ==================== Modal ==================== */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
display: none;
align-items: center;
justify-content: center;
z-index: 100;
backdrop-filter: blur(4px);
}
.modal-overlay.show {
display: flex;
}
.modal {
background: white;
border-radius: var(--radius);
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
width: 90%;
max-width: 500px;
animation: modalIn 0.3s ease;
}
.modal-header {
padding: 20px 24px;
border-bottom: 1px solid var(--border);
display: flex;
justify-content: space-between;
align-items: center;
}
.modal-header h3 {
font-size: 1.1rem;
font-weight: 600;
}
.modal-close {
width: 32px;
height: 32px;
border: none;
background: #f0f3f5;
border-radius: 6px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
}
.modal-close:hover {
background: var(--danger);
color: white;
}
.modal-body {
padding: 24px;
}
.modal-footer {
padding: 16px 24px;
border-top: 1px solid var(--border);
display: flex;
justify-content: flex-end;
gap: 12px;
}
/* ==================== Checkbox Group ==================== */
.checkbox-group {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
}
.checkbox-item {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border: 1.5px solid var(--border);
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
}
.checkbox-item:hover {
border-color: var(--primary-light);
background: rgba(41, 128, 185, 0.05);
}
.checkbox-item input {
width: 18px;
height: 18px;
accent-color: var(--primary);
}
.checkbox-item label {
cursor: pointer;
font-size: 0.9rem;
}
/* ==================== Special Fields ==================== */
.confidential-field {
position: relative;
}
.confidential-field input {
padding-left: 32px;
}
.confidential-field::before {
content: '🔒';
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
font-size: 14px;
}
.numbered-textarea {
font-family: inherit;
line-height: 1.8;
}
/* ==================== Data Preview ==================== */
.data-preview {
margin-top: 24px;
padding: 20px;
background: #f8fafc;
border-radius: var(--radius);
border: 1px solid var(--border);
}
.data-preview h4 {
font-size: 0.9rem;
color: var(--text-secondary);
margin-bottom: 12px;
}
.data-preview pre {
font-family: 'Monaco', 'Consolas', monospace;
font-size: 0.8rem;
background: #2c3e50;
color: #ecf0f1;
padding: 16px;
border-radius: 6px;
overflow-x: auto;
max-height: 300px;
}