/* ============================================================
   申小记 - 可复用组件库
   所有页面共享的 UI 组件样式，通过 class 直接使用。

   组件清单：
   - 按钮：.btn .btn-primary .btn-secondary .btn-danger .btn-code
   - 表单：.input-field .form-field .form-field-err
   - 标签：.chip .chip.sel .chip.disabled
   - 弹窗：.modal-overlay .modal-content .modal-actions
   - 提示：.toast
   - 顶栏：.app-title .user-menu-trigger .user-dropdown .dropdown-item
   - 添加按钮：.btn-add .btn-save-config
   ============================================================ */

/* ==================== 按钮组件 ==================== */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: #3a5a95;
}

.btn-primary:disabled {
  background: #B7C1D6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #F2F3F4;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  border-color: var(--brand);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-code {
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-code:disabled {
  border-color: var(--line);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.btn-add {
  border: 1px dashed var(--line);
  background: #FAFBFC;
  color: var(--ink-soft);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-add:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* ==================== 表单组件 ==================== */
.input-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
}

.input-field:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  font-weight: 600;
}

.form-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
}

.form-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-field.invalid input {
  border-color: var(--danger);
}

.form-field-err {
  font-size: 11.5px;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-field.invalid .form-field-err {
  display: block;
}

/* ==================== 标签/Chip 组件 ==================== */
.chip {
  background: #F2F3F4;
  border: 1px solid transparent;
  color: var(--ink);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-block;
  transition: background 0.15s, color 0.15s;
}

.chip.sel {
  background: var(--brand);
  color: #fff;
}

.chip.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ==================== 弹窗组件 ==================== */
.modal-overlay,
.config-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  display: none;
}

.modal-overlay.show,
.config-modal.show {
  display: flex;
}

.modal-content {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 400px;
  max-width: 90%;
}

.modal-content h3 {
  font-size: 16px;
  color: var(--brand-deep);
  margin: 0 0 16px;
}

.modal-content .form-field {
  margin-bottom: 16px;
}

.modal-content textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
  min-height: 60px;
}

.modal-content textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-save-config {
  width: 100%;
  margin-top: 16px;
}

/* ==================== Toast 提示组件 ==================== */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-deep);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
}

/* ==================== 顶栏组件 ==================== */
.app-title {
  background: var(--brand-deep);
  color: #fff;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  flex: none;
}

.app-title .title-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  text-decoration: none;
}

.app-title .user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.app-title .user-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
}

.app-title .avatar-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title .avatar-text {
  font-size: 13px;
  font-weight: 600;
}

.app-title .user-menu-trigger span {
  font-size: 12.5px;
  color: #C9D4E8;
}

.user-dropdown {
  position: absolute;
  top: 58px;
  right: 16px;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 160px;
  display: none;
  z-index: 200;
}

.user-dropdown.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 7px;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: #F2F3F4;
}

.dropdown-item iconify-icon {
  font-size: 16px;
  color: var(--ink-soft);
}

.dropdown-item.logout {
  color: var(--danger);
}

.dropdown-item.logout iconify-icon {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}

/* ==================== v2.5.0 机构名公共截断样式 ==================== */
/* 机构名展示位统一应用的截断样式类，由 truncateOrgName 配合使用 */
.org-name-text {
  display: inline-block;
  max-width: var(--org-chip-name-max-width);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* tooltip、弹窗等空间充足的位置不截断 */
.org-name-text--full {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

/* org1 固定机构标识：仅改变光标，悬停不改变显示文本（v2.5.1 修复）
   原方案中 :hover::after 会向芯片追加"（固定机构）"文本，导致悬停时
   芯片宽度变化、显示内容改变。现改为通过 title 属性提供原生 tooltip。 */
.org-chip.fixed {
  cursor: not-allowed;
}

/* 机构自定义弹窗历史记录列表项 */
.org-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.org-history-item:hover {
  background: var(--bg);
}

.org-history-item .org-history-time {
  font-size: 11px;
  color: var(--ink-soft);
  margin-left: 8px;
  white-space: nowrap;
}

/* 机构芯片区整体宽度约束（防止长名称挤压问题标签区） */
#orgChips {
  max-width: var(--org-chips-max-width-ratio);
  overflow: hidden;
}

