/* ─── 按钮系统 ──────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-accent,
.btn-danger {
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: #238636;
  border-color: rgba(63, 185, 80, 0.6);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #2ea043; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-accent {
  background: var(--accent-dim);
  border-color: var(--border-hi);
  color: var(--accent);
}
.btn-accent:hover { background: rgba(63, 185, 80, 0.25); }

.btn-secondary {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-1);
}
.btn-secondary:hover { border-color: var(--text-2); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--text-2); color: var(--text-1); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.4);
  color: #ff7b72;
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.2); }

.btn-primary.small,
.btn-secondary.small,
.btn-ghost.small,
.btn-accent.small,
.btn-danger.small { padding: 5px 10px; font-size: 12px; }

.tiny { padding: 4px 8px !important; font-size: 11px !important; border-radius: 5px !important; }

/* ─── 表单元素 ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  margin-bottom: 12px;
}

label {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input,
select,
textarea {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-1);
  padding: 7px 9px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.15);
}

textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.form-error {
  color: #ff7b72;
  font-size: 12px;
  margin: 2px 0 4px;
}

.form-error.small { font-size: 11px; }

.tips {
  font-size: 11px;
  color: var(--text-3);
  word-break: break-all;
  margin-top: 4px;
}

/* ─── 列表通用样式 ──────────────────────────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  gap: 8px;
}

.item-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-title { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.item-sub { font-size: 12px; color: var(--text-2); }
.muted { font-size: 11px; color: var(--text-3); }
.item-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; }

.cmd-code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-2);
  word-break: break-all;
}

.empty-hint { font-size: 12px; color: var(--text-3); margin: 4px 0 12px; }

/* ─── 子面板 ─────────────────────────────────────────────────────── */
.sub-panel { display: flex; flex-direction: column; gap: 8px; }
.sub-panel-header { display: flex; align-items: center; justify-content: space-between; }
.sub-panel-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-1); }
.sub-form h4 { margin: 4px 0 8px; font-size: 13px; color: var(--text-2); }

/* ─── 脚本管理布局 ──────────────────────────────────────────────── */
.script-layout {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr);
  gap: 10px;
}

.script-list { display: flex; flex-direction: column; gap: 4px; }

.script-item {
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  padding: 6px 10px;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.script-item:hover { background: var(--bg-3); color: var(--text-1); }
.script-item.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.script-editor { display: flex; flex-direction: column; gap: 8px; }
.script-content-label textarea { min-height: 140px; font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ─── 移动端响应 ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .item-row { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }
  .script-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
