/* 博客页面专用样式 */

/* 博客卡片样式 */
.blog-card {
  margin-bottom: 0;
}

.blog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.blog-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

#searchPosts {
  min-width: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-weak);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
}

#searchPosts:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

/* 博客文章列表样式 */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 内联编辑器 */
.inline-editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.inline-actions {
  display: flex;
  gap: 8px;
}

.inline-editor .status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.post-item {
  background: var(--surface-weak);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.post-item:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.post-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}

.post-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.post-content {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  background: var(--brand);
  color: #052e16;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.post-time {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* 空状态样式 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
}

/* 模态框样式 */
#postModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

#postModal:not(.show) {
  display: none;
}

#postModal .modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

#postModal .modal-content {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  margin: 0 auto;
}

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

#postModal .modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

#postModal .modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

#postModal .modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-weak);
}

/* 表单样式 */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-weak);
  color: var(--text);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.form-group textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.6;
}

/* 格式选择器样式  */
.format-selector {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.format-option {
  position: relative;
  display: inline-block;
}

.format-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.format-option label {
  display: inline-block;
  background: var(--brand);
  color: #052e16;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.format-option label:hover {
  background: var(--brand-600);
}

.format-option input[type="radio"]:checked + label {
  background: var(--brand-600);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.format-option input[type="radio"]:not(:checked) + label {
  background: var(--surface-weak);
  color: var(--text);
  border: 1px solid var(--border);
}

.format-option input[type="radio"]:not(:checked) + label:hover {
  background: var(--panel);
  border-color: var(--brand);
}

/* Markdown 编辑器包装器 */
.markdown-editor-wrapper {
  margin-top: 8px;
}

/* 确保隐藏的元素不会显示 */
#ieContentMarkdown[hidden],
#ieContentMarkdown[style*="display: none"] {
  display: none !important;
}

#ieContent[hidden],
#ieContent[style*="display: none"] {
  display: none !important;
}

/* 文章内容样式（支持 Markdown 渲染） */
/* Markdown 渲染后的样式在下面的规则中定义 */

.post-content[data-format="markdown"] h1,
.post-content[data-format="markdown"] h2,
.post-content[data-format="markdown"] h3 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: var(--text);
}

.post-content[data-format="markdown"] h1 {
  font-size: 24px;
}

.post-content[data-format="markdown"] h2 {
  font-size: 20px;
}

.post-content[data-format="markdown"] h3 {
  font-size: 18px;
}

.post-content[data-format="markdown"] code {
  background: var(--surface-weak);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.post-content[data-format="markdown"] strong {
  font-weight: 600;
  color: var(--text);
}

.post-content[data-format="markdown"] em {
  font-style: italic;
}

/* 按钮样式 */
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-secondary {
  background: var(--muted);
  color: var(--text);
}

.btn-secondary:hover {
  background: #6b7280;
}

/* 消息提示样式 */
.message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.message.show {
  transform: translateX(0);
}

.message-success {
  background: var(--brand);
}

.message-error {
  background: var(--danger);
}

.message-info {
  background: #3b82f6;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .blog-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .blog-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  #searchPosts {
    min-width: auto;
    width: 100%;
  }
  
  .post-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .post-actions {
    justify-content: flex-end;
  }
  
  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .post-time {
    flex-direction: column;
    gap: 4px;
  }
  
  #postModal {
    padding: 10px;
  }
  
  #postModal .modal-content {
    max-height: 95vh;
    width: 100%;
  }
  
  #postModal .modal-header,
  #postModal .modal-body,
  #postModal .modal-footer {
    padding: 16px;
  }
  
  #postModal .modal-footer {
    flex-direction: column;
    gap: 8px;
  }
  
  #postModal .modal-footer .btn {
    width: 100%;
  }
  
  .message {
    top: 10px;
    right: 10px;
    left: 10px;
    transform: translateY(-100%);
  }
  
  .message.show {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  
  .post-item {
    padding: 16px;
  }
  
  .post-title {
    font-size: 18px;
  }
  
  .post-content {
    font-size: 14px;
  }
  
  .tag {
    font-size: 11px;
    padding: 3px 6px;
  }
  
  .post-time {
    font-size: 11px;
  }
  
  #postModal {
    padding: 5px;
  }
  
  #postModal .modal-content {
    max-height: 98vh;
    width: 100%;
  }
}

/* 深色模式优化 */
[data-theme="light"] .post-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] #postModal .modal-content {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

/* 加载状态 */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Vditor 编辑器样式适配 */
.markdown-editor-wrapper {
  margin-top: 8px;
}

/* Vditor 主容器 */
#ieContentMarkdown.vditor {
  display: flex !important;
  flex-direction: column !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  overflow: hidden;
  min-height: 400px;
}

/* Vditor 工具栏样式适配 */
#ieContentMarkdown .vditor-toolbar {
  background: var(--surface-weak) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  flex-shrink: 0;
}

#ieContentMarkdown .vditor-toolbar__item {
  color: var(--text) !important;
}

#ieContentMarkdown .vditor-toolbar__item:hover {
  background: var(--brand) !important;
  color: white !important;
}

#ieContentMarkdown .vditor-toolbar__item--current {
  background: var(--brand) !important;
  color: white !important;
}

/* Vditor 内容区域 */
#ieContentMarkdown .vditor-content {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Vditor IR 编辑器样式 */
#ieContentMarkdown .vditor-ir {
  background: var(--panel) !important;
  border: none !important;
  border-radius: 0 !important;
  color: var(--text) !important;
  flex: 1;
  min-height: 350px;
}

.vditor-ir__preview {
  color: var(--text) !important;
}

.vditor-ir__marker {
  color: var(--muted) !important;
}

/* Vditor 预览样式 */
.vditor-preview {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

/* 暗色主题优化 */
[data-theme="dark"] #ieContentMarkdown .vditor-toolbar {
  background: #1e1e1e !important;
}

[data-theme="dark"] #ieContentMarkdown .vditor-ir {
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}

/* 亮色主题优化 */
[data-theme="light"] #ieContentMarkdown .vditor-toolbar {
  background: #f9fafb !important;
}

[data-theme="light"] #ieContentMarkdown .vditor-ir {
  background: #ffffff !important;
  color: #1f2937 !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
  #ieContentMarkdown .vditor-toolbar {
    flex-wrap: wrap !important;
  }
  
  #ieContentMarkdown .vditor-toolbar__item {
    padding: 6px !important;
    font-size: 14px !important;
  }
  
  #ieContentMarkdown {
    min-height: 300px;
  }
  
  #ieContentMarkdown .vditor-ir {
    min-height: 250px;
  }
}
