/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #ff6b6b;
  --primary-dark: #ee5a5a;
  --secondary: #4ecdc4;
  --success: #51cf66;
  --warning: #ffd93d;
  --danger: #ff6b6b;
  --dark: #2d3436;
  --gray: #636e72;
  --light-gray: #b2bec3;
  --bg: #f8f9fa;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部 */
.header {
  text-align: center;
  padding: 30px 0;
}

.header h1 {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--gray);
  font-size: 16px;
}

/* 步骤指示器 */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 0 30px;
  flex-wrap: wrap;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.4;
  transition: all 0.3s;
}

.step.active {
  opacity: 1;
}

.step.completed {
  opacity: 1;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--light-gray);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.3s;
}

.step.active .step-number,
.step.completed .step-number {
  background: var(--primary);
}

.step-title {
  font-size: 13px;
  color: var(--gray);
}

.step.active .step-title {
  color: var(--primary);
  font-weight: 600;
}

.step-arrow {
  color: var(--light-gray);
  font-size: 20px;
}

/* 主要内容 */
.main-content {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.step-content {
  display: none;
}

.step-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 输入区域 */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.label-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
}

.label-hint {
  font-size: 13px;
  color: var(--gray);
}

/* 文本输入 */
.text-input-wrapper {
  position: relative;
}

.text-input {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
  transition: border-color 0.3s;
  font-family: inherit;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

.text-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.file-btn,
.clear-btn {
  padding: 8px 16px;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
}

.file-btn:hover,
.clear-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
}

/* 图片上传 */
.image-upload-area {
  border: 2px dashed #e9ecef;
  border-radius: var(--radius-sm);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
}

.image-upload-area:hover,
.image-upload-area.dragover {
  border-color: var(--primary);
  background: rgba(255,107,107,0.05);
}

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

.upload-placeholder p {
  color: var(--gray);
  margin: 4px 0;
}

.upload-hint {
  font-size: 12px;
  color: var(--light-gray);
}

/* 图片预览列表 */
.image-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid #e9ecef;
}

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

.image-preview-item .image-index {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.image-preview-item .image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.image-preview-item:hover .image-remove {
  opacity: 1;
}

.image-preview-item .image-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 排版策略 */
.layout-options {
  margin-bottom: 30px;
}

.layout-options h3 {
  margin-bottom: 20px;
  font-size: 18px;
}

.strategy-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.strategy-card {
  padding: 20px;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.strategy-card:hover {
  border-color: var(--primary);
}

.strategy-card.active {
  border-color: var(--primary);
  background: rgba(255,107,107,0.05);
}

.strategy-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.strategy-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.strategy-desc {
  font-size: 13px;
  color: var(--gray);
}

/* 预览区域 */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e9ecef;
}

.preview-header h3 {
  font-size: 18px;
}

.preview-stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--gray);
}

/* 模块列表 */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
}

.module-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: all 0.3s;
}

.module-item:hover {
  border-color: var(--primary);
}

.module-item.dragging {
  opacity: 0.5;
}

.module-index {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.module-content {
  flex: 1;
  min-width: 0;
}

.module-type {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 4px;
}

.module-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.module-image {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--radius-sm);
}

.module-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.module-item:hover .module-actions {
  opacity: 1;
}

.module-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.3s;
}

.module-btn:hover {
  background: var(--primary);
  color: white;
}

/* 发布区域 */
.publish-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.chrome-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 2px solid #e9ecef;
  transition: all 0.3s;
}

.chrome-status.connected {
  background: rgba(81, 207, 102, 0.1);
  border-color: var(--success);
}

.chrome-status.disconnected {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--danger);
}

.status-icon {
  font-size: 24px;
}

.status-text {
  font-size: 14px;
  font-weight: 500;
}

.publish-options {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.publish-log {
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: var(--radius-sm);
  padding: 16px;
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.log-placeholder {
  color: #666;
}

.log-entry {
  margin: 4px 0;
}

.log-entry.success {
  color: #7ee787;
}

.log-entry.error {
  color: #f85149;
}

.log-entry.info {
  color: #79c0ff;
}

/* 按钮 */
.step-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #e9ecef;
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--bg);
  color: var(--dark);
}

.btn-secondary:hover {
  background: #e9ecef;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #40c057;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 底部 */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--gray);
  font-size: 13px;
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
  font-size: 18px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray);
}

.modal-close:hover {
  color: var(--dark);
}

.modal-body {
  padding: 20px;
  flex: 1;
  overflow: auto;
}

.edit-textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
}

.edit-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px;
  border-top: 1px solid #e9ecef;
}

/* 响应式 */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  .header h1 {
    font-size: 24px;
  }
  
  .steps {
    gap: 6px;
  }
  
  .step-number {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .step-title {
    font-size: 11px;
  }
  
  .main-content {
    padding: 20px;
  }
  
  .strategy-cards {
    grid-template-columns: 1fr;
  }
  
  .preview-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .step-actions {
    flex-direction: column;
    gap: 12px;
  }
  
  .btn {
    width: 100%;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ========== 新增样式 ========== */

/* 头部链接 */
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  position: relative;
}

.header h1 {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 0;
}

.header-actions {
  position: absolute;
  right: 0;
}

.header-link {
  color: var(--gray);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-sm);
  transition: all 0.3s;
}

.header-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* 状态栏 */
.status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 2px solid #e9ecef;
  transition: all 0.3s;
  margin-bottom: 20px;
}

.status.connected {
  background: rgba(81, 207, 102, 0.1);
  border-color: var(--success);
}

.status.disconnected {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--danger);
}

/* 编辑器区域 */
.editor-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

#editor {
  min-height: 300px;
  padding: 16px;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-sm);
  outline: none;
  line-height: 1.6;
}

#editor:empty:before {
  content: attr(placeholder);
  color: var(--light-gray);
}

#editor img {
  max-width: 100%;
  display: block;
  margin: 10px 0;
}

.editor-box .actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.action-btn {
  padding: 8px 16px;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.action-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
}

/* 预览区域 */
.preview-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.preview-box h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

#previewStats {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 16px;
}

#moduleList {
  max-height: 400px;
  overflow-y: auto;
}

.module-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.module-item.text .module-content {
  color: var(--dark);
  white-space: pre-line;
}

.module-item.image img,
.module-item.video {
  max-width: 200px;
  border-radius: var(--radius-sm);
}

.module-number {
  min-width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

/* 设置区域 */
.settings {
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.settings label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.settings input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* 发布按钮 */
.publish-btn {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  margin-bottom: 20px;
}

.publish-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.publish-btn:disabled {
  background: var(--light-gray);
  cursor: not-allowed;
}

/* 日志区域 */
.log-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.log-box h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

#publishLog {
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: var(--radius-sm);
  padding: 16px;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.log-entry {
  margin: 4px 0;
}

.log-entry.success {
  color: #7ee787;
}

.log-entry.error {
  color: #f85149;
}

.log-entry.info {
  color: #79c0ff;
}

/* 结果区域 */
.result-box {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.result-box h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.result-card {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.result-title {
  font-size: 14px;
  color: var(--gray);
  margin-bottom: 8px;
}

.result-value {
  display: flex;
  gap: 8px;
}

.result-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 13px;
  color: var(--dark);
}

.copy-btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s;
}

.copy-btn:hover {
  background: var(--primary-dark);
}

/* ========== 登录页面样式 ========== */
.login-page .container {
  max-width: 600px;
}

.login-page h1 {
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-page .info-text {
  text-align: center;
  color: var(--gray);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-page .card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.qrcode-container {
  text-align: center;
  margin-bottom: 24px;
}

.qrcode-img {
  max-width: 100%;
  height: auto;
  border: 1px solid #e9ecef;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.qrcode-container .tip {
  font-size: 13px;
  color: var(--gray);
  margin-top: 12px;
}

.login-page .actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-page .btn {
  width: 100%;
}

.login-page .status-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
}

.login-page .status-message.info {
  background: rgba(121, 192, 255, 0.1);
  color: #0c7cd5;
}

.login-page .status-message.success {
  background: rgba(126, 231, 135, 0.1);
  color: #2f9e44;
}

.login-page .status-message.warning {
  background: rgba(255, 217, 61, 0.1);
  color: #f08c00;
}

.login-page .status-message.error {
  background: rgba(248, 81, 73, 0.1);
  color: #c92a2a;
}

/* 登录成功状态 */
.success-state .card {
  text-align: center;
  padding: 48px 32px;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.success-state h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.success-state p {
  color: var(--gray);
  margin-bottom: 24px;
}
