/* ============================================
   Blog Site - 全局样式
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&family=Noto+Serif+SC:wght@400;700&family=ZCOOL+XiaoWei&family=Ma+Shan+Zheng&family=Roboto:wght@400;700&family=Merriweather:wght@400;700&family=Fira+Code:wght@400&display=swap');

/* --- CSS Variables --- */
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --max-width: 800px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Navigation --- */
.navbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand:hover { text-decoration: none; opacity: 0.85; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  list-style: none;
}

.navbar-nav a {
  color: var(--gray-600);
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.navbar-nav a:hover {
  background: var(--gray-100);
  color: var(--gray-800);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { border-color: var(--gray-400); background: var(--gray-50); text-decoration: none; }

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

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* --- Container --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- Cards --- */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gray-800);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-800);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.form-hint {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

.form-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 0.3rem;
  display: none;
}

/* --- Alerts --- */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* --- Post Cards (首页文章列表) --- */
.post-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
}

.post-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--gray-200);
}

.post-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
}

.post-card-title a { color: inherit; }
.post-card-title a:hover { color: var(--primary); text-decoration: none; }

.post-card-meta {
  font-size: 0.8rem;
  color: var(--gray-400);
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.post-card-excerpt {
  font-size: 0.9rem;
  color: var(--gray-600);
  margin-top: 0.75rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--gray-100);
}

/* --- Post Detail --- */
.post-detail { }

.post-detail-header {
  margin-bottom: 2rem;
}

.post-detail-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.post-detail-meta {
  font-size: 0.85rem;
  color: var(--gray-400);
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.post-detail-actions {
  display: flex;
  gap: 0.5rem;
}

.post-detail-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--gray-700);
  word-break: break-word;
}

.post-detail-content h1 { font-size: 1.8rem; margin: 1.2rem 0 0.5rem; font-weight: 700; }
.post-detail-content h2 { font-size: 1.5rem; margin: 1rem 0 0.4rem; font-weight: 700; }
.post-detail-content h3 { font-size: 1.2rem; margin: 0.8rem 0 0.3rem; font-weight: 700; }
.post-detail-content blockquote {
  border-left: 3px solid var(--primary);
  padding: 0.5rem 1rem;
  margin: 0.8rem 0;
  background: var(--gray-50);
  color: var(--gray-600);
}
.post-detail-content pre {
  background: var(--gray-800);
  color: #e5e7eb;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: 'Fira Code', 'Menlo', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.post-detail-content code { background: #f5f5f5; padding: 0.15em 0.35em; border-radius: 3px; font-size: 0.9em; }
.post-detail-content pre code { background: none; padding: 0; }
.post-detail-content ul, .post-detail-content ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.post-detail-content li { margin: 0.25rem 0; }
.post-detail-content hr { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

.post-detail-content img,
.post-detail-media img {
  max-width: 100%;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
}

.post-detail-content video,
.post-detail-media video {
  max-width: 100%;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
}

.post-detail-content iframe,
.post-detail-media iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
  border: none;
}

.media-caption {
  font-size: 0.85rem;
  color: var(--gray-400);
  text-align: center;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

/* --- Media Upload Area --- */
.media-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--gray-50);
}

.media-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.media-upload-area .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.media-preview {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.media-preview-item {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.media-preview-item img,
.media-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Video URL Input --- */
.video-url-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.video-url-row .form-input { flex: 1; }

/* --- Auth Pages --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f9fafb 100%);
  padding: 2rem;
}

.auth-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--gray-500);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--gray-500); }

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading { text-align: center; padding: 2rem; color: var(--gray-400); }

/* --- Utilities --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 640px) {
  .container { padding: 1rem; }
  .post-detail-title { font-size: 1.5rem; }
  .card { padding: 1rem; }
  .auth-card { padding: 1.5rem; }
  .navbar { padding: 0 1rem; }
}
