/* ========== Shared base / a11y / shell ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/*
  交互状态触发方式（全局）：
  - Hover：鼠标悬停
  - Active：按下
  - Focus：:focus-visible
  - Disabled：disabled / aria-disabled
*/

button,
[role="button"],
input,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus,
[role="button"]:focus {
  outline: none;
}

button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

button:disabled,
button[aria-disabled="true"],
[role="button"][aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

button:not(:disabled):not([aria-disabled="true"]),
.media-card,
.log-card,
.robot-item,
.stat-card,
.alert-summary__card,
.alert-item,
.progress-row,
.project-card,
.login-submit {
  transition:
    opacity 0.2s ease,
    transform 0.15s ease,
    filter 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

body {
  background: var(--body-bg, #0a0a0a);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  font-family: var(--font-family-base);
  color: var(--icon-white);
}

.page {
  width: var(--layout-canvas-width);
  min-height: var(--layout-canvas-min-height);
  background: var(--bg-page);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.abs {
  position: absolute;
}

/* ========== 系统顶部背景底沿线型流动光感（柔和） ========== */
.header__flow {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 1.05rem;
  height: 0.75rem;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
  opacity: 0.92;
}

/* 与顶栏底缘融合的柔光基线 */
.header__flow-base {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
  border-radius: 1px;
  background: linear-gradient(
    90deg,
    rgba(0, 103, 176, 0) 0%,
    rgba(4, 222, 255, 0.16) 18%,
    rgba(180, 236, 255, 0.42) 50%,
    rgba(4, 222, 255, 0.16) 82%,
    rgba(0, 102, 174, 0) 100%
  );
  box-shadow: 0 0 10px 1px rgba(4, 222, 255, 0.16);
  opacity: 0.75;
}

.header__flow-base::before,
.header__flow-base::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: #eafcff;
  box-shadow: 0 0 8px 2px rgba(4, 222, 255, 0.55);
  animation: header-node-pulse 3.2s ease-in-out infinite;
}

.header__flow-base::before {
  left: 18%;
}

.header__flow-base::after {
  right: 18%;
  animation-delay: -1.6s;
}

.header__flow-glow {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 14px;
  transform: translateY(-50%);
  background: radial-gradient(
    ellipse 60% 100% at 50% 50%,
    rgba(4, 222, 255, 0.18) 0%,
    rgba(27, 126, 242, 0.06) 50%,
    transparent 78%
  );
  filter: blur(6px);
  opacity: 0.55;
  animation: header-flow-breathe 9s ease-in-out infinite;
}

.header__flow-beam {
  position: absolute;
  top: 50%;
  left: 0;
  width: 36%;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(4, 222, 255, 0) 8%,
    rgba(4, 222, 255, 0.1) 32%,
    rgba(210, 246, 255, 0.55) 50%,
    rgba(4, 222, 255, 0.18) 68%,
    transparent 100%
  );
  box-shadow: 0 0 12px 2px rgba(4, 222, 255, 0.22);
  filter: blur(1.6px);
  animation: header-flow-move 10s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
  will-change: transform, opacity;
}

.header__flow-beam--alt {
  width: 28%;
  opacity: 0.55;
  animation-duration: 14s;
  animation-delay: -6s;
  filter: blur(2.4px);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(27, 126, 242, 0) 10%,
    rgba(27, 126, 242, 0.12) 38%,
    rgba(4, 222, 255, 0.28) 50%,
    rgba(27, 126, 242, 0.1) 62%,
    transparent 100%
  );
  box-shadow: 0 0 14px 2px rgba(27, 126, 242, 0.14);
}

.header__title {
  color: #eaf4ff;
  text-shadow:
    0 0 16px rgba(4, 222, 255, 0.26),
    0 1px 0 rgba(255, 255, 255, 0.16);
  animation: header-title-glow 6.5s ease-in-out infinite;
}

@keyframes header-flow-move {
  0% {
    transform: translate3d(-12%, 0, 0);
    opacity: 0;
  }
  18% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.8;
  }
  82% {
    opacity: 0.5;
  }
  100% {
    transform: translate3d(155%, 0, 0);
    opacity: 0;
  }
}

@keyframes header-flow-breathe {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(-50%) scaleX(0.98);
  }
  50% {
    opacity: 0.62;
    transform: translateY(-50%) scaleX(1.02);
  }
}

@keyframes header-node-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes header-title-glow {
  0%,
  100% {
    text-shadow:
      0 0 12px rgba(4, 222, 255, 0.18),
      0 1px 0 rgba(255, 255, 255, 0.12);
  }
  50% {
    text-shadow:
      0 0 22px rgba(4, 222, 255, 0.38),
      0 1px 0 rgba(255, 255, 255, 0.22);
  }
}

html[data-theme="light"] .header__flow {
  opacity: 0.55;
}

html[data-theme="light"] .header__flow-base {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.35) 22%,
    rgba(255, 255, 255, 0.7) 50%,
    rgba(255, 255, 255, 0.35) 78%,
    rgba(255, 255, 255, 0) 100%
  );
  box-shadow: 0 0 10px 1px rgba(255, 255, 255, 0.28);
}

html[data-theme="light"] .header__flow-glow {
  background: radial-gradient(
    ellipse 60% 100% at 50% 50%,
    rgba(255, 255, 255, 0.22) 0%,
    rgba(161, 208, 252, 0.08) 50%,
    transparent 78%
  );
}

html[data-theme="light"] .header__flow-beam {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0) 8%,
    rgba(255, 255, 255, 0.18) 30%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(210, 230, 255, 0.22) 65%,
    transparent 100%
  );
  box-shadow: 0 0 12px 2px rgba(255, 255, 255, 0.2);
}

html[data-theme="light"] .header__flow-beam--alt {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 35%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.12) 65%,
    transparent 100%
  );
}

html[data-theme="light"] .header__title {
  color: #ffffff;
  animation: none;
  text-shadow: 0 1px 2px rgba(12, 48, 110, 0.22);
}

html[data-theme="light"] .header__flow-base::before,
html[data-theme="light"] .header__flow-base::after {
  background: #ffffff;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.55);
}

html[data-theme="light"] .win-btn:hover {
  box-shadow: 0 0 0.4rem rgba(22, 119, 255, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  .header__flow-beam,
  .header__flow-glow,
  .header__flow-base::before,
  .header__flow-base::after,
  .header__title {
    animation: none !important;
  }

  .header__flow-beam {
    left: 28%;
    opacity: 0.4;
    transform: none;
  }

  .header__flow-beam--alt {
    left: 48%;
    opacity: 0.25;
  }
}

/* ========== 窗口控制（各页右上角共用） ========== */
.win-controls {
  position: absolute;
  right: 0;
  top: 0;
  width: 123px;
  height: 36px;
  z-index: 50;
  pointer-events: auto;
}

.win-controls__bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 123px;
  height: 36px;
  line-height: 0;
}

.win-controls__bg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.win-controls__btns {
  position: absolute;
  left: 24px;
  top: 5px;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.win-btn {
  width: 25.92px;
  height: 25.92px;
  border-radius: 5.18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}

.win-btn:hover {
  background: var(--theme-hover, rgba(27, 126, 242, 0.25));
  box-shadow: 0 0 0.375rem rgba(4, 222, 255, 0.35);
}

.win-btn:active {
  background: var(--theme-selected, rgba(27, 126, 242, 0.5));
}

.win-btn--close:hover {
  background: rgba(255, 56, 56, 0.25);
}

.win-btn--close:active {
  background: rgba(255, 56, 56, 0.45);
}

.win-btn--minus {
  width: 0.729rem;
  height: 0.081rem;
  background: var(--text-secondary, #b2becc);
  display: block;
}

.win-btn--zoom-box {
  width: 12.96px;
  height: 12.96px;
  border-radius: 2.59px;
  border: 1.04px solid var(--text-secondary, #b2becc);
  box-sizing: border-box;
}

.win-btn--close > span {
  width: 11.66px;
  height: 11.66px;
  display: flex;
  line-height: 0;
}

.win-btn--close svg {
  width: 100%;
  height: 100%;
}

/* 全局弹层：默认隐藏；.is-open 必须能压过 [hidden] */
.create-overlay,
.process-overlay,
.admin-overlay {
  display: none;
}

.create-overlay.is-open,
.process-overlay.is-open,
.admin-overlay.is-open {
  display: flex !important;
}

/* ========== 输入框报错（登录 / 创建 / 后台共用） ========== */
/* 关闭浏览器原生 :invalid 红框，统一走 .is-error */
.login-field:invalid,
.create-field__control:invalid,
.admin-field__control:invalid {
  box-shadow: none;
}

.login-field.is-error,
.create-field__control.is-error,
.admin-field__control.is-error {
  border-color: var(--func-error) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 210, 210, 0.08),
    0 0 0 1px rgba(255, 56, 56, 0.28),
    0 0 0.75rem rgba(255, 56, 56, 0.18);
}

.login-field.is-error:focus,
.login-field.is-error:focus-visible,
.create-field__control.is-error:focus,
.create-field__control.is-error:focus-visible,
.admin-field__control.is-error:focus,
.admin-field__control.is-error:focus-visible {
  border-color: var(--func-error) !important;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 210, 210, 0.1),
    0 0 0 1px rgba(255, 56, 56, 0.35),
    0 0 0.85rem rgba(255, 56, 56, 0.2);
}

.field-error {
  margin: 0.35rem 0 0;
  font: var(--font-12);
  color: #ff7a7a;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.field-error[hidden] {
  display: none !important;
}

@keyframes field-error-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
}

.login-field.is-shake,
.create-field__control.is-shake,
.admin-field__control.is-shake {
  animation: field-error-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@media (prefers-reduced-motion: reduce) {
  .login-field.is-shake,
  .create-field__control.is-shake,
  .admin-field__control.is-shake {
    animation: none;
  }
}

html[data-theme="light"] .login-field.is-error,
html[data-theme="light"] .create-field__control.is-error,
html[data-theme="light"] .admin-field__control.is-error {
  box-shadow:
    0 0 0 1px rgba(232, 90, 90, 0.22),
    0 0 0.5rem rgba(232, 90, 90, 0.12);
}

html[data-theme="light"] .login-field.is-error:focus,
html[data-theme="light"] .login-field.is-error:focus-visible,
html[data-theme="light"] .create-field__control.is-error:focus,
html[data-theme="light"] .create-field__control.is-error:focus-visible,
html[data-theme="light"] .admin-field__control.is-error:focus,
html[data-theme="light"] .admin-field__control.is-error:focus-visible {
  box-shadow:
    0 0 0 1px rgba(232, 90, 90, 0.32),
    0 0 0.6rem rgba(232, 90, 90, 0.16);
}

html[data-theme="light"] .field-error {
  color: var(--func-error);
}
