/* AMNews - 增材制造情报站 */
:root {
  --primary: #1a1a1a;
  --secondary: #333;
  --accent: #0066cc;
  --accent-light: #e6f0fa;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-tertiary: #888;
  --text-quaternary: #aaa;
  --border: #e0e0e0;
  --border-light: #f0f0f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Accessibility ===== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 10000;
  font-size: 13px;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.brand-text span {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 400;
}

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

.btn-refresh {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-refresh:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-refresh.spinning .icon-refresh {
  animation: spin 1s linear infinite;
}

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

.last-update {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ===== Main Layout ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 88px;
  height: fit-content;
}

.sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

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

.filter-list li {
  margin-bottom: 2px;
}

.filter-btn {
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.filter-btn.active {
  background: var(--primary);
  color: #fff;
}

.filter-count {
  font-size: 11px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.source-list {
  max-height: 400px;
  overflow-y: auto;
}

.source-list::-webkit-scrollbar {
  width: 4px;
}

.source-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
}

.source-item:hover {
  background: var(--bg);
}

.source-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.source-item label {
  cursor: pointer;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-count-badge {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ===== Content Area ===== */
.content {
  min-width: 0;
}

/* Search Bar */
.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.4;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

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

.search-stats {
  font-size: 13px;
  color: var(--text-tertiary);
}

.search-stats b {
  color: var(--text);
  font-weight: 600;
}

.sort-options {
  display: flex;
  gap: 4px;
}

.sort-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.sort-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sort-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Tags */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tag {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

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

.tag.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ===== News Cards ===== */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.news-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: var(--transition);
}

.news-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.news-card:hover::before {
  background: var(--primary);
}

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

.news-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

.news-card:hover .news-title {
  color: var(--accent);
}

.news-lang {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 2px;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.news-cat {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.cat-market { background: #e8f4fd; color: #0066cc; }
.cat-tech { background: #e6f7ed; color: #0a8f4c; }
.cat-event { background: #f3e8ff; color: #7c3aed; }
.cat-industry { background: #fef3c7; color: #b45309; }
.cat-policy { background: #f1f5f9; color: #475569; }

.news-source {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.news-date {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.news-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 12px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.news-kw {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-tertiary);
  transition: var(--transition);
}

.news-kw.highlight {
  background: var(--primary);
  color: #fff;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  padding: 16px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}

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

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

.empty-state p {
  font-size: 14px;
}

/* Footer */
.footer {
  max-width: 1200px;
  margin: 40px auto 0;
  padding: 24px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
  }
  .sidebar-section {
    margin-bottom: 0;
  }
}

@media (max-width: 600px) {
  .header-inner {
    padding: 0 16px;
    height: 56px;
  }
  .brand-text span {
    display: none;
  }
  .main {
    padding: 16px;
  }
  .news-card {
    padding: 16px;
  }
  .news-title {
    font-size: 15px;
  }
}

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.show {
  opacity: 1;
  pointer-events: all;
}

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