/* ============================================================
 * components.css - 通用组件样式
 * ============================================================ */

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 15px; border-radius: 7px; border: 1px solid transparent; font-size: 13px; font-weight: 500; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: var(--surface-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.link-btn { border: none; background: transparent; color: var(--primary); font-size: 12.5px; padding: 3px 6px; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: #dc2626; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }

/* 通用数据表 */
.datatable-host, .dt-toolbar-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.dt-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dt-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dt-count { color: var(--primary); font-weight: 500; font-size: 13px; margin-left: 4px; }
.dt-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dt-search { display: flex; align-items: center; height: 34px; border: 1px solid var(--border); border-radius: 7px; padding: 0 10px; background: var(--surface-2); min-width: 180px; }
.dt-search:focus-within { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-light); }
.search-ico { color: var(--text-3); font-size: 17px; margin-right: 6px; }
.dt-search input { border: none; outline: none; background: transparent; width: 100%; font-size: 13px; color: var(--text); }
.dt-filter { height: 34px; border: 1px solid var(--border); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--text); font-size: 12.5px; outline: none; }
.dt-table-wrap { overflow-x: auto; }
.dt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt-table th { background: var(--surface-2); color: var(--text-2); font-weight: 500; text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12.5px; }
.dt-table th[data-sort]:hover { color: var(--primary); }
.sort-ind { color: var(--primary); }
.dt-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; white-space: nowrap; }
.dt-table tbody tr:hover { background: var(--surface-2); }
.dt-table tbody tr:last-child td { border-bottom: none; }
.dt-empty { text-align: center; color: var(--text-3); padding: 50px 0 !important; }
.col-check { width: 36px; text-align: center; }
.col-actions { white-space: nowrap; text-align: right; }
.cell-truncate { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.dt-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); min-height: 50px; }
.dt-selbar { color: var(--text-2); font-size: 13px; }
.dt-pager { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dt-page-info { font-size: 12.5px; color: var(--text-2); }
.pg-btn { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; color: var(--text-2); font-size: 16px; }
.pg-btn:hover { border-color: var(--primary); color: var(--primary); }
.dt-page-jump { width: 52px; height: 30px; border: 1px solid var(--border); border-radius: 6px; text-align: center; background: var(--surface); color: var(--text); outline: none; }

/* 模态框 */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 200; opacity: 0; transition: opacity .2s; padding: 20px; }
.modal-overlay.modal-show { opacity: 1; }
.modal-overlay.modal-hide { opacity: 0; }
.modal { background: var(--surface); border-radius: 14px; width: 520px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.25); transform: translateY(10px); transition: transform .2s; }
.modal-show .modal { transform: translateY(0); }
.modal-wide { width: 720px; }
.modal-xwide { width: 1000px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close { border: none; background: transparent; font-size: 24px; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-shrink: 0; }
.confirm-msg { font-size: 14px; color: var(--text); line-height: 1.7; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-full { grid-column: 1 / -1; }
.form-span2 { grid-column: span 2; }
.form-item label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.form-item label .req { color: #dc2626; }
.form-item input, .form-item select, .form-item textarea { width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 8px 11px; background: var(--surface); color: var(--text); outline: none; font-size: 13px; transition: .15s; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-item textarea { min-height: 70px; resize: vertical; }
.form-item .input-error { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.1) !important; }

/* Toast */
.toast-box { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px; padding: 12px 16px; box-shadow: var(--shadow-md); font-size: 13px; color: var(--text); min-width: 220px; transition: .3s; }
.toast-out { opacity: 0; transform: translateX(20px); }
.toast-success { border-left-color: #16a34a; }
.toast-error { border-left-color: #dc2626; }
.toast-ico { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.toast-success .toast-ico { background: #16a34a; }
.toast-error .toast-ico { background: #dc2626; }

/* 主题选择 */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.theme-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; color: var(--text-2); transition: .15s; }
.theme-item:hover { border-color: var(--primary); }
.theme-item.active { border-color: var(--primary); color: var(--primary); font-weight: 500; background: var(--primary-light); }
.theme-swatch { width: 36px; height: 36px; border-radius: 8px; }

/* 用户菜单 */
.user-menu-list { display: flex; flex-direction: column; gap: 4px; }
.um-item { text-align: left; padding: 12px 14px; border: none; background: var(--surface-2); border-radius: 8px; color: var(--text); font-size: 13px; }
.um-item:hover { background: var(--primary-light); color: var(--primary); }
.about-box h3 { margin-bottom: 12px; }
.about-box p { color: var(--text-2); line-height: 1.9; font-size: 13px; }

/* 记录详情 */
.record-detail { display: flex; flex-direction: column; }
.rd-row { display: flex; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.rd-row:last-child { border-bottom: none; }
.rd-key { width: 150px; flex-shrink: 0; color: var(--text-2); }
.rd-val { flex: 1; color: var(--text); word-break: break-word; }
.err-box { padding: 40px; text-align: center; color: #dc2626; background: var(--surface); border-radius: var(--radius); }
.placeholder { padding: 60px; text-align: center; color: var(--text-3); background: var(--surface); border-radius: var(--radius); }
.empty-mini { padding: 30px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============ 身份切换 ============ */
.login-roles { display: flex; flex-wrap: wrap; gap: 6px; }
.login-role { flex: 1 1 auto; min-width: 62px; padding: 8px 4px; border: 1px solid #e2e8f0; background: #f8fafc; color: #475569; border-radius: 7px; font-size: 12px; transition: .15s; white-space: nowrap; }
.login-role:hover { border-color: var(--role-color); color: var(--role-color); }
.login-role.active { border-color: var(--role-color); color: #fff; background: var(--role-color); box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.role-chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid #2563eb44; background: #2563eb14; color: #2563eb; font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: .15s; }
.role-chip:hover { filter: brightness(.96); transform: translateY(-1px); }
.role-chip::before { content: '◈'; margin-right: 6px; font-size: 13px; }
[data-theme="dark"] .role-chip { color: #93c5fd; }

.role-switch-tip { padding: 12px 14px; background: var(--primary-light); color: var(--text-2); border-radius: 8px; font-size: 13px; line-height: 1.7; margin-bottom: 16px; }
.role-switch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.role-card { border: 2px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); transition: .18s; display: flex; flex-direction: column; }
.role-card:hover { border-color: var(--role-color); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.role-card.active { border-color: var(--role-color); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--role-color) 12%, transparent); }
.rc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rc-avatar { width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: var(--role-color); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; }
.rc-title b { font-size: 15px; color: var(--text); }
.rc-current { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 4px; background: var(--role-color); color: #fff; font-size: 10px; vertical-align: 2px; }
.rc-duty { font-size: 12px; color: var(--role-color); font-weight: 500; margin-bottom: 6px; }
.rc-desc { font-size: 12px; color: var(--text-2); line-height: 1.6; min-height: 58px; }
.rc-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.rc-meta span { font-size: 11px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 3px 7px; }
.rc-btn { width: 100%; margin-top: auto; }
.rc-btn:disabled { opacity: .6; cursor: default; }

.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 4px 4px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.umh-avatar { width: 40px; height: 40px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.user-menu-head b { display: block; font-size: 14px; }
.user-menu-head small { display: block; color: var(--text-2); font-size: 12px; margin-top: 2px; }
.um-primary { background: var(--primary-light) !important; color: var(--primary) !important; font-weight: 500; }

.no-permit { padding: 64px 20px; text-align: center; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }
.no-permit .np-ico { font-size: 52px; color: var(--text-3); line-height: 1; margin-bottom: 16px; }
.no-permit h3 { font-size: 17px; margin-bottom: 8px; }
.no-permit p { color: var(--text-2); font-size: 13px; line-height: 1.8; margin-bottom: 20px; }
.no-permit .btn { margin: 0 5px; }

@media (max-width: 720px) {
  .role-switch-grid { grid-template-columns: 1fr; }
  .rc-desc { min-height: 0; }
  .role-chip { display: none; }
}
