/* ========== 富文本编辑器样式 ========== */

.rte-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s;
}

.rte-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* 工具栏 */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border-light);
}

.rte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.rte-btn:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--color-primary);
}

.rte-btn.active {
  background: var(--color-primary);
  color: #fff;
}

.rte-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.rte-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

.rte-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  outline: none;
}

.rte-select:hover {
  border-color: var(--color-primary);
}

/* 编辑区域 */
.rte-editor {
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--color-text-primary);
  outline: none;
}

.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.rte-editor h1 { font-size: 1.5rem; font-weight: 600; margin: 0.8em 0 0.4em; }
.rte-editor h2 { font-size: 1.25rem; font-weight: 600; margin: 0.8em 0 0.4em; }
.rte-editor h3 { font-size: 1.0625rem; font-weight: 600; margin: 0.8em 0 0.4em; }
.rte-editor p { margin: 0 0 0.6em; }
.rte-editor ul, .rte-editor ol { margin: 0 0 0.6em; padding-left: 1.8em; }
.rte-editor li { margin-bottom: 0.2em; }
.rte-editor blockquote {
  margin: 0.6em 0;
  padding: 8px 16px;
  border-left: 3px solid var(--color-primary);
  background: var(--color-bg-tertiary);
  border-radius: 0 6px 6px 0;
  color: var(--color-text-secondary);
}
.rte-editor a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rte-editor img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  display: block;
}
.rte-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.875rem;
}
.rte-editor th,
.rte-editor td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
}
.rte-editor th {
  background: var(--color-bg-tertiary);
  font-weight: 600;
  color: var(--color-text-primary);
}
.rte-editor td {
  color: var(--color-text-secondary);
}
.rte-editor video,
.rte-editor iframe {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  display: block;
}
.rte-editor hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}
.rte-editor code {
  background: var(--color-bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'Courier New', monospace;
}

/* 弹窗 */
.rte-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.rte-modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.rte-modal h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--color-text-primary);
}

.rte-modal label {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.rte-modal input,
.rte-modal textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.rte-modal input:focus,
.rte-modal textarea:focus {
  border-color: var(--color-primary);
}

.rte-modal textarea {
  resize: vertical;
  min-height: 60px;
}

.rte-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.rte-modal-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s;
}

.rte-modal-btn-cancel {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.rte-modal-btn-cancel:hover {
  background: var(--color-border-light);
}

.rte-modal-btn-confirm {
  background: var(--color-primary);
  color: #fff;
}

.rte-modal-btn-confirm:hover {
  background: #2563eb;
}

/* 移动端 */
@media (max-width: 768px) {
  .rte-toolbar {
    padding: 6px;
  }

  .rte-btn {
    min-width: 28px;
    height: 28px;
    font-size: 0.8125rem;
  }

  .rte-editor {
    min-height: 240px;
    padding: 14px 16px;
    font-size: 0.875rem;
  }

  .rte-modal {
    width: 92vw;
    padding: 20px;
  }
}

/* Toast 提示 */
.rte-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #1f2937;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

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