/*
 * 内容区与弹窗的交互反馈统一层。
 * 作用范围只落在右侧工作区和弹窗，左侧一级导航不在本文件选择器范围内。
 */

#app .project-main > .project-workspace :is(button, [role="button"]),
#app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button, [role="button"]),
body :is([role="dialog"], [role="alertdialog"]) :is(button, [role="button"]) {
  transition: background-color .14s ease, border-color .14s ease, color .14s ease,
    box-shadow .14s ease;
}

@media (hover: hover) and (pointer: fine) {
  /* 普通按钮、页签和内容区中的无障碍按钮。 */
  #app .project-main > .project-workspace :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):not(.active):not(.primary):not(.danger):not(.danger-text):not(.software-confirm-danger):not(.link):not(.text-btn):not([class*="close"]):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):not(.active):not(.primary):not(.danger):not(.danger-text):not(.software-confirm-danger):not(.link):not(.text-btn):not([class*="close"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):not(.active):not(.primary):not(.danger):not(.danger-text):not(.software-confirm-danger):not(.link):not(.text-btn):not([class*="close"]):hover {
    border-color: #7fa9e5 !important;
    background: #edf4ff !important;
    color: #145fc9 !important;
    box-shadow: 0 0 0 2px rgba(23, 105, 232, .09) !important;
  }

  /* 文字操作按钮保持轻量，但通过底色和下划线让可操作性更清楚。 */
  #app .project-main > .project-workspace :is(button.link, button.text-btn, .text-btn):not(:disabled):not([aria-disabled="true"]):not(.danger):not(.danger-text):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button.link, button.text-btn, .text-btn):not(:disabled):not([aria-disabled="true"]):not(.danger):not(.danger-text):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button.link, button.text-btn, .text-btn):not(:disabled):not([aria-disabled="true"]):not(.danger):not(.danger-text):hover {
    border-color: transparent !important;
    background: #edf4ff !important;
    color: #145fc9 !important;
    box-shadow: none !important;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
  }

  /* 主操作保留蓝色层级，移入时加深并增强高亮。 */
  #app .project-main > .project-workspace :is(button.primary, .btn.primary, [role="button"].primary):not(:disabled):not([aria-disabled="true"]):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button.primary, .btn.primary, [role="button"].primary):not(:disabled):not([aria-disabled="true"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button.primary, .btn.primary, [role="button"].primary):not(:disabled):not([aria-disabled="true"]):hover {
    border-color: #123889 !important;
    background: linear-gradient(180deg, #123889, #0b4da6) !important;
    color: #fff !important;
    box-shadow: none !important;
  }

  /* 危险操作只加深红色，不改变其语义。 */
  #app .project-main > .project-workspace :is(button.danger, button.danger-text, .danger-text, [role="button"].danger):not(:disabled):not([aria-disabled="true"]):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button.danger, button.danger-text, .danger-text, [role="button"].danger):not(:disabled):not([aria-disabled="true"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button.danger, button.danger-text, .danger-text, [role="button"].danger):not(:disabled):not([aria-disabled="true"]):hover {
    border-color: #bd3933 !important;
    background: #fff0f0 !important;
    color: #a93636 !important;
    box-shadow: 0 0 0 2px rgba(189, 57, 51, .08) !important;
  }

  /* 关闭按钮和已选页签也要有可感知的移入反馈，但不改变已选层级。 */
  #app .project-main > .project-workspace :is(button[class*="close"], .close):not(:disabled):not([aria-disabled="true"]):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button[class*="close"], .close):not(:disabled):not([aria-disabled="true"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button[class*="close"], .close):not(:disabled):not([aria-disabled="true"]):hover {
    border-color: #b9cee8 !important;
    background: #edf4ff !important;
    color: #145fc9 !important;
    box-shadow: 0 0 0 2px rgba(23, 105, 232, .08) !important;
  }

  #app .project-main > .project-workspace :is(button.active, [role="tab"][aria-selected="true"], [aria-current="page"]):not(:disabled):hover,
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button.active, [role="tab"][aria-selected="true"], [aria-current="page"]):not(:disabled):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button.active, [role="tab"][aria-selected="true"], [aria-current="page"]):not(:disabled):not([aria-disabled="true"]):hover {
    box-shadow: 0 0 0 2px rgba(23, 105, 232, .14) !important;
  }

  /* 统一处理页签：只改变颜色和内侧底线，不改变几何位置，避免顶部被父容器裁切。 */
  #app .project-main > .project-workspace .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):not(.active):not([aria-selected="true"]):not([aria-current="page"]):hover,
  #app .project-workbench .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):not(.active):not([aria-selected="true"]):not([aria-current="page"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):not(.active):not([aria-selected="true"]):not([aria-current="page"]):hover {
    border-color: #7fa9e5 !important;
    background: #edf4ff !important;
    color: #145fc9 !important;
    box-shadow: inset 0 -2px 0 #7fa9e5 !important;
    transform: none !important;
  }

  #app .project-main > .project-workspace .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):is(.active, [aria-selected="true"], [aria-current="page"]):hover,
  #app .project-workbench .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):is(.active, [aria-selected="true"], [aria-current="page"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) .business-tabs :is(button, [role="button"], [role="tab"]):not(:disabled):not([aria-disabled="true"]):is(.active, [aria-selected="true"], [aria-current="page"]):hover {
    box-shadow: inset 0 -2px 0 rgba(255, 255, 255, .82) !important;
    transform: none !important;
  }

  /* 内容区所有交互控件均不做位移，避免按钮顶部在紧贴边界的容器中被截断。 */
  #app .project-main > .project-workspace :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):hover,
  #app .project-workbench .project-workspace :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):hover,
  body :is([role="dialog"], [role="alertdialog"]) :is(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):hover {
    transform: none !important;
  }
}

/* 键盘操作使用比普通边框更清楚的聚焦环；一级导航不在作用域内。 */
#app .project-main > .project-workspace :is(button, [role="button"]):focus-visible,
#app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button, [role="button"]):focus-visible,
body :is([role="dialog"], [role="alertdialog"]) :is(button, [role="button"]):focus-visible {
  outline: 3px solid rgba(23, 105, 232, .28) !important;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #app .project-main > .project-workspace :is(button, [role="button"]),
  #app .project-workbench :is([role="dialog"], [class*="dialog"], [class*="modal"]) :is(button, [role="button"]),
  body :is([role="dialog"], [role="alertdialog"]) :is(button, [role="button"]) {
    transition: none;
  }
}

/* 统一操作等待反馈：只在真实等待状态显示，不影响短信倒计时。 */
button[data-action-busy="true"] { min-width: var(--action-busy-width, auto); cursor: wait; }
button[data-action-busy="true"]::before,
.project-list-loading-state[aria-busy="true"] > div::before {
  content: ""; display: inline-block; box-sizing: border-box; width: 12px; height: 12px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; margin-right: 6px; vertical-align: -1px;
  animation: hcr-action-spin .8s linear infinite;
}
.project-list-loading-state[aria-busy="true"] > div::before {
  box-sizing: border-box; width: 20px; height: 20px; margin: 0; justify-self: center; color: #1b58b8;
}
button[data-action-busy="true"]::before {
  position: static; inset: auto; flex: 0 0 12px;
}
/* 等待用户确认或结果尚未返回时停止转圈，保留按钮禁用防止重复导入。 */
button[data-local-restore][data-import-display-state="confirm"]::before,
button[data-local-restore][data-import-display-state="unconfirmed"]::before {
  content: none;
  animation: none;
}
button[data-local-restore][data-import-display-state="confirm"],
button[data-local-restore][data-import-display-state="unconfirmed"] {
  cursor: default;
}
.project-list-loading-state[aria-busy="true"] > div {
  justify-items: center; text-align: center;
}
@keyframes hcr-action-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  button[data-action-busy="true"]::before,
  .project-list-loading-state[aria-busy="true"] > div::before { animation: none; }
}
