/* ====== 基础样式 ====== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  background: #f5f5f5;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
}

/* ====== 页面切换 ====== */

.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: block;
}

/* ====== 头部 ====== */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1890ff;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 500;
}

.header-icon {
  width: 24px;
  height: 24px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
}

.btn-back {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  padding: 8px;
  cursor: pointer;
}

/* ====== 主内容区 ====== */

.main-content {
  padding: 16px;
  max-width: 100%;
}

/* ====== 输入组 ====== */

.input-group {
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: #1890ff;
}

/* ====== 上传区域 ====== */

.upload-section {
  margin-bottom: 16px;
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:active {
  border-color: #1890ff;
  background: #f0f7ff;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 18px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 14px;
  color: #999;
}

/* ====== 预览容器 ====== */

.preview-container {
  margin-top: 16px;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  color: #666;
}

.preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
}

.preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: #ff4d4f;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ====== 按钮 ====== */

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: #1890ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
  background: #096dd9;
}

.btn-secondary {
  padding: 12px 24px;
  font-size: 14px;
  color: #666;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
}

.btn-text {
  background: transparent;
  border: none;
  color: #1890ff;
  font-size: 14px;
  cursor: pointer;
}

.btn-execute {
  margin-bottom: 24px;
}

/* ====== 任务列表 ====== */

.task-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.task-list {
  min-height: 60px;
}

.empty-hint {
  text-align: center;
  color: #999;
  padding: 20px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.task-item:last-child {
  border-bottom: none;
}

.task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}

.task-dot.queued {
  background: #faad14;
}

.task-dot.running {
  background: #1890ff;
  animation: pulse 1.5s infinite;
}

.task-dot.success {
  background: #52c41a;
}

.task-dot.error {
  background: #ff4d4f;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.task-time {
  font-size: 14px;
  color: #999;
}

.task-status {
  font-size: 14px;
  color: #333;
  flex: 1;
  text-align: right;
}

/* ====== 设置页面 ====== */

.settings-content {
  padding-bottom: 32px;
}

.settings-desc {
  font-size: 14px;
  color: #666;
  margin-bottom: 16px;
  line-height: 1.6;
}

.settings-form {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.form-input:focus {
  border-color: #1890ff;
}

.form-input-number {
  width: 80px;
  text-align: center;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.form-range {
  width: 100%;
  margin-bottom: 8px;
}

.threshold-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.form-actions .btn-primary {
  flex: 1;
}

/* ====== 历史记录 ====== */

.history-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}

.history-status {
  padding: 12px;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #666;
}

.history-status-ok {
  background: #f6ffed;
  color: #52c41a;
}

/* ====== 弹窗 ====== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.modal-show {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #1890ff;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
}

.btn-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(80vh - 56px);
}

.detail-section {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-top: 12px;
  margin-bottom: 8px;
}

.detail-row {
  display: flex;
  margin-bottom: 8px;
  font-size: 14px;
}

.detail-label {
  color: #999;
  min-width: 80px;
}

.detail-value {
  color: #333;
  flex: 1;
}

/* ====== Toast ====== */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: #333;
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  max-width: 80%;
  text-align: center;
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success {
  background: #52c41a;
}

.toast.toast-error {
  background: #ff4d4f;
}

.toast.toast-info {
  background: #1890ff;
}

/* ====== 版本信息 ====== */

.version-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.version-info {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.version-item {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

.version-item:last-child {
  margin-bottom: 0;
}

/* ====== 更新弹窗 ====== */

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid #eee;
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
  flex: 1;
}

.update-info {
  font-size: 14px;
}

.update-row {
  margin-bottom: 12px;
  color: #666;
}

.update-latest {
  color: #52c41a;
  font-weight: 500;
}

.update-changelog {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

.update-changelog-title {
  font-weight: 500;
  margin-bottom: 8px;
  color: #333;
}

.update-changelog-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.update-changelog-item {
  padding: 4px 0;
  color: #666;
  font-size: 14px;
}

.update-changelog-item::before {
  content: '✓ ';
  color: #52c41a;
  margin-right: 8px;
}

/* ====== 响应式适配 ====== */

@media (min-width: 768px) {
  .main-content {
    max-width: 600px;
    margin: 0 auto;
  }

  .preview-item {
    width: 100px;
    height: 100px;
  }

  .modal-content {
    max-width: 500px;
  }
}