/* ============================================
   编辑器专用样式
   ============================================ */

/* ---------- 编辑器头部 ---------- */
.editor-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-search);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: 56px;
}

.editor-header__inner {
  max-width: 100%;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-header__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.editor-header__back {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.editor-header__back:hover {
  color: var(--accent);
}

.editor-header__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.editor-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
  color: var(--text-primary);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn--danger {
  color: #ef4444;
  border-color: #fca5a5;
}

.btn--danger:hover {
  background: #fef2f2;
}

[data-theme="dark"] .btn--danger:hover {
  background: #451a1a;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--bg-hover);
}

.btn--sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.btn--full {
  width: 100%;
  justify-content: center;
}

/* ---------- 主布局 ---------- */
.editor-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 56px);
}

/* ---------- 侧边栏 ---------- */
.editor-sidebar {
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.editor-sidebar__header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.editor-sidebar__search {
  padding: 0 12px 12px;
}

.editor-sidebar__search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

.editor-sidebar__search input:focus {
  border-color: var(--accent);
}

.editor-post-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.editor-post-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.editor-post-item:hover {
  background: var(--bg-hover);
}

.editor-post-item.active {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
}

.editor-post-item__title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
  line-height: 1.3;
}

.editor-post-item__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.editor-sidebar__divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 16px;
}

.editor-sidebar__section {
  padding: 12px 16px;
}

.editor-sidebar__section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

/* ---------- 编辑区域 ---------- */
.editor-content {
  overflow-y: auto;
  background: var(--bg-primary);
}

.editor-panel {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 40px;
}

.editor-panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.editor-panel__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- 输入框 ---------- */
.editor-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

.editor-input:focus {
  border-color: var(--accent);
}

.editor-input--title {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid var(--border-color);
  border-radius: 0;
  background: transparent;
}

.editor-input--title:focus {
  border-bottom-color: var(--accent);
}

.editor-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
  line-height: 1.6;
}

.editor-textarea:focus {
  border-color: var(--accent);
}

.editor-textarea--content {
  min-height: 400px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.7;
  tab-size: 2;
}

/* ---------- Meta 区域 ---------- */
.editor-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 12px;
  margin-bottom: 16px;
}

.editor-meta__item label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ---------- Tabs ---------- */
.editor-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.editor-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.editor-tab:hover {
  color: var(--text-primary);
}

.editor-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- 工具栏 ---------- */
.editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-secondary);
  flex-wrap: wrap;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s;
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 4px 4px;
}

.editor-write .editor-textarea--content {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ---------- 预览区 ---------- */
.editor-preview {
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  min-height: 300px;
}

/* ---------- 空状态 ---------- */
.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
}

.editor-empty__icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.editor-empty h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.editor-empty p {
  font-size: 0.95rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: #10b981;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
  z-index: 999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #ef4444;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .editor-main {
    grid-template-columns: 1fr;
  }

  .editor-sidebar {
    position: fixed;
    left: -280px;
    top: 56px;
    bottom: 0;
    width: 280px;
    z-index: 50;
    transition: left 0.3s ease;
  }

  .editor-sidebar.open {
    left: 0;
  }

  .editor-panel {
    padding: 20px 16px;
  }

  .editor-meta {
    grid-template-columns: 1fr;
  }

  .editor-panel__header {
    flex-direction: column;
  }
}
