/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #22262f;
  --bg-sidebar: #131620;
  --border: #2a2e3a;
  --text: #e4e6eb;
  --text-dim: #8b8f9a;
  --text-muted: #5c606b;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --accent-bg: rgba(74, 222, 128, 0.1);
  --blue: #60a5fa;
  --purple: #c084fc;
  --orange: #fb923c;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 8px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.logo { font-size: 24px; line-height: 1; }

.sidebar-header h1 { font-size: 15px; font-weight: 700; }
.subtitle { font-size: 11px; color: var(--accent); font-weight: 500; }

.stats-section { padding: 14px 20px; border-bottom: 1px solid var(--border); }

.stat-card {
  background: var(--accent-bg);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
}

.stat-value { display: block; font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.filter-section { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.filter-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }

.category-list { display: flex; flex-direction: column; gap: 2px; }

.category-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.category-btn:hover { background: var(--bg-hover); color: var(--text); }
.category-btn.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.cat-count {
  background: var(--bg-card);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
}

.category-btn.active .cat-count { background: rgba(74, 222, 128, 0.2); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; }

.tag-chip {
  padding: 3px 8px;
  border-radius: 16px;
  font-size: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s ease;
  font-family: inherit;
}

.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
}

.version { opacity: 0.6; }

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  z-index: 50;
}

.search-box { position: relative; flex: 1; max-width: 450px; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

#search-input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

.topbar-info { font-size: 11px; color: var(--text-dim); white-space: nowrap; margin-left: 16px; }

/* ── Table ────────────────────────────────────────────────────── */
.table-container {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.article-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.article-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.article-table th {
  background: var(--bg-sidebar);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.article-table th:first-child { text-align: center; }
.article-table th:last-child { text-align: center; }

.article-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s ease;
}

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

.article-table td {
  padding: 10px 12px;
  vertical-align: top;
  color: var(--text-dim);
}

.article-table td:nth-child(1) { text-align: center; color: var(--text-muted); font-size: 11px; }

/* Title column */
.article-table td:nth-child(2) {
  color: var(--text);
  font-weight: 500;
  max-width: 400px;
}

/* Author column */
.article-table td:nth-child(3) {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Date column */
.article-table td:nth-child(4) {
  white-space: nowrap;
  font-size: 11px;
}

/* Journal column */
.article-table td:nth-child(5) {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

/* DOI link */
.article-table td:nth-child(8) { text-align: center; }
.doi-icon {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.doi-icon:hover { color: var(--accent-dim); }

/* Category Badge */
.cat-badge {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: inline-block;
}

.cat-ai-vet { background: rgba(96,165,250,0.15); color: var(--blue); }
.cat-aivet { background: rgba(192,132,252,0.15); color: var(--purple); }
.cat-epivet { background: rgba(74,222,128,0.15); color: var(--accent); }
.cat-pvm { background: rgba(251,146,60,0.15); color: var(--orange); }
.cat-ted { background: rgba(248,113,113,0.15); color: var(--red); }

/* Inline tags */
.inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.inline-tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.loading { text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-hover);
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close:hover { background: var(--red); color: white; }

.modal h2 { font-size: 17px; font-weight: 700; line-height: 1.4; margin-bottom: 12px; padding-right: 36px; }

.modal-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.modal .meta-row { display: flex; gap: 8px; font-size: 12px; margin-bottom: 6px; align-items: baseline; }
.modal .meta-label { color: var(--text-muted); min-width: 70px; font-weight: 500; }
.modal .meta-value { color: var(--text); }

.modal-abstract {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}

.doi-link {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--accent-bg);
  border: 1px solid rgba(74,222,128,0.3);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.doi-link:hover { background: rgba(74,222,128,0.2); }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  #app { flex-direction: column; }
  .main-content { margin-left: 0; }
  .article-table { font-size: 11px; }
  .article-table th, .article-table td { padding: 6px 8px; }
}
