/* =====================================================================
   应用内组件：弹窗 / 下拉框 / 滑块 / 复选 / 颜色选择器 / 菜单 / 提示
   全部为应用端实现，不使用浏览器原生控件。
   ===================================================================== */

/* ---------- 遮罩 ---------- */
.ps-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease);
  backdrop-filter: blur(2px);
}
.ps-overlay.open { opacity: 1; }

/* ---------- 弹窗 ---------- */
.ps-modal {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform var(--dur-base) var(--ease);
  overflow: hidden;
}
.ps-overlay.open .ps-modal { transform: translateY(0) scale(1); }
.ps-modal.wide { width: min(760px, calc(100vw - 32px)); }
.ps-modal.slim { width: min(400px, calc(100vw - 32px)); }

.ps-modal__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.ps-modal__title { font-weight: 600; font-size: 14px; flex: 1; }
.ps-modal__body {
  padding: var(--space-4);
  overflow: auto;
  flex: 1;
}
.ps-modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

/* ---------- 浮动层（下拉/菜单共用） ---------- */
.ps-popup {
  position: fixed;
  z-index: 1200;
  min-width: 160px;
  max-height: 320px;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.ps-popup.open { opacity: 1; transform: translateY(0); }
.ps-popup.up { transform: translateY(4px); }
.ps-popup.up.open { transform: translateY(0); }

/* ---------- 下拉框 ---------- */
.ps-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  min-width: 120px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
.ps-select:hover { border-color: var(--border-strong); }
.ps-select.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.ps-select__value { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-select__arrow { width: 14px; height: 14px; color: var(--text-faint); transition: transform var(--dur-fast) var(--ease); }
.ps-select.open .ps-select__arrow { transform: rotate(180deg); }

.ps-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.ps-option:hover { background: var(--bg-hover); }
.ps-option.selected { background: var(--accent-weak); color: var(--accent); }
.ps-option__check { width: 14px; color: var(--accent); }
.ps-popup__search {
  padding: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-1);
}

/* ---------- 上下文菜单 ---------- */
.ps-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.ps-menu-item:hover { background: var(--bg-hover); }
.ps-menu-item.disabled { opacity: 0.4; pointer-events: none; }
.ps-menu-item.danger { color: var(--danger); }
.ps-menu-item .shortcut { margin-left: auto; color: var(--text-faint); font-size: 11px; }
.ps-menu-sep { height: 1px; background: var(--border); margin: var(--space-1) 4px; }

/* ---------- 复选框 ---------- */
.ps-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.ps-check__box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-sunken);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  flex: none;
}
.ps-check__box svg { width: 12px; height: 12px; color: var(--text-on-accent); opacity: 0; transform: scale(0.6); transition: all var(--dur-fast) var(--ease); }
.ps-check.checked .ps-check__box { background: var(--accent); border-color: var(--accent); }
.ps-check.checked .ps-check__box svg { opacity: 1; transform: scale(1); }

/* ---------- 开关 ---------- */
.ps-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
  flex: none;
}
.ps-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
.ps-switch.on { background: var(--accent); }
.ps-switch.on::after { transform: translateX(16px); }

/* ---------- 滑块 ---------- */
.ps-slider { position: relative; height: 20px; display: flex; align-items: center; cursor: pointer; width: 100%; }
.ps-slider__track { width: 100%; height: 4px; border-radius: 999px; background: var(--bg-active); overflow: hidden; }
.ps-slider__fill { height: 100%; background: var(--accent); border-radius: 999px; }
.ps-slider__thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease);
}
.ps-slider:hover .ps-slider__thumb { transform: translate(-50%, -50%) scale(1.15); }

/* ---------- 数字输入 ---------- */
.ps-number {
  display: inline-flex;
  align-items: center;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  overflow: hidden;
}
.ps-number input {
  width: 100%;
  min-width: 28px;
  height: 100%;
  padding: 0 2px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
}
.ps-number button {
  width: 24px;
  height: 100%;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ps-number button:hover { background: var(--bg-hover); color: var(--text); }
.ps-number:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

/* ---------- 颜色选择器 ---------- */
.ps-colorpicker { width: 236px; padding: var(--space-2); }
.ps-cp__area {
  position: relative;
  width: 100%;
  height: 150px;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  overflow: hidden;
}
.ps-cp__cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.ps-cp__hue {
  position: relative;
  height: 12px;
  margin-top: var(--space-2);
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.ps-cp__hue-cursor {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
}
.ps-cp__row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.ps-cp__preview { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex: none; }
.ps-cp__fields { display: flex; gap: 4px; flex: 1; }
.ps-cp__fields .field { height: 28px; padding: 0 6px; font-family: var(--font-mono); text-align: center; }

/* ---------- 提示 Toast ---------- */
.ps-toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}
.ps-toast-root.top { top: 56px; }
.ps-toast-root.center { top: 50%; transform: translate(-50%, -50%); }
.ps-toast-root.bottom { bottom: 48px; }
.ps-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text);
  animation: toastIn var(--dur-base) var(--ease);
  max-width: 80vw;
}
.ps-toast svg { width: 16px; height: 16px; flex: none; }
.ps-toast.success svg { color: var(--success); }
.ps-toast.error svg { color: var(--danger); }
.ps-toast.warn svg { color: var(--warning); }
.ps-toast.leaving { animation: toastOut var(--dur-fast) var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ---------- 标签页 ---------- */
.ps-tabs { display: flex; gap: 2px; padding: 3px; background: var(--bg-sunken); border-radius: var(--radius-sm); }
.ps-tab {
  flex: 1;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ps-tab:hover { color: var(--text); }
.ps-tab.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- 分段控件 ---------- */
.ps-segment { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.ps-segment button {
  height: 28px;
  padding: 0 10px;
  color: var(--text-dim);
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
}
.ps-segment button:last-child { border-right: none; }
.ps-segment button.active { background: var(--accent-weak); color: var(--accent); }

/* ---------- 快速预设按钮组 ---------- */
.seg-quick { display: inline-flex; gap: 4px; margin-left: 6px; }
.seg-quick .btn.sm { padding: 0 8px; height: 26px; }

/* ---------- 危险操作警告 ---------- */
.warn-dialog { text-align: center; padding: 6px 4px 2px; }
.warn-dialog__icon { color: var(--warning); display: flex; justify-content: center; margin-bottom: 10px; }
.warn-dialog__title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.warn-dialog__text { color: var(--text-dim); font-size: 13px; line-height: 1.75; margin-bottom: 8px; }
.warn-dialog__text b { color: var(--text); }

/* ---------- 表单行 ---------- */
.ps-formrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 38px;
}
.ps-formrow > label { width: 108px; flex: none; color: var(--text-dim); }
.ps-formrow > .ps-formrow__control { flex: 1; display: flex; align-items: center; gap: 8px; }
.ps-formhint { color: var(--text-faint); font-size: 12px; margin: -2px 0 var(--space-2); }
