/* ============================================================
   悬浮窗组件 v3（圆形图标 + 展开面板）
   - 依赖图片：Assets/injection/icon.webp
   - 面板：半透明磨砂玻璃质感黑色圆角矩形，图标位于面板左上角
   - 尺寸随渲染分辨率自适应：以游戏设计分辨率 1280×720 为基准，
     由 JS 按视口尺寸计算 --fwt-s，本文件所有尺寸均按该变量计算
   - 全部样式带 fwt- 前缀，避免与游戏样式冲突
   ============================================================ */

.fwt-widget {
  /* JS 会动态覆盖该变量（当前渲染分辨率对应的缩放比例） */
  --fwt-s: 1;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999999;
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  will-change: transform;
  /* 窗口平移（自动回弹/展开避让/折叠还原）动画 */
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* 拖动过程中禁用位移动画，保证跟手 */
.fwt-widget.fwt-dragging {
  transition: none;
}

/* ---------- 圆形图标（带呼吸动画） ---------- */
.fwt-icon {
  position: relative;
  z-index: 3;
  display: block;
  width: calc(52px * var(--fwt-s));
  height: calc(52px * var(--fwt-s));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: grab;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  animation: fwt-breathe 3.2s ease-in-out infinite;
  transition: transform 0.18s ease;
}

.fwt-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-sizing: border-box;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* 呼吸：轻微缩放 + 柔和金色光晕 */
@keyframes fwt-breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(255, 205, 120, 0);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(255, 205, 120, 0.28);
  }
}

/* 长按/拖动期间停止呼吸，直接显示按压态 */
.fwt-widget.fwt-armed .fwt-icon,
.fwt-widget.fwt-dragging .fwt-icon {
  animation: none;
  cursor: grabbing;
  transform: scale(1.06);
}

/* ---------- 展开面板：磨砂玻璃黑色圆角矩形 ---------- */
.fwt-panel {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  box-sizing: border-box;
  width: min(calc(320px * var(--fwt-s)), calc(100vw - 24px));
  min-height: calc(272px * var(--fwt-s));
  max-height: calc(100vh - 16px);
  padding: calc(14px * var(--fwt-s)) calc(16px * var(--fwt-s));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: calc(18px * var(--fwt-s));
  background: rgba(10, 10, 18, 0.58);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(226, 205, 165, 0.18);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transform-origin: top left;
  transform: scale(0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.25, 0.45, 1),
    opacity 0.22s ease,
    visibility 0s 0.3s;
}

.fwt-widget.fwt-open .fwt-panel {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.25, 0.45, 1),
    opacity 0.22s ease,
    visibility 0s;
}

/* 面板头部：标题整体右移，为左上角圆形图标让位 */
.fwt-panel-head {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: calc(28px * var(--fwt-s));
  padding-left: calc(64px * var(--fwt-s));
}

.fwt-title {
  font-size: calc(15px * var(--fwt-s));
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffe4a1;
}

.fwt-panel-body {
  flex: 1 1 auto;
  margin-top: calc(12px * var(--fwt-s));
  overflow: auto;
  color: #d9ccd8;
  font-size: calc(13px * var(--fwt-s));
  line-height: 1.7;
}

.fwt-panel-body p {
  margin: 0 0 8px;
}

/* ---------- 悬浮菜单增强项：开关行 / 开关 / 危险按钮 / 说明 ---------- */
.fwt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(10px * var(--fwt-s));
  padding: calc(8px * var(--fwt-s)) calc(10px * var(--fwt-s));
  margin-bottom: calc(6px * var(--fwt-s));
  border-radius: calc(10px * var(--fwt-s));
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(226, 205, 165, 0.12);
  cursor: pointer;
  transition: background 0.18s ease;
}

.fwt-row:hover {
  background: rgba(255, 255, 255, 0.09);
}

.fwt-row-text {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
  min-width: 0;
}

.fwt-row-text b {
  color: #f2e6d8;
  font-size: calc(13.5px * var(--fwt-s));
  font-weight: 600;
}

.fwt-row-text small {
  color: #a898ab;
  font-size: calc(11px * var(--fwt-s));
}

.fwt-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.fwt-switch {
  position: relative;
  flex: 0 0 auto;
  width: calc(44px * var(--fwt-s));
  height: calc(24px * var(--fwt-s));
  border-radius: calc(12px * var(--fwt-s));
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.fwt-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(2px * var(--fwt-s));
  width: calc(18px * var(--fwt-s));
  height: calc(18px * var(--fwt-s));
  border-radius: 50%;
  background: #e8ddcf;
  transform: translateY(-50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: left 0.18s ease, background 0.18s ease;
}

.fwt-switch-input:checked + .fwt-switch {
  background: #d8a94e;
  border-color: rgba(255, 222, 160, 0.55);
}

.fwt-switch-input:checked + .fwt-switch::after {
  left: calc(24px * var(--fwt-s));
  background: #fff3da;
}

.fwt-switch-input:focus-visible + .fwt-switch {
  outline: 2px solid rgba(255, 228, 161, 0.6);
  outline-offset: 2px;
}

.fwt-danger {
  display: block;
  width: 100%;
  margin: calc(4px * var(--fwt-s)) 0 calc(2px * var(--fwt-s));
  padding: calc(9px * var(--fwt-s)) 0;
  border: 1px solid rgba(255, 138, 128, 0.4);
  border-radius: calc(10px * var(--fwt-s));
  background: linear-gradient(180deg, rgba(176, 54, 54, 0.72), rgba(126, 32, 32, 0.72));
  color: #ffe1d9;
  font-size: calc(13px * var(--fwt-s));
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.fwt-danger:hover {
  filter: brightness(1.12);
}

.fwt-danger:active {
  transform: scale(0.98);
}

.fwt-note {
  margin: calc(6px * var(--fwt-s)) 0 0;
  color: #8b7d8e;
  font-size: calc(10.5px * var(--fwt-s));
  line-height: 1.5;
}

.fwt-panel-hint {
  margin-top: auto;
  padding-top: calc(10px * var(--fwt-s));
  border-top: 1px solid rgba(226, 205, 165, 0.14);
  color: #a898ab;
  font-size: calc(11px * var(--fwt-s));
  letter-spacing: 0.03em;
}

/* 展开时面板内容轻微上浮淡入（错峰 80ms，更流畅） */
.fwt-panel-head,
.fwt-panel-body,
.fwt-panel-hint {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.24s ease 0.08s, transform 0.24s ease 0.08s;
}

.fwt-widget.fwt-open .fwt-panel-head,
.fwt-widget.fwt-open .fwt-panel-body,
.fwt-widget.fwt-open .fwt-panel-hint {
  opacity: 1;
  transform: none;
}

/* ---------- 清除数据确认覆盖弹窗（网页内弹窗，替代浏览器 confirm） ---------- */
.fwt-modal-overlay {
  /* 尺寸随渲染分辨率自适应，与悬浮窗同一基准；JS 会动态覆盖 */
  --fwt-s: 1;
  position: fixed;
  inset: 0;
  z-index: 1000000; /* 高于悬浮窗本身（999999） */
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px;
  background: rgba(4, 4, 10, 0.62);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  backdrop-filter: blur(6px) saturate(120%);
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0s 0.22s;
}

.fwt-modal-overlay.fwt-modal-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.22s ease;
}

.fwt-modal {
  box-sizing: border-box;
  width: min(calc(380px * var(--fwt-s)), calc(100vw - 32px));
  padding: calc(20px * var(--fwt-s)) calc(22px * var(--fwt-s)) calc(18px * var(--fwt-s));
  border-radius: calc(18px * var(--fwt-s));
  background: rgba(17, 16, 28, 0.94);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(226, 205, 165, 0.22);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.26s cubic-bezier(0.34, 1.25, 0.45, 1);
}

.fwt-modal-overlay.fwt-modal-open .fwt-modal {
  transform: none;
}

.fwt-modal-title {
  margin: 0 0 calc(10px * var(--fwt-s));
  color: #ffe4a1;
  font-size: calc(17px * var(--fwt-s));
  font-weight: 700;
  letter-spacing: 0.05em;
}

.fwt-modal-body {
  margin: 0 0 calc(16px * var(--fwt-s));
  color: #d9ccd8;
  font-size: calc(13px * var(--fwt-s));
  line-height: 1.75;
}

.fwt-modal-body b {
  color: #ffd9a0;
}

.fwt-modal-actions {
  display: flex;
  gap: calc(10px * var(--fwt-s));
}

.fwt-modal-btn {
  flex: 1 1 0;
  padding: calc(10px * var(--fwt-s)) 0;
  border-radius: calc(10px * var(--fwt-s));
  font-size: calc(13px * var(--fwt-s));
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.18s ease;
}

.fwt-modal-btn:hover {
  filter: brightness(1.12);
}

.fwt-modal-btn:active {
  transform: scale(0.98);
}

.fwt-modal-btn:disabled {
  cursor: default;
  filter: grayscale(0.4) brightness(0.9);
  transform: none;
}

.fwt-modal-cancel {
  border: 1px solid rgba(226, 205, 165, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #e8ddcf;
}

.fwt-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.fwt-modal-confirm {
  border: 1px solid rgba(255, 138, 128, 0.45);
  background: linear-gradient(180deg, rgba(176, 54, 54, 0.8), rgba(126, 32, 32, 0.82));
  color: #ffe1d9;
}

/* 尊重系统“减少动态效果”偏好 */
@media (prefers-reduced-motion: reduce) {
  .fwt-widget,
  .fwt-icon,
  .fwt-panel,
  .fwt-panel-head,
  .fwt-panel-body,
  .fwt-panel-hint,
  .fwt-modal-overlay,
  .fwt-modal {
    transition: none !important;
    animation: none !important;
  }
}
