/* ===== RESET & VARIABLES ===== */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --card-dark: #1a1a1a;
  --text: #1a1a1a;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --accent: #ff6b35;
  --accent-light: #ff8f5a;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'MiSans', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.page-content {
  padding-top: 80px;
  min-height: calc(100vh - 200px);
}

/* ===== NAVIGATION ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(250,250,250,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-light);
  transition: all 0.3s ease;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 64px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
}
.nav-brand .logo-mark {
  width: 32px; height: 32px; background: var(--card-dark); color: #fff;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.nav-links {
  display: flex; align-items: center; gap: 28px; list-style: none;
}
.nav-links a {
  font-size: 14px; font-weight: 500; color: var(--text-light);
  transition: color 0.2s; position: relative;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a::after {
  content: ''; position: absolute; bottom: -4px; left: 0;
  width: 0; height: 2px; background: var(--accent);
  transition: width 0.25s ease;
}
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }

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

/* Search box */
.nav-search {
  position: relative; display: flex; align-items: center;
}
.nav-search input {
  width: 180px; padding: 8px 14px 8px 36px;
  border: 1px solid var(--border); border-radius: 100px;
  background: var(--card); font-size: 13px;
  transition: all 0.2s;
}
.nav-search input:focus {
  outline: none; border-color: var(--accent); width: 220px;
}
.nav-search svg {
  position: absolute; left: 12px; width: 16px; height: 16px;
  color: var(--text-muted);
}

/* User menu */
.user-menu {
  display: flex; align-items: center; gap: 10px;
  position: relative;
}
.user-menu .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; cursor: pointer;
}
.user-dropdown {
  position: absolute; top: 44px; right: 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px 0; min-width: 160px; display: none;
}
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; padding: 8px 16px;
  font-size: 14px; color: var(--text); background: none; border: none;
  text-align: left; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover {
  background: var(--border-light);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-radius: 100px; font-size: 14px;
  font-weight: 500; border: none; cursor: pointer; transition: all 0.25s;
}
.btn-primary { background: var(--card-dark); color: #fff; }
.btn-primary:hover { background: #333; transform: translateY(-1px); }
.btn-outline {
  background: transparent; color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--border);
}
.btn-outline:hover { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 16px; font-size: 13px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ===== MOBILE MENU ===== */
.mobile-toggle {
  display: none; background: none; border: none;
  width: 36px; height: 36px; align-items: center; justify-content: center;
}

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border-light);
  padding: 48px 0; margin-top: 80px;
  background: var(--card);
}
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.footer-brand { font-size: 16px; font-weight: 600; }
.footer-links { display: flex; gap: 24px; list-style: none; }
.footer-links a { font-size: 14px; color: var(--text-light); transition: color 0.2s; }
.footer-links a:hover { color: var(--text); }
.footer-copy { font-size: 13px; color: var(--text-muted); }

/* ===== CARDS ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  overflow: hidden; transition: all 0.35s cubic-bezier(0.16,1,0.3,1);
  box-shadow: var(--shadow);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.card-image {
  width: 100%; height: 200px; background-size: cover; background-position: center;
  position: relative;
}
.card-image::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4) 100%);
}
.card-body { padding: 24px; }
.card-title {
  font-size: 18px; font-weight: 600; line-height: 1.4;
  margin-bottom: 8px; letter-spacing: -0.3px;
}
.card-text { font-size: 14px; color: var(--text-light); line-height: 1.6; }
.card-meta {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px; font-size: 13px; color: var(--text-muted);
}
.card-meta .dot-sep { width: 3px; height: 3px; background: var(--border); border-radius: 50%; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; padding: 4px 12px; border-radius: 100px;
  font-size: 12px; font-weight: 500;
}
.badge-accent { background: rgba(255,107,53,0.1); color: var(--accent); }
.badge-outline { background: var(--border-light); color: var(--text-light); }

/* ===== TAGS ===== */
.tag {
  display: inline-flex; padding: 4px 12px; border-radius: 100px;
  font-size: 12px; font-weight: 500; background: var(--border-light);
  color: var(--text-light); transition: all 0.2s; cursor: pointer;
}
.tag:hover { background: var(--accent); color: #fff; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 14px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); font-size: 15px; font-family: inherit;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none; border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 120px; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 48px;
}
.pagination button {
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border);
  font-size: 14px; color: var(--text); transition: all 0.2s;
}
.pagination button:hover:not(:disabled) {
  background: var(--card-dark); color: #fff;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 14px; color: var(--text-light); }

/* ===== LOADING ===== */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text-muted);
}
.loading-spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 80px 24px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* ===== MARKDOWN CONTENT ===== */
.markdown-body h1 { font-size: 32px; font-weight: 700; margin: 32px 0 16px; letter-spacing: -0.5px; }
.markdown-body h2 { font-size: 24px; font-weight: 600; margin: 28px 0 14px; letter-spacing: -0.3px; }
.markdown-body h3 { font-size: 20px; font-weight: 600; margin: 24px 0 12px; }
.markdown-body p { margin-bottom: 16px; line-height: 1.8; }
.markdown-body ul, .markdown-body ol { margin: 16px 0; padding-left: 24px; }
.markdown-body li { margin-bottom: 8px; }
.markdown-body pre {
  background: #1e1e2e; color: #cdd6f4; padding: 20px; border-radius: var(--radius);
  overflow-x: auto; margin: 20px 0; font-size: 14px; line-height: 1.6;
}
.markdown-body code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--border-light); padding: 2px 8px; border-radius: 4px;
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent); padding-left: 20px;
  margin: 20px 0; color: var(--text-light); font-style: italic;
}
.markdown-body img { border-radius: var(--radius); margin: 20px 0; }
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-body table {
  width: 100%; border-collapse: collapse; margin: 20px 0;
}
.markdown-body th, .markdown-body td {
  padding: 10px 14px; border: 1px solid var(--border); text-align: left;
}
.markdown-body th { background: var(--border-light); font-weight: 600; }

/* ===== COMMENTS ===== */
.comments-section { margin-top: 48px; padding-top: 48px; border-top: 1px solid var(--border-light); }
.comments-title { font-size: 20px; font-weight: 600; margin-bottom: 24px; }
.comment-form { margin-bottom: 32px; }
.comment-item { padding: 20px 0; border-bottom: 1px solid var(--border-light); }
.comment-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.comment-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600;
}
.comment-author { font-weight: 600; font-size: 14px; }
.comment-date { font-size: 12px; color: var(--text-muted); }
.comment-content { font-size: 15px; line-height: 1.7; color: var(--text); padding-left: 48px; }
.comment-replies { margin-left: 48px; margin-top: 12px; }
.comment-reply-btn {
  font-size: 13px; color: var(--accent); background: none; border: none;
  cursor: pointer; padding: 4px 0;
}

/* ===== ADMIN LAYOUT ===== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; background: var(--card-dark); color: #fff;
  padding: 24px; position: fixed; height: 100vh; overflow-y: auto;
}
.admin-sidebar .brand { font-size: 18px; font-weight: 700; margin-bottom: 32px; }
.admin-nav { list-style: none; }
.admin-nav li { margin-bottom: 4px; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 14px; color: rgba(255,255,255,0.7); transition: all 0.2s;
}
.admin-nav a:hover, .admin-nav a.active {
  background: rgba(255,255,255,0.1); color: #fff;
}
.admin-main {
  margin-left: 240px; flex: 1; padding: 32px;
  background: var(--bg); min-height: 100vh;
}
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 32px;
}
.admin-header h1 { font-size: 24px; font-weight: 600; }

/* Stats cards */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px; margin-bottom: 32px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--text); }
.stat-card .stat-label { font-size: 14px; color: var(--text-light); margin-top: 4px; }
.stat-card .stat-change { font-size: 12px; color: var(--accent); margin-top: 8px; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th { font-weight: 600; color: var(--text-light); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table tr:hover { background: var(--border-light); }
.data-table .actions { display: flex; gap: 8px; }
.data-table .actions button {
  padding: 4px 10px; font-size: 12px; border-radius: 6px;
  border: none; cursor: pointer;
}

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  color: var(--text-light); border: none; background: none;
  cursor: pointer; position: relative;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--accent);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 600px; width: 90%;
  max-height: 80vh; overflow-y: auto;
}
.modal-header { padding: 24px 24px 0; display: flex; justify-content: space-between; }
.modal-header h2 { font-size: 20px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 0 24px 24px; display: flex; gap: 12px; justify-content: flex-end; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .mobile-toggle { display: flex; }
  .nav-search { display: none; }
  .footer-inner { flex-direction: column; gap: 16px; text-align: center; }
  .admin-sidebar { width: 100%; position: relative; height: auto; }
  .admin-main { margin-left: 0; }
  .admin-layout { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
