/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* 布局 */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 30px;
  padding: 30px 0;
}

/* 头部导航 */
header {
  background: white;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  color: var(--text);
  font-weight: 500;
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
}

.search-box input {
  padding: 8px 14px 8px 38px;
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 240px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  background: var(--bg);
}

.search-box input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

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

/* 卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* 文章卡片 */
.post-card {
  padding: 24px;
  margin-bottom: 20px;
}

.post-card:last-child {
  margin-bottom: 0;
}

.post-card h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
  line-height: 1.4;
}

.post-card h2 a {
  color: var(--text);
}

.post-card h2 a:hover {
  color: var(--primary);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.post-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-summary {
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 16px;
}

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

.tag {
  padding: 4px 10px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 12px;
  font-size: 12px;
}

/* 侧边栏 */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.widget {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.widget-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--primary);
  border-radius: 2px;
}

.links-list {
  list-style: none;
}

.links-list li {
  margin-bottom: 10px;
}

.links-list li:last-child {
  margin-bottom: 0;
}

.links-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.links-list a:hover {
  background: var(--bg);
  color: var(--primary);
  transform: translateX(4px);
}

.link-icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* 文章详情 */
.post-detail {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px;
}

.post-detail h1 {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 16px;
}

.post-detail .post-meta {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.post-content {
  line-height: 1.8;
  font-size: 16px;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 24px;
  margin-bottom: 12px;
  line-height: 1.4;
}

.post-content h2 {
  font-size: 1.5rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.post-content h3 {
  font-size: 1.25rem;
}

.post-content p {
  margin-bottom: 16px;
}

.post-content ul,
.post-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.post-content li {
  margin-bottom: 8px;
}

.post-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Fira Code', Consolas, monospace;
}

.post-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-light);
  font-style: italic;
}

.post-content img {
  border-radius: 8px;
  margin: 16px 0;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}

.post-content th {
  background: var(--bg);
  font-weight: 600;
}

/* 评论区 */
.comments-section {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 1.25rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-form {
  margin-bottom: 30px;
  background: var(--bg);
  padding: 20px;
  border-radius: var(--radius);
}

.comment-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.comment-form textarea:focus {
  border-color: var(--primary);
}

.comment-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.comment-form input:focus {
  border-color: var(--primary);
}

.comment-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.comment-form-row input {
  flex: 1;
  min-width: 150px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comment-item {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

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

.comment-author {
  font-weight: 600;
  color: var(--text);
}

.comment-time {
  font-size: 12px;
  color: var(--text-light);
}

.comment-content {
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}

.comment-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.comments-disabled {
  text-align: center;
  padding: 30px;
  color: var(--text-light);
  background: var(--bg);
  border-radius: var(--radius);
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: all 0.2s;
}

.pagination a {
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 页脚 */
footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 40px 0 20px;
  margin-top: 60px;
}

.footer-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 30px;
}

.footer-section h4 {
  color: white;
  margin-bottom: 16px;
  font-size: 1rem;
}

.footer-section p {
  font-size: 14px;
  line-height: 1.7;
}

.footer-section ul {
  list-style: none;
}

.footer-section li {
  margin-bottom: 8px;
}

.footer-section a {
  color: #94a3b8;
  font-size: 14px;
}

.footer-section a:hover {
  color: white;
}

.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 20px 0;
  border-top: 1px solid #334155;
  text-align: center;
  font-size: 13px;
}

/* 广告位 */
.ad-space {
  background: linear-gradient(135deg, #f0f9ff, #fdf4ff);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  border: 2px dashed #cbd5e1;
}

.ad-space-title {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* 管理后台 */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}

.admin-sidebar {
  background: #1e293b;
  color: white;
  padding: 20px 0;
}

.admin-sidebar-menu {
  list-style: none;
}

.admin-sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: #94a3b8;
  transition: all 0.2s;
}

.admin-sidebar-menu li a:hover,
.admin-sidebar-menu li a.active {
  background: #334155;
  color: white;
}

.admin-sidebar-menu li a.active {
  border-left: 3px solid var(--primary);
}

.admin-content {
  padding: 30px;
  background: var(--bg);
}

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

.admin-header h1 {
  font-size: 1.5rem;
}

.admin-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* 表单 */
.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,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-help {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tr:hover {
  background: var(--bg);
}

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

/* 登录页面 */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 1.75rem;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 30px;
  font-size: 14px;
}

.login-card .btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

/* 提示消息 */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 14px;
  color: var(--text-light);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.purple { background: #f3e8ff; }
.stat-icon.orange { background: #ffedd5; }

/* 加载动画 */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

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

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text);
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Markdown编辑器预览 */
.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.editor-preview {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
  max-height: 500px;
}

/* 开关 */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* 移动端菜单 */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}

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

  .sidebar {
    order: 2;
  }

  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    padding: 10px 0;
  }

  .admin-sidebar-menu {
    display: flex;
    overflow-x: auto;
    padding: 0 10px;
  }

  .admin-sidebar-menu li a {
    padding: 10px 16px;
    white-space: nowrap;
  }

  .admin-sidebar-menu li a.active {
    border-left: none;
    border-bottom: 3px solid var(--primary);
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .mobile-menu-btn {
    display: block;
  }

  .search-box input {
    width: 160px;
  }

  .post-detail {
    padding: 24px 20px;
  }

  .post-detail h1 {
    font-size: 1.5rem;
  }

  .post-card {
    padding: 20px;
  }

  .post-card h2 {
    font-size: 1.2rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 30px 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .search-box {
    display: none;
  }
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 选中文字颜色 */
::selection {
  background: var(--primary);
  color: white;
}
