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

html { font-size: 16px; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f6fa;
  color: #1a1a2e;
  min-height: 100vh;
}

a { color: #3b5bdb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

header h1 { font-size: 2rem; letter-spacing: -.5px; }
header p   { margin-top: .4rem; opacity: .75; font-size: .95rem; }

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ── Search ───────────────────────────────────────────────────────────── */
#search-section {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  margin-bottom: 1.5rem;
}

#search-section label {
  display: block;
  font-weight: 600;
  margin-bottom: .5rem;
}

.search-hint {
  margin-top: .6rem;
  font-size: .82rem;
  color: #868e96;
}

#search-form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

#search-input {
  flex: 1 1 260px;
  padding: .6rem .9rem;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color .2s;
}
#search-input:focus {
  outline: none;
  border-color: #3b5bdb;
  box-shadow: 0 0 0 3px rgba(59,91,219,.15);
}

button[type="submit"] {
  padding: .6rem 1.4rem;
  background: #3b5bdb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
button[type="submit"]:hover { background: #2f4bc0; }

/* ── Author picker ────────────────────────────────────────────────────── */
#author-select {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  margin-bottom: 1.5rem;
}

#author-select h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #495057;
}

#author-list {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.author-btn {
  padding: .45rem 1rem;
  background: #e7f5ff;
  color: #1971c2;
  border: 1px solid #a5d8ff;
  border-radius: 20px;
  cursor: pointer;
  font-size: .9rem;
  transition: background .15s, border-color .15s;
}
.author-btn:hover { background: #d0ebff; border-color: #74c0fc; }

/* ── Loading ──────────────────────────────────────────────────────────── */
#loading {
  text-align: center;
  padding: 2rem;
  color: #495057;
}

.spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 4px solid #dee2e6;
  border-top-color: #3b5bdb;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: .75rem;
}

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

/* ── Status messages ──────────────────────────────────────────────────── */
.status-msg {
  padding: .85rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: .95rem;
}
.status-info  { background: #e7f5ff; color: #1864ab; border: 1px solid #a5d8ff; }
.status-error { background: #fff5f5; color: #c92a2a; border: 1px solid #ffc9c9; }

/* ── Publication histogram ────────────────────────────────────────────── */
#chart-section {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.25rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  margin-bottom: 1.5rem;
}

#chart-section h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 0.5rem;
}

.pub-chart-canvas {
  width: 100%;
  height: 300px;
}

@media (max-width: 600px) {
  .pub-chart-canvas { height: 260px; }
}

/* ── Controls bar ─────────────────────────────────────────────────────── */
#controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}

#controls-bar label {
  font-size: .875rem;
  font-weight: 500;
  color: #495057;
}

#controls-bar select {
  padding: .35rem .65rem;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: .875rem;
  background: #fff;
  cursor: pointer;
}
#controls-bar select:focus {
  outline: none;
  border-color: #3b5bdb;
  box-shadow: 0 0 0 2px rgba(59,91,219,.15);
}

/* ── Summary bar ──────────────────────────────────────────────────────── */
#summary-bar {
  background: #fff;
  border-radius: 8px;
  padding: .65rem 1rem;
  margin-bottom: 1rem;
  font-size: .875rem;
  color: #495057;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ── Results table ────────────────────────────────────────────────────── */
#results-section {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  overflow: hidden;
}

#results-header {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1px solid #e9ecef;
}

#results-header h2 { font-size: 1.1rem; color: #1a1a2e; }
#results-header h2 span { color: #3b5bdb; }

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

thead th {
  background: #f8f9fa;
  text-align: left;
  padding: .7rem 1rem;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6c757d;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid #f1f3f5; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8f9fa; }

tbody td { padding: .65rem 1rem; vertical-align: top; }

td:first-child { white-space: nowrap; color: #868e96; font-size: .85rem; }

.pub-title { max-width: 420px; line-height: 1.4; }
.pub-venue { 
  white-space: nowrap; 
  font-size: .85rem; 
  color: #495057; 
  max-width: 120px; 
  overflow: hidden;
  text-overflow: ellipsis;
}
.pub-type  { white-space: nowrap; font-size: .82rem; color: #868e96; }
.pub-rank  { text-align: center; white-space: nowrap; }

/* ── Ranking badges ───────────────────────────────────────────────────── */
.rank-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.rank-astar   { background: #d3f9d8; color: #1a7a32; border: 1px solid #8ce99a; }
.rank-a       { background: #dbe4ff; color: #2f4bc0; border: 1px solid #91a7ff; }
.rank-b       { background: #fff3bf; color: #7d5b00; border: 1px solid #ffe066; }
.rank-c       { background: #fff0f6; color: #a61e4d; border: 1px solid #faa2c1; }
.rank-journal { background: #f3f0ff; color: #5f3dc4; border: 1px solid #d0bfff; }
.rank-unknown { background: #f1f3f5; color: #868e96; border: 1px solid #dee2e6; }

/* ── Legend ───────────────────────────────────────────────────────────── */
#legend {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  font-size: .85rem;
  color: #495057;
}

#legend h3 { font-size: .9rem; font-weight: 700; margin-bottom: .6rem; }

.legend-items { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }

.legend-item  { display: flex; align-items: center; gap: .4rem; }

.methodology {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed #dee2e6;
  line-height: 1.5;
  color: #868e96;
  font-size: 0.8rem;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: .8rem;
  color: #adb5bd;
  margin-top: 2rem;
}

footer a { color: #adb5bd; }
footer a:hover { color: #495057; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  header h1 { font-size: 1.5rem; }
  .pub-title { max-width: 200px; }
  .pub-venue { max-width: 90px;  overflow: hidden; text-overflow: ellipsis; }
}
