/* panel.css —— 功能面板页公共样式（布局 + pui-* UI 组件）—— D0 极简黑白（静态） */

/* ---------- 布局 ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f7f7;
  color: #111;
  line-height: 1.6;
}

.panel-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.panel-header {
  background: #111;
  color: #fff;
}

.panel-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 34px 24px 30px;
}

.panel-header h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.panel-subtitle {
  margin: 8px 0 0;
  color: #9a9a9a;
  font-size: 14px;
}

.panel-main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.panel-content {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 24px;
}

/* ---------- 内容组件 ---------- */
.pui-card {
  margin: 0 0 18px;
  padding: 18px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #fff;
}

.pui-card:last-child {
  margin-bottom: 0;
}

.pui-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.pui-card-title {
  margin: 0;
  color: #111;
  font-size: 16px;
  line-height: 1.4;
}

.pui-card-desc {
  margin: 3px 0 0;
  color: #888;
  font-size: 12px;
}

.pui-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.pui-label {
  color: #111;
  font-size: 13px;
  font-weight: 600;
}

.pui-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  outline: 0;
  background: #fff;
  color: #111;
  font: inherit;
}

textarea.pui-input {
  min-height: 96px;
  resize: vertical;
}

.pui-input:focus {
  border-color: #111;
  box-shadow: 0 0 0 1px #111;
}

.pui-input:disabled {
  background: #f4f4f4;
  color: #888;
  cursor: not-allowed;
}

.pui-help {
  color: #888;
  font-size: 12px;
}

.pui-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  background: #fafafa;
  color: #555;
  font-size: 12px;
  white-space: nowrap;
}

.pui-divider {
  height: 1px;
  margin: 16px 0;
  background: #ececec;
}

.pui-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid #ececec;
}

.pui-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid #ececec;
  font-size: 13px;
}

.pui-list li strong {
  font-weight: 500;
  white-space: nowrap;
}

.pui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  padding: 24px 16px;
  border: 1px dashed #d4d4d4;
  border-radius: 4px;
  background: #fafafa;
  color: #888;
  text-align: center;
  font-size: 12px;
}

.pui-empty strong {
  color: #111;
  font-size: 14px;
}

.pui-log {
  max-height: 180px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #111;
  color: #fff;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.panel-footer {
  border-top: 1px solid #ececec;
  padding: 18px 24px;
  text-align: center;
  background: #fff;
}

.panel-footer a {
  color: #888;
  text-decoration: none;
  margin: 0 10px;
  font-size: 13px;
}

.panel-footer a:hover {
  color: #111;
}

/* 广告位：预留占位，后续统一接入 */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin-bottom: 20px;
  border-radius: 4px;
  background: #fafafa;
  border: 1px dashed #ccc;
  color: #aaa;
}

.ad-slot-top {
  min-height: 90px;
}

/* ---------- 状态区（统一框架：waiting/ready/running/done/failed） ---------- */
.panel-status {
  padding: 12px 16px;
  border-radius: 4px;
  background: #f4f4f4;
  border-left: 3px solid #111;
  margin-bottom: 20px;
}

.panel-status-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #999;
  flex: none;
}

.panel-status-text {
  font-size: 13px;
  color: #111;
}

.panel-status[data-state="waiting"] .panel-status-dot {
  background: #999;
  animation: panel-status-pulse 1.4s ease-in-out infinite;
}

.panel-status[data-state="ready"] {
  border-left-color: #111;
  background: #f0f0f0;
}

.panel-status[data-state="ready"] .panel-status-dot {
  background: #111;
}

.panel-status[data-state="running"] .panel-status-dot {
  background: #111;
  animation: panel-status-pulse 0.9s ease-in-out infinite;
}

.panel-status[data-state="done"] .panel-status-dot {
  background: #111;
  box-shadow: inset 0 0 0 2px #fff;
}

.panel-status[data-state="failed"] {
  border-left-color: #111;
  background: #e8e8e8;
}

.panel-status[data-state="failed"] .panel-status-dot {
  background: #111;
  transform: rotate(45deg);
  border-radius: 1px;
}

@keyframes panel-status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.panel-progress {
  margin-top: 10px;
}

.panel-progress-track {
  height: 6px;
  border-radius: 3px;
  background: #ddd;
  overflow: hidden;
}

.panel-progress-fill {
  height: 100%;
  width: 0;
  background: #111;
  transition: width 0.25s ease;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- 通用功能组件（D0：pb-* 系列） ---------- */
.pb-status {
  padding: 10px 14px;
  border-radius: 4px;
  background: #f4f4f4;
  color: #111;
  border-left: 3px solid #111;
  font-size: 13px;
  margin-bottom: 16px;
}

.pb-group {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #ececec;
}

.pb-group:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.pb-group h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #111;
}

.pb-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.pb-lbl {
  font-size: 13px;
}

.pb-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pb-rate {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pb-rate button {
  padding: 6px 12px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 13px;
  cursor: pointer;
}

.pb-rate button:hover {
  border-color: #111;
}

.pb-rate button.active {
  background: #111;
  border-color: #111;
  color: #fff;
  font-weight: 600;
}

.pb-sw {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  color: #111;
}

.pb-sw > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pb-sw small {
  color: #888;
  font-size: 12px;
  font-weight: 400;
}

.pb-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.pb-hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: #a3a3a3;
}

input[type="range"] {
  accent-color: #111;
  cursor: pointer;
}

/* pui-switch 开关（D0 黑白） */
.pui-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
}

.pui-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pui-switch i {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: #d4d4d4;
  cursor: pointer;
}

.pui-switch i:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.pui-switch input:checked + i {
  background: #111;
}

.pui-switch input:checked + i:after {
  transform: translateX(18px);
}

/* ---------- PUI 组件 ---------- */
.pui-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pui-toast {
  min-width: 200px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 4px;
  color: #111;
  font-size: 14px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-left: 3px solid #111;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.pui-toast-info {
  border-left-color: #111;
}

.pui-toast-success {
  border-left-color: #555;
}

.pui-toast-warn {
  border-left-color: #888;
}

.pui-toast-error {
  border-left-color: #000;
  background: #111;
  color: #fff;
}

.pui-progress {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 48px);
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.pui-progress-track {
  height: 8px;
  border-radius: 4px;
  background: #e5e5e5;
  overflow: hidden;
}

.pui-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: #111;
}

.pui-progress-label {
  margin-top: 6px;
  font-size: 12px;
  color: #888;
  text-align: center;
}

.pui-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.pui-modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 4px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.pui-modal-head {
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #ececec;
}

.pui-modal-body {
  padding: 18px 20px;
  font-size: 14px;
  color: #333;
  word-break: break-word;
}

.pui-modal-foot {
  padding: 12px 20px;
  border-top: 1px solid #ececec;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pui-btn {
  padding: 8px 16px;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.pui-btn:disabled {
  border-color: #e5e5e5;
  background: #f4f4f4;
  color: #a3a3a3;
  cursor: not-allowed;
}

.pui-btn-default {
  background: #fff;
  border-color: #d4d4d4;
  color: #111;
}

.pui-btn-default:hover {
  border-color: #111;
}

.pui-btn-primary {
  background: #111;
  color: #fff;
}

.pui-btn-primary:hover {
  background: #000;
}

.pui-btn-danger {
  background: #fff;
  border-color: #111;
  color: #111;
}

.pui-btn-danger:hover {
  background: #111;
  color: #fff;
}

/* ---------- 运行日志抽屉（默认隐藏，Ctrl+` 切换） ---------- */
.panel-log {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.panel-log[hidden] {
  display: none;
}

.panel-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #ececec;
  background: #111;
  color: #fff;
}

.panel-log-title {
  font-size: 13px;
  font-weight: 600;
}

.panel-log-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.panel-log-tools .pui-btn {
  padding: 4px 10px;
  font-size: 12px;
}

.panel-log-list {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #111;
  color: #eee;
}

.panel-log-entry {
  padding: 4px 0;
  border-bottom: 1px solid #222;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-log-entry .panel-log-level {
  font-weight: 700;
  margin-right: 6px;
}

.panel-log-entry[data-level="error"] {
  color: #ff9c9c;
}

.panel-log-entry[data-level="warn"] {
  color: #ffd479;
}

.panel-log-entry[data-level="debug"] {
  color: #9a9a9a;
}

.panel-log-empty {
  padding: 14px;
  color: #888;
  font-size: 12px;
  text-align: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .panel-header-inner {
    padding: 24px 16px 20px;
  }

  .panel-header h1 {
    font-size: 22px;
  }

  .panel-main {
    padding: 16px;
  }

  .panel-content {
    padding: 16px;
  }

  .pui-card {
    padding: 14px;
  }

  .pui-form-grid {
    grid-template-columns: 1fr;
  }
}
