/* Registry 配置管理中心样式 - 参考 Windows 注册表编辑器风格 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  color: #1e1e1e;
  background: #f0f0f0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部工具栏 */

.app-title {
  font-weight: 600;
  font-size: 14px;
  color: #003a70;
}

.toolbar-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #adadad;
  border-radius: 3px;
  background: #fff;
  font-size: 13px;
  min-width: 180px;
}

.toolbar-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #adadad;
  border-radius: 3px;
  background: linear-gradient(to bottom, #fdfdfd, #e8e8e8);
  cursor: pointer;
  font-size: 12px;
}

.toolbar-btn:hover {
  background: linear-gradient(to bottom, #eaf3fb, #d6e9f9);
  border-color: #5b9bd5;
}

.mode-label {
  color: #555;
}

.mode-switcher {
  display: flex;
  border: 1px solid #adadad;
  border-radius: 3px;
  overflow: hidden;
}

.mode-btn {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-right: 1px solid #adadad;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.mode-btn:last-child {
  border-right: none;
}

.mode-btn.active {
  background: #0078d4;
  color: #fff;
  font-weight: 600;
}

.mode-btn:not(.active):hover {
  background: #e5f1fb;
}

/* 主内容区 */
.main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 左侧树形导航 */
.tree-panel {
  width: 320px;
  min-width: 180px;
  background: #fff;
  border-right: 1px solid #c0c0c0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 10px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  color: #555;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #666;
}

.tree-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-header-actions .icon-btn {
  padding: 0 4px;
  border-radius: 3px;
}

.tree-header-actions .icon-btn:hover {
  background: #e5f1fb;
  color: #0078d4;
}

.tree-content {
  flex: 1;
  overflow: auto;
  padding: 4px 0;
}

.tree-empty {
  padding: 20px;
  text-align: center;
  color: #999;
}

/* 树节点 */
.tree-node {
  user-select: none;
}

.tree-node-label {
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 4px;
  cursor: pointer;
  white-space: nowrap;
}

.tree-node-label:hover {
  background: #e5f1fb;
}

.tree-node-label.selected {
  background: #cce8ff;
}

.tree-toggle {
  width: 16px;
  display: inline-block;
  text-align: center;
  color: #666;
  font-size: 10px;
}

.tree-icon {
  margin-right: 4px;
}

.tree-children {
  padding-left: 16px;
}

.tree-children.collapsed {
  display: none;
}

/* 分隔条 */
.resizer {
  width: 4px;
  background: #e0e0e0;
  cursor: col-resize;
  flex-shrink: 0;
}

.resizer:hover {
  background: #5b9bd5;
}

/* 右侧详情面板 */
.detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 4px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
}

#detail-path {
  font-family: Consolas, monospace;
  color: #003a70;
  font-size: 12px;
}

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

.detail-table-wrapper {
  flex: 1;
  overflow: auto;
}

/* 配置表格 */
.config-table {
  width: 100%;
  border-collapse: collapse;
}

.config-table th {
  position: sticky;
  top: 0;
  background: #f0f0f0;
  border-bottom: 1px solid #c0c0c0;
  border-right: 1px solid #e0e0e0;
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: #555;
}

.config-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f0;
  border-right: 1px solid #f5f5f5;
  vertical-align: top;
}

.config-table tr:hover td {
  background: #f8fbff;
}

.col-key { width: 18%; }
.col-value { width: 24%; }
.col-type { width: 8%; }
.col-status { width: 12%; }
.col-desc { width: 26%; }
.col-actions { width: 12%; }

.config-key-cell {
  font-family: Consolas, monospace;
  color: #0451a5;
}

.config-value-cell {
  font-family: Consolas, monospace;
  word-break: break-all;
}

.value-truncated {
  display: inline;
}

.value-more-btn {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  height: 20px;
  line-height: 20px;
  border: 1px solid #5b9bd5;
  border-radius: 10px;
  background: #e5f1fb;
  color: #0078d4;
  font-size: 11px;
  cursor: pointer;
  vertical-align: middle;
}

.value-more-btn:hover {
  background: #d0e5f7;
}

.type-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: #e5f1fb;
  color: #0078d4;
}

/* 状态徽标：必填 / 存在 / 不存在 */
.config-status-cell {
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-right: 4px;
  border: 1px solid transparent;
}

.badge-required {
  background: #fff3e0;
  color: #b45309;
  border-color: #f0c98f;
}

.badge-exists {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #b5dfb8;
}

.badge-missing {
  background: #fdecea;
  color: #c62828;
  border-color: #f2b8b5;
}

/* 不存在（未生效）的配置行 */
.row-not-exists td {
  color: #999;
  background: #fafafa;
}

.row-not-exists .config-key-cell {
  color: #999;
  text-decoration: line-through;
}

.value-missing {
  color: #bbb;
}

/* 默认值回退展示（配置值为空时） */
.value-default {
  color: #8a8a8a;
  font-style: italic;
}

.empty-row td {
  text-align: center;
  color: #999;
  padding: 30px;
}

.row-btn {
  border: 1px solid #adadad;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 11px;
  margin-right: 4px;
}

.row-btn:hover {
  background: #e5f1fb;
}

.row-btn.danger:hover {
  background: #fde7e9;
  border-color: #d13438;
  color: #d13438;
}

/* 状态栏 */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  padding: 0 12px;
  background: #f0f0f0;
  border-top: 1px solid #c0c0c0;
  font-size: 12px;
  color: #666;
  flex-shrink: 0;
}

.statusbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.statusbar-version {
  white-space: nowrap;
  font-family: Consolas, monospace;
  color: #888;
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  width: 480px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* 右侧抽屉：配置项编辑/查看使用，占屏幕至少 60% */
.drawer-overlay {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
}

.drawer-overlay .modal {
  width: 68vw;
  max-width: none;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  animation: drawer-in 0.22s ease-out;
}

.drawer-overlay .modal-body {
  flex: 1;
  max-height: none;
  overflow-y: auto;
}

/* 抽屉内表单内容限宽，避免超宽屏下字段过度拉伸 */
.drawer-overlay .modal-body .form-group,
.drawer-overlay .modal-body .form-row {
  max-width: 780px;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.modal-sm {
  width: 360px;
}

/* 宽模态框：访问记录等表格型内容，宽度至少占屏幕的 70% */
.modal-wide {
  width: min(86vw, 1720px);
  max-width: none;
  display: flex;
  flex-direction: column;
}

.modal-wide .modal-body {
  max-height: 70vh;
}

/* 访问记录：过滤栏与分页 */
.audit-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.audit-filters input,
.audit-filters select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #adadad;
  border-radius: 3px;
  font-size: 13px;
  background: #fff;
}

.audit-filters #audit-filter-key {
  min-width: 180px;
}

.audit-filters input[type="datetime-local"] {
  padding: 0 4px;
  font-size: 12px;
}

.audit-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: #555;
}

.audit-pagination .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.audit-pagination select {
  height: 26px;
  border: 1px solid #adadad;
  border-radius: 3px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
  font-size: 15px;
  color: #003a70;
}

.modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: #999;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 16px;
  max-height: 60vh;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
}

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

.form-row {
  display: flex;
  gap: 12px;
}

.form-half {
  flex: 1;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: #444;
  font-size: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #adadad;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
}

.required {
  color: #d13438;
}

.hint {
  font-weight: normal;
  color: #999;
  font-size: 11px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal !important;
  cursor: pointer;
}

.checkbox-label input {
  width: auto !important;
}

/* 按钮 */
.btn {
  height: 30px;
  padding: 0 16px;
  border-radius: 3px;
  border: 1px solid #adadad;
  cursor: pointer;
  font-size: 13px;
}

.btn-primary {
  background: #0078d4;
  color: #fff;
  border-color: #0078d4;
}

.btn-primary:hover {
  background: #106ebe;
}

.btn-secondary {
  background: #fff;
}

.btn-secondary:hover {
  background: #f0f0f0;
}

.btn-danger {
  background: #d13438;
  color: #fff;
  border-color: #d13438;
}

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

/* 只读模式下隐藏操作按钮 */
body.mode-readonly .detail-actions #btn-add-config,
body.mode-readonly .row-btn:not(.view) {
  display: none;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toast-success { background: #107c10; }
.toast-error { background: #d13438; }
.toast-info { background: #0078d4; }

/* ===== 标题栏（与工具栏分离） ===== */
.titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 40px;
  padding: 0 14px;
  background: linear-gradient(to bottom, #0a4a86, #003a70);
  color: #fff;
  flex-shrink: 0;
}

.titlebar .app-title {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}

.titlebar .current-project {
  font-size: 13px;
  color: #cfe3f7;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== 标题栏右侧：用户信息与入口 ===== */
.titlebar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.titlebar-user {
  color: #e8f1fb;
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.role-badge.admin {
  background: #ffb900;
  border-color: #ffd666;
  color: #4a3200;
  font-weight: 600;
}

.titlebar-link {
  color: #cfe3f7;
  text-decoration: none;
  cursor: pointer;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.titlebar-link:hover {
  color: #fff;
  text-decoration: underline;
}

/* ===== 工具栏（分组处理） ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 6px 4px;
  min-height: 46px;
  padding: 5px 8px;
  background: linear-gradient(to bottom, #fdfdfd, #eaeaea);
  border-bottom: 1px solid #c0c0c0;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-right: 1px solid #d5d5d5;
  white-space: nowrap;
}

.tool-group:last-child {
  border-right: none;
}

.tool-group .group-label {
  font-size: 11px;
  color: #888;
}

/* ===== 维度栏 ===== */
.dimension-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 34px;
  padding: 4px 14px;
  background: #eef4fb;
  border-bottom: 1px solid #d0dced;
  flex-shrink: 0;
  flex-wrap: wrap;
}


.dim-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dim-item .dim-name {
  font-weight: 600;
  color: #0a4a86;
  font-size: 12px;
}

.dim-select {
  height: 26px;
  padding: 0 6px;
  border: 1px solid #adadad;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
}

.dim-mapping {
  font-size: 11px;
  color: #7a8ba0;
}

/* ===== 配置导航地址栏 ===== */
.address-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #e0e0e0;
}

.address-icon {
  font-size: 13px;
}

.address-input {
  flex: 1;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #adadad;
  border-radius: 3px;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.addr-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #adadad;
  border-radius: 3px;
  background: linear-gradient(to bottom, #fdfdfd, #e8e8e8);
  cursor: pointer;
  font-size: 12px;
}

.addr-btn:hover {
  background: linear-gradient(to bottom, #eaf3fb, #d6e9f9);
  border-color: #5b9bd5;
}

/* ===== 新建项目维度映射行 ===== */
.dim-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.dim-config-row .checkbox-label {
  min-width: 60px;
}

.dim-config-row .map-name {
  min-width: 60px;
  font-weight: 600;
  color: #444;
  font-size: 12px;
}

.mapping-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #adadad;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
}

/* ===== 树节点：值项与目录项区分 ===== */
.tree-node-label.is-leaf .tree-icon {
  opacity: 0.9;
}
