/**
 * 招聘测评与大五人格系统 - 统一设计系统 Tokens 与公共样式体系
 * 规范遵循: ui-redesign-prompt.md (Linear / Stripe 极简克制风)
 */

:root {
  /* 颜色 (亮色模式) */
  --bg-page:        #F5F6F8;   /* 页面底色 */
  --bg-surface:     #FFFFFF;   /* 卡片/面板/侧栏 */
  --bg-subtle:      #F3F4F6;   /* hover、表头、输入禁用 */
  --border:         #E5E7EB;   /* 默认边框 */
  --border-strong:  #D1D5DB;   /* 输入框边框 */
  --text-primary:   #111827;   /* 主文字 */
  --text-secondary: #4B5563;   /* 次要文字 */
  --text-muted:     #5B6472;   /* 辅助说明文字 (对比度 >= 4.5:1) */

  /* 品牌色 (单一蓝色，禁止彩色渐变与发光阴影) */
  --brand:          #2563EB;   /* 主色 */
  --brand-hover:    #1D4ED8;   /* 悬停 */
  --brand-subtle:   #F0F6FF;   /* 选中底、信息提示底 */
  --brand-border:   #CFE0FF;   /* 品牌细边框 */
  --brand-text:     #1E3A8A;   /* 品牌深色文字 */

  /* 状态语义色 */
  --success:        #15803D;
  --success-subtle: #F0FDF4;
  --success-border: #BBF7D0;
  --success-text:   #14532D;

  --warning:        #B45309;
  --warning-subtle: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-text:   #78350F;

  --danger:         #B91C1C;
  --danger-subtle:  #FEF2F2;
  --danger-border:  #FECACA;
  --danger-text:    #7F1D1D;

  /* 圆角规范 */
  --r-sm: 6px;   /* 标签页、小按钮、tag */
  --r-md: 8px;   /* 按钮、输入框、提示条 */
  --r-lg: 12px;  /* 卡片、面板、对话框 (圆形仅用于头像与 Radio) */

  /* 阴影规范 (仅两档浮层阴影，普通卡片无阴影) */
  --shadow-pop:    0 4px 16px rgba(17, 24, 39, 0.08);
  --shadow-drawer: 0 8px 32px rgba(17, 24, 39, 0.16);

  /* 动效规范 */
  --transition: 140ms ease;

  /* 五大特质维度基准色 (冷静中性，杜绝彩虹色) */
  --dim-o: #2563EB;
  --dim-c: #0D9488;
  --dim-e: #D97706;
  --dim-a: #059669;
  --dim-n: #7C3AED;

  /* 历史测试兼容性别名 (保持 pytest 100% 通过) */
  --jade:           var(--brand);
  --jade-hover:     var(--brand-hover);
  --jade-light:     var(--brand-subtle);
  --jade-border:    var(--brand-border);
  --paper:          var(--bg-page);
  --card:           var(--bg-surface);
  --card-alt:       var(--bg-subtle);
  --line:           var(--border);
  --line-strong:    var(--border-strong);
  --ink:            var(--text-primary);
  --ink-secondary:  var(--text-secondary);
  --mute:           var(--text-muted);
  --crimson:        var(--danger);
  --crimson-bg:     var(--danger-subtle);
  --crimson-border: var(--danger-border);
  --amber:          var(--warning);
  --amber-bg:       var(--warning-subtle);
  --amber-border:   var(--warning-border);
  --pine:           var(--success);
  --pine-bg:        var(--success-subtle);
  --pine-border:    var(--success-border);
}

/* 颜色 (深色模式) */
.dark {
  --bg-page:        #0B0F17;
  --bg-surface:     #121826;
  --bg-subtle:      #1C2436;
  --border:         #263043;
  --border-strong:  #37435B;
  --text-primary:   #E5E7EB;
  --text-secondary: #9AA4B2;
  --text-muted:     #9AA4B2;

  --brand:          #4C8DFF;
  --brand-hover:    #3B82F6;
  --brand-subtle:   #172554;
  --brand-border:   #1E40AF;
  --brand-text:     #93C5FD;

  --success:        #22C55E;
  --success-subtle: #052E16;
  --success-border: #166534;
  --success-text:   #86EFAC;

  --warning:        #F59E0B;
  --warning-subtle: #451A03;
  --warning-border: #78350F;
  --warning-text:   #FCD34D;

  --danger:         #EF4444;
  --danger-subtle:  #450A0A;
  --danger-border:  #7F1D1D;
  --danger-text:    #FCA5A5;

  --shadow-pop:    0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-drawer: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* 全局盒模型重置 (消除 padding 与 border 导致的容器与按钮超界溢出) */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 全局基准与字体栈 (严禁外链字体) */
html, body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 22px;
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 数字列表格等宽支持 */
.tabular-nums, [data-num] {
  font-variant-numeric: tabular-nums;
}

/* 消除旧版本黄色网格与背景杂纹 */
.grain {
  background-image: none !important;
}

/* 键盘可访问性焦点环 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 尊重减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 链接通用规范 */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--brand);
}

/* 排版层级规范 */
h1, .h1 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
@media (max-width: 640px) {
  h1, .h1 { font-size: 22px; line-height: 30px; }
}

h2, .h2 {
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

h3, .h3 {
  font-size: 15px;
  line-height: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

p {
  margin: 0;
}

.text-muted {
  color: var(--text-muted);
}
.text-secondary {
  color: var(--text-secondary);
}

/* ==========================================================================
   通用组件库规范 (Buttons, Inputs, Cards, Alerts, Tags, Tables, RadioCards)
   ========================================================================== */

/* 1. Button 按钮体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color var(--transition), border-color var(--transition), opacity var(--transition);
  text-decoration: none;
}
.btn:active:not(:disabled) {
  opacity: 0.92;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4 !important;
}

.btn-primary {
  background-color: var(--brand);
  color: #FFFFFF !important;
  border-color: var(--brand);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-hover);
  border-color: var(--brand-hover);
  color: #FFFFFF !important;
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-secondary) !important;
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-primary) !important;
  border-color: var(--border-strong);
}

.btn-text {
  background-color: transparent;
  color: var(--brand) !important;
  border-color: transparent;
  padding: 0 8px;
}
.btn-text:hover:not(:disabled) {
  background-color: var(--brand-subtle);
}

.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF !important;
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
}

/* 2. Input / Select / Textarea 表单控件 (移动端 16px 防缩放) */
.input, .identity-field, select.input, textarea.input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
@media (max-width: 768px) {
  .input, .identity-field, select.input, textarea.input {
    height: 44px;
    font-size: 16px; /* 防止 iOS 触发页面自动缩放 */
  }
}
.input:focus, .identity-field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}
.input::placeholder, .identity-field::placeholder {
  color: var(--text-muted);
}
.input:disabled, .identity-field:disabled {
  background-color: var(--bg-subtle);
  cursor: not-allowed;
  opacity: 0.7;
}

.input-error {
  border-color: var(--danger) !important;
}
.field-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 4px;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.field-label .optional {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

/* 3. Card 卡片容器 (无彩色发光阴影，最多嵌套一层) */
.card, .bg-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: none;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body {
  padding: 20px;
}
@media (min-width: 640px) {
  .card-header { padding: 20px 24px; }
  .card-body { padding: 24px; }
}

/* 4. Alert 信息提示条 (替换彩色胶囊) */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 20px;
}
.alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.alert-info {
  background-color: var(--brand-subtle);
  border-color: var(--brand-border);
  color: var(--brand-text);
}
.alert-info .alert-icon { color: var(--brand); }

.alert-success {
  background-color: var(--success-subtle);
  border-color: var(--success-border);
  color: var(--success-text);
}
.alert-success .alert-icon { color: var(--success); }

.alert-warning {
  background-color: var(--warning-subtle);
  border-color: var(--warning-border);
  color: var(--warning-text);
}
.alert-warning .alert-icon { color: var(--warning); }

.alert-danger {
  background-color: var(--danger-subtle);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.alert-danger .alert-icon { color: var(--danger); }

/* 5. Tag 标签 (仅在表格/详情中表征状态，小圆角) */
.tag, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-dot, .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tag-success, .badge-ok {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border-color: var(--success-border);
}
.tag-success .tag-dot, .badge-ok .badge-dot { background-color: var(--success); }

.tag-warning, .badge-watch {
  background-color: var(--warning-subtle);
  color: var(--warning-text);
  border-color: var(--warning-border);
}
.tag-warning .tag-dot, .badge-watch .badge-dot { background-color: var(--warning); }

.tag-danger, .badge-high {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border-color: var(--danger-border);
}
.tag-danger .tag-dot, .badge-high .badge-dot { background-color: var(--danger); }

.tag-neutral, .badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border);
}
.tag-neutral .tag-dot, .badge-neutral .badge-dot { background-color: var(--text-muted); }

/* 6. Tabs / 分段器 (32px 高度) */
.tabs-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}
.tab-btn.active, .tab-btn[aria-selected="true"] {
  color: var(--brand);
  background-color: var(--brand-subtle);
  font-weight: 600;
}

/* 7. 选择卡 Radio Card (岗位单选，右上角圆形单选点) */
.radio-card, .pos-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  outline: none;
  transition: border-color var(--transition), background-color var(--transition);
}
.radio-card:hover, .pos-card:hover {
  border-color: var(--border-strong);
}
.radio-card:focus-visible, .pos-card:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}
.radio-card[aria-pressed="true"], .pos-card[aria-pressed="true"],
.radio-card[aria-checked="true"], .pos-card[aria-checked="true"] {
  border-color: var(--brand) !important;
  background-color: var(--brand-subtle) !important;
  box-shadow: 0 0 0 1px var(--brand);
}

/* 8. Table 表格 */
.table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}
.table th {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  height: 48px;
  padding: 0 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover td {
  background-color: var(--bg-subtle);
}

@media (max-width: 640px) {
  .table-container {
    border: none !important;
    background: transparent !important;
  }
  .table thead {
    display: none !important;
  }
  .table, .table tbody, .table tr, .table td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .table tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background-color: var(--bg-surface);
  }
  .table tr:last-child {
    margin-bottom: 0;
  }
  .table td {
    height: auto !important;
    padding: 4px 0 !important;
    border-bottom: none !important;
  }
}

/* 深浅色模式专用元素显隐 */
.dark .dark-hide { display: none !important; }
.dark .dark-show { display: inline-flex !important; }
:not(.dark) .dark-show { display: none !important; }
:not(.dark) .dark-hide { display: inline-flex !important; }

/* 9. 浮动与吸底操作栏 */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: var(--shadow-pop);
}

/* 10. Toast 轻量通知 */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 18px;
  background-color: var(--text-primary);
  color: var(--bg-surface);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: toastFadeDown 0.16s ease forwards;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toast-success {
  background-color: var(--success);
  color: #FFFFFF;
}
@keyframes toastFadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 11. Avatar 头像 */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* 12. 进度条 (细条，无发光) */
.progress-container {
  height: 4px;
  background-color: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background-color: var(--brand);
  border-radius: 2px;
  transition: width 0.2s ease;
}

/* 13. 李克特量表单选 (候选人端) */
.likert-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--transition);
}
.likert-btn:hover:not([aria-pressed="true"]) {
  border-color: var(--brand);
  background-color: var(--bg-subtle);
}
.likert-btn[aria-pressed="true"] {
  background-color: var(--brand);
  color: #FFFFFF;
  border-color: var(--brand);
  font-weight: 600;
}

/* 14. 拖拽上传区域 */
.dropzone-box {
  border: 1px dashed var(--border-strong);
  background-color: var(--bg-subtle);
  border-radius: var(--r-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background-color var(--transition);
}
.dropzone-box:hover, .dropzone-box.dropzone-active {
  border-color: var(--brand);
  background-color: var(--brand-subtle);
}

/* 15. HR 侧栏与 App Shell 布局 */
.hr-app-layout {
  display: flex;
  min-height: 100dvh;
  background-color: var(--bg-page);
}
.hr-sidebar {
  width: 232px;
  flex-shrink: 0;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 30;
}
.app-topbar {
  height: 56px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.hr-main-container {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.hr-nav-item:hover {
  background-color: var(--bg-subtle) !important;
  color: var(--text-primary) !important;
}
.hr-nav-item.active, .hr-nav-item[aria-current="page"] {
  background-color: var(--brand-subtle) !important;
  color: var(--brand) !important;
  font-weight: 600;
}

/* 16. 岗位选择卡网格与单选指示 */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.pos-card[aria-pressed="true"] .radio-dot {
  border-color: var(--brand);
  background-color: var(--brand);
}
.pos-card[aria-pressed="true"] .radio-dot svg {
  display: block !important;
}

/* 17. 响应式布局断点 */
@media (max-width: 1023px) {
  .hr-sidebar { display: none !important; }
  .hr-drawer-btn { display: inline-flex !important; }
  .hr-main-container { padding: 24px 16px 64px !important; }
  .hire-summary-card { display: none !important; }
  .mobile-bottom-bar { display: block !important; }
}
@media (max-width: 640px) {
  .app-topbar { padding: 0 16px !important; }
  .hr-main-container { padding: 16px 12px 80px !important; }
  .pos-grid { grid-template-columns: 1fr !important; }
}

/* 打印友好样式 */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .no-print, header, .app-sidebar, .app-topbar, .mobile-bottom-bar, footer {
    display: none !important;
  }
  .card {
    border: 1px solid #CCCCCC !important;
    break-inside: avoid;
  }
}
