/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
}

/* Main Container */
#container {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Graph Wrapper */
#graph-wrapper {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f8fafc 100%);
}

#graph-container {
  width: 100%;
  height: 100%;
  background: transparent;
}

/* ── D3 SVG fills the container ── */
#graph-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Node hover via SVG class (D3 attaches .node-g) ── */
.node-g { cursor: pointer; }

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 100;
  transition: opacity 0.3s ease;
}

/* "hidden" class used by graph.js to dismiss the loader */
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.loading-content p {
  color: #64748b;
  font-weight: 500;
}

.spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid #e0e7ff;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Floating Controls */
.controls {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.control-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 15px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.control-btn:hover {
  border-color: #a5b4fc;
  box-shadow: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  transform: translateY(-1px);
}

.control-btn:active {
  transform: translateY(0);
}

.control-btn .icon {
  font-size: 1rem;
}

/* Legend */
.legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  max-width: 18rem;
  box-shadow: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  z-index: 10;
}

.legend h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.75rem;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-item span {
  font-size: 0.875rem;
  color: #64748b;
}

/* Sidebar */
#sidebar {
  width: 24rem;
  background: white;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 6px rgba(0,0,0,0.02);
}

/* Search Container */
.search-container {
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
}

.search-wrapper {
  position: relative;
}

#search {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  outline: none;
}

#search:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  color: #94a3b8;
  pointer-events: none;
}

/* Paper Details */
.paper-details {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
}

.empty-icon {
  width: 5rem;
  height: 5rem;
  background: #f1f5f9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.empty-icon svg {
  width: 2.5rem;
  height: 2.5rem;
  color: #94a3b8;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
}

/* Paper Content */
.paper-content {
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.paper-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
  margin-bottom: 1.25rem;
}

/* Metadata Cards */
.metadata-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.metadata-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.metadata-row {
  display: flex;
  gap: 0.75rem;
}

.metadata-row .metadata-card {
  flex: 1;
}

.metadata-row .metadata-card:last-child {
  flex: 0 0 auto;
  min-width: 5rem;
}

.metadata-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.metadata-value {
  font-size: 0.875rem;
  color: #334155;
}

.cluster-card {
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border-color: #c7d2fe;
}

.cluster-label { color: #4338ca; }

.cluster-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cluster-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.cluster-name {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Notes */
.notes-container {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.notes-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.notes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes-list li {
  font-size: 0.875rem;
  color: #334155;
  display: flex;
  align-items: flex-start;
  line-height: 1.5;
}

.notes-list li::before {
  content: "•";
  color: #f59e0b;
  font-weight: bold;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

/* Read Paper Button */
.read-paper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: #4f46e5;
  color: white;
  font-weight: 500;
  border-radius: 0.5rem;
  text-decoration: none;
  box-shadow: 0 4px 6px rgba(79,70,229,0.2);
  transition: all 0.2s ease;
}

.read-paper-btn:hover {
  background: #4338ca;
  box-shadow: 0 10px 15px rgba(79,70,229,0.3);
  transform: translateY(-1px);
}

.read-paper-btn:active { transform: translateY(0); }

.read-paper-btn svg {
  width: 1rem;
  height: 1rem;
}

/* Scrollbar */
.paper-details::-webkit-scrollbar        { width: 0.5rem; }
.paper-details::-webkit-scrollbar-track  { background: #f8fafc; }
.paper-details::-webkit-scrollbar-thumb  { background: #cbd5e1; border-radius: 0.25rem; }
.paper-details::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.cluster-panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
 
.cluster-panel-name {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}
 
.cluster-panel-desc {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 1rem;
}
 
.cluster-paper-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  margin-top: 0.5rem;
}
 
.cluster-paper-list li {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.8rem;
  line-height: 1.4;
}
 
.cp-year {
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
}
 
.cp-title {
  color: #334155;
}
 
.author-tag {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  color: #475569;
  margin: 2px 2px 2px 0;
}

.author-tag > a {
  text-decoration: none;
}
 
.author-count {
  color: #94a3b8;
}
