/* ========================================
   BRAIN Platform - GitHub Style Dark Theme
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* GitHub Dark palette */
  --bg-canvas: #0d1117;
  --bg-primary: #161b22;
  --bg-secondary: #1c2128;
  --bg-overlay: #22272e;
  --bg-inset: #0d1117;
  --border: #30363d;
  --border-muted: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --accent-fg: #58a6ff;
  --accent-blue: #1f6feb;
  --accent-green: #3fb950;
  --accent-purple: #a371f7;
  --accent-orange: #f0883e;
  --accent-red: #f85149;
  --accent-yellow: #d29922;

  /* Shadows as borders (GitHub style) */
  --shadow-border: 0 0 0 1px #30363d;
  --shadow-card: 0 0 0 1px #30363d, 0 1px 0 1px rgba(0,0,0,0.1);
  --shadow-focus: 0 0 0 3px rgba(56,139,253,0.4);

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ========================================
   LAYOUT
   ======================================== */

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  width: 100%;
}

/* ========================================
   TOP NAVIGATION (GitHub Header)
   ======================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.header-logo svg { color: var(--text-primary); }

.header-search {
  flex: 1;
  max-width: 320px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-focus);
}
.search-input::placeholder { color: var(--text-tertiary); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-nav a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent-green);
  border-color: rgba(240,246,252,0.1);
  color: #fff;
}
.btn-primary:hover { background: #2ea043; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--bg-secondary);
  border-color: var(--text-tertiary);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }

/* ========================================
   PAGE LAYOUT
   ======================================== */

.page-main {
  flex: 1;
  padding: 40px 0 80px;
}

.page-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}
.sidebar-item:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
  text-decoration: none;
}
.sidebar-item.active {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.sidebar-item svg { flex-shrink: 0; }

.sidebar-section {
  margin-top: 24px;
}
.sidebar-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 12px;
  margin-bottom: 6px;
}

/* ========================================
   MAIN CONTENT - REPO LIST STYLE
   ======================================== */

.main-content {}

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

.content-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.content-meta {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ========================================
   FILTER BAR (GitHub Tab style)
   ======================================== */

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.filter-tabs {
  display: flex;
  gap: 0;
  border-bottom: none;
}

.filter-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.filter-tab.active {
  color: var(--text-primary);
  background: var(--bg-primary);
  border-color: var(--border);
}

.tab-count {
  font-size: 12px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(177,186,196,0.2);
  color: var(--text-secondary);
}

/* ========================================
   ARTICLE LIST (GitHub repo list style)
   ======================================== */

.article-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.article-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-primary);
  transition: background 0.2s;
  cursor: pointer;
}
.article-item:last-child { border-bottom: none; }
.article-item:hover { background: var(--bg-secondary); }

.article-item-main { flex: 1; min-width: 0; }

.article-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.article-item-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-top: 2px;
}

.article-item-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-fg);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-item-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.article-item-cover {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.article-item-cover-placeholder {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 24px;
  color: var(--text-tertiary);
}

/* Tags & Badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.2s;
}

.tag-blue {
  background: rgba(56,139,253,0.15);
  color: #79c0ff;
  border-color: rgba(56,139,253,0.4);
}
.tag-green {
  background: rgba(63,185,80,0.15);
  color: #7ee787;
  border-color: rgba(63,185,80,0.4);
}
.tag-purple {
  background: rgba(163,113,247,0.15);
  color: #d2a8ff;
  border-color: rgba(163,113,247,0.4);
}
.tag-orange {
  background: rgba(240,136,62,0.15);
  color: #ffa657;
  border-color: rgba(240,136,62,0.4);
}
.tag-red {
  background: rgba(248,81,73,0.15);
  color: #ff7b72;
  border-color: rgba(248,81,73,0.4);
}
.tag-yellow {
  background: rgba(210,153,34,0.15);
  color: #e3b341;
  border-color: rgba(210,153,34,0.4);
}

.tag-gray {
  background: rgba(177,186,196,0.15);
  color: #8b949e;
  border-color: rgba(177,186,196,0.3);
}

.meta-item {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-item svg { flex-shrink: 0; }

/* ========================================
   SKELETON LOADING
   ======================================== */

.skeleton {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  animation: pulse 1.5s ease-in-out infinite;
}
.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: var(--bg-secondary);
  margin-bottom: 8px;
}
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-line.w-40 { width: 40%; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========================================
   HERO SECTION (Landing page)
   ======================================== */

.hero {
  text-align: center;
  padding: 80px 0 60px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.hero-title {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1.1;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.hero-title span {
  background: linear-gradient(135deg, #58a6ff, #a371f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto 32px;
  font-weight: 400;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-large {
  padding: 10px 24px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.hero-stats {
  display: flex;
  gap: 32px;
  justify-content: center;
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--border-muted);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 32px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ========================================
   CATEGORY Pills
   ======================================== */

.category-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.category-pill {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.category-pill:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.category-pill.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

/* ========================================
   FOOTER
   ======================================== */

.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-links a:hover { color: var(--text-secondary); }

/* ========================================
   EMPTY / LOADING STATES
   ======================================== */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
  .page-grid {
    grid-template-columns: 1fr;
  }
  .sidebar { display: none; }
  .content-wrapper { padding: 0 16px; }
  .hero-title { font-size: 40px; }
}

@media (max-width: 768px) {
  .header-nav { display: none; }
  .header-search { max-width: 200px; }
  .hero-title { font-size: 32px; letter-spacing: -1px; }
  .hero-desc { font-size: 16px; }
  .hero-stats { flex-wrap: wrap; gap: 20px; }
}


/* ========================================
   ARTICLE DETAIL PAGE
   ======================================== */

.main-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-logo svg {
  width: 32px;
  height: 32px;
}

.navbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.navbar-clock {
  font-size: 14px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-username {
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

/* Detail Page */

.detail-container {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 24px;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-back:hover {
  border-color: var(--accent-fg);
  color: var(--accent-fg);
}

.btn-back svg {
  width: 16px;
  height: 16px;
}

.detail-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.detail-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-muted);
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-meta-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}

.detail-meta-item strong {
  color: var(--text-primary);
  font-weight: 500;
}

.detail-cover {
  margin-bottom: 24px;
}

.detail-cover img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.detail-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-muted);
}

.article-tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent-blue);
  color: white;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-source:hover {
  opacity: 0.85;
}

@media (max-width: 768px) {
  .detail-container {
    padding: 16px;
  }
  .detail-card {
    padding: 20px;
  }
  .detail-title {
    font-size: 20px;
  }
  .detail-meta {
    gap: 12px;
  }
}

/* Markdown 渲染样式 - 用于 article.html detailContent */
.detail-content h1 { font-size: 24px; font-weight: 700; margin: 0 0 16px; color: var(--text-primary); line-height: 1.3; }
.detail-content h2 { font-size: 18px; font-weight: 600; margin: 24px 0 12px; color: var(--text-primary); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.detail-content h3 { font-size: 16px; font-weight: 600; margin: 18px 0 8px; color: var(--text-primary); }
.detail-content p { margin: 10px 0; line-height: 1.75; color: var(--text-primary); }
.detail-content strong { color: var(--accent-green); font-weight: 600; }
.detail-content em { color: var(--text-secondary); font-style: italic; }
.detail-content a { color: var(--accent-green); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.detail-content a:hover { border-bottom-color: var(--accent-green); }
.detail-content ul, .detail-content ol { margin: 10px 0 10px 24px; }
.detail-content li { margin: 4px 0; line-height: 1.7; }
.detail-content code { background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px; font-family: 'SF Mono', Monaco, monospace; font-size: 0.9em; color: var(--accent-green); }
.detail-content pre { background: var(--bg-secondary); padding: 12px 16px; border-radius: 6px; overflow-x: auto; }
.detail-content blockquote { border-left: 3px solid var(--accent-green); padding-left: 16px; margin: 12px 0; color: var(--text-secondary); }
.detail-content img { max-width: 100%; height: auto; border-radius: 6px; margin: 12px 0; }
.detail-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.detail-content table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.detail-content th, .detail-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.detail-content th { background: var(--bg-secondary); font-weight: 600; }
