/* =========================================================
   Outfit font via local files
   ========================================================= */
/* outfit-300 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300;
  src: url('./assets/fonts/outfit-v15-latin-300.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* outfit-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  src: url('./assets/fonts/outfit-v15-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* outfit-500 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  src: url('./assets/fonts/outfit-v15-latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* outfit-700 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  src: url('./assets/fonts/outfit-v15-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* =========================================================
   CSS Custom Properties
   ========================================================= */
:root {
  --color-primary: #66267b;
  --color-dark: #000000;
  --color-accent-yellow: #c9d52d;
  --color-accent-cyan: #00cccc;
  --color-accent-orange: #e84a18;
  --color-accent-gray: #cccccc;
  --color-hover: #ff33cc;
  --color-accent-dark: #3d0d51;

  --sidebar-width: 260px;
  --panel-width: 33vw;
  --sidebar-bg: #f4f5f5;
  --sidebar-border: #e0d8e8;
  --body-bg: #ffffff;
  --text-main: #1a1a2e;
  --text-muted: #6b6b80;
  --row-alt: #f5f5f5;
  --row-hover-bg: #ebebeb;
  --header-bg: #66267b;
  --header-text: #ffffff;
  --border-light: #cccccc;
  --shadow-panel: 0 4px 32px rgba(102, 38, 123, 0.18);
  --transition-speed: 0.22s;

  --font-size-xxs: 16px;  /* tree labels and count */
  --font-size-xs: 18px;    /* small labels, tags, arrows */
  --font-size-sm: 18px;   /* secondary text, table headers, filters */
  --font-size-base: 18px;     /* main content, inputs, links */
  --font-size-lg: 26px;   /* panel titles */
  --font-size-icon: 28px;   /* icon buttons (e.g. close) */
}

/* =========================================================
   Reset & Base
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 300;
  color: var(--text-main);
  background: var(--body-bg);
  line-height: 1.5;
}

/* =========================================================
   App Shell
   ========================================================= */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* =========================================================
   Sidebar
   ========================================================= */
#sidebar {
  width: var(--sidebar-width);
  min-width: 180px;
/*  background: var(--sidebar-bg); */
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width var(--transition-speed) ease;
}

#sidebar-title {
  padding: 18px 20px 12px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary);
  border-bottom: 1px solid var(--sidebar-border);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition-speed), color var(--transition-speed);
  display: none;
}

#sidebar-toggle:hover {
  background: rgba(102, 38, 123, 0.08);
  color: var(--color-hover);
}

#sidebar.collapsed {
  width: 40px;
  min-width: 0;
}

#sidebar.collapsed #sidebar-title {
  justify-content: center;
  padding: 18px 8px 12px;
}

#sidebar.collapsed #sidebar-title-text,
#sidebar.collapsed #collection-tree {
  display: none;
}

#collection-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent-gray) transparent;
}

#collection-tree::-webkit-scrollbar {
  width: 5px;
}
#collection-tree::-webkit-scrollbar-thumb {
  background: var(--color-accent-gray);
  border-radius: 3px;
}

/* Tree node structure */
.tree-node {
  user-select: none;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px 5px 0;
  cursor: pointer;
  border-radius: 0 20px 20px 0;
  margin-right: 8px;
  transition: background var(--transition-speed), color var(--transition-speed);
  position: relative;
  color: var(--text-main);
}

.tree-node-row:hover {
  background: var(--row-hover-bg);
  color: var(--color-hover);
}

.tree-node-row.active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
}

.tree-node-row.active:hover {
  color: #fff;
  background: var(--color-primary);
}

/* Toggle arrow */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  transition: transform var(--transition-speed);
  cursor: pointer;
  border-radius: 3px;
}

.tree-toggle:hover {
  color: var(--color-hover);
  background: rgba(102, 38, 123, 0.08);
}

.tree-toggle.open {
  transform: rotate(90deg);
}

.tree-toggle.leaf {
  visibility: hidden;
  pointer-events: none;
}

.tree-label {
  flex: 1;
  font-size: var(--font-size-xxs);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-count {
  font-size: var(--font-size-xxs);
  color: var(--text-muted);
  background: rgba(102,38,123,0.08);
  border-radius: 50%;
  padding: 1px 6px;
  flex-shrink: 0;
}

.tree-node-row.active .tree-count {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
}

/* Children container */
.tree-children {
  display: none;
  overflow: hidden;
}

.tree-children.open {
  display: block;
}

/* =========================================================
   Main Area
   ========================================================= */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Filters bar (with integrated search on the right) */
#filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: #faf8fc;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

#search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}

#search-input {
  width: 240px;
  padding: 8px 36px 8px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: var(--font-size-base);
  font-weight: 300;
  border: 1px solid #999;
  border-radius: 40px;
  outline: none;
  background: #fff;
  color: var(--text-main);
  margin-bottom: 0;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

#search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 38, 123, 0.12);
}

#search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: var(--font-size-base);
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color var(--transition-speed), background var(--transition-speed);
}

#search-clear:hover {
  color: var(--color-hover);
  background: rgba(255, 51, 204, 0.07);
}

.filter-label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#filters-bar select {
  font-family: 'Outfit', sans-serif;
  font-size: var(--font-size-sm);
  padding: 5px 28px 5px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2366267b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
  transition: border-color var(--transition-speed);
}

#filters-bar select:focus {
  border-color: var(--color-primary);
}

#reset-filters {
  font-family: 'Outfit', sans-serif;
  font-size: var(--font-size-sm);
  font-weight: 500;
  padding: 5px 14px;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  transition: background var(--transition-speed), color var(--transition-speed);
}

#reset-filters:hover {
  background: var(--color-primary);
  color: #fff;
}

/* Results info */
#results-info {
  padding: 6px 20px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  min-height: 28px;
}

/* =========================================================
   Table Wrapper
   ========================================================= */
#table-wrapper {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent-gray) transparent;
}

#table-wrapper::-webkit-scrollbar {
  width: 6px;
}
#table-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-accent-gray);
  border-radius: 3px;
}

#no-results {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: var(--font-size-base);
}

/* =========================================================
   Table
   ========================================================= */
#publications-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#publications-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

#publications-table th {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 14px;
  text-align: left;
  font-weight: 500;
  font-size: var(--font-size-sm);
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background var(--transition-speed);
}

#publications-table th:hover {
  background: #7d338f;
}

#publications-table th.col-link {
  width: 60px;
  text-align: center;
  cursor: default;
}

#publications-table th[data-col="title"] { width: 65%; }
#publications-table th[data-col="authors"] { width: 16%; }
#publications-table th[data-col="year"] { width: 7%; }
#publications-table th[data-col="type"] { width: 8%; }

.sort-arrow {
  display: inline-block;
  margin-left: 5px;
  opacity: 0.6;
  font-size: var(--font-size-xs);
}

th[aria-sort="ascending"] .sort-arrow,
th[aria-sort="descending"] .sort-arrow {
  opacity: 1;
  color: var(--header-text);
}

/* Table body rows */
#publications-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-speed);
  border-bottom: 1px solid var(--border-light);
}

#publications-table tbody tr:nth-child(even) {
  background: var(--row-alt);
}

#publications-table tbody tr:hover {
  background: var(--row-hover-bg);
}

 /*
#publications-table tbody tr:hover td {
 color: var(--color-hover); 
}

#publications-table tbody tr:hover td.cell-link a {
  color: var(--color-hover);
}
*/


#publications-table td {
  padding: 15px 10px;
  font-size: var(--font-size-sm);
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-speed);
}

#publications-table td.cell-title {
  white-space: normal;
  word-break: break-word;
  font-weight: 300;
  line-height: 1.4;
}

#publications-table td.cell-authors {
  white-space: normal;
  word-break: break-word;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

#publications-table td.cell-year {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

#publications-table td.cell-type {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  white-space: normal;
  word-break: break-word;
}

#publications-table td.cell-link {
  text-align: center;
  vertical-align: middle;
}

#publications-table td.cell-link a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--font-size-base);
  transition: color var(--transition-speed);
  display: inline-block;
  padding: 2px 4px;
}

#publications-table td.cell-link a:hover {
  color: var(--color-hover);
}

/* =========================================================
   Detail Panel
   ========================================================= */
#panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.18);
  z-index: 90;
  transition: opacity var(--transition-speed);
}

#panel-overlay.visible {
  display: block;
}

#detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  min-width: 360px;
  max-width: 95vw;
  height: 100vh;
  background: #fff;
  box-shadow: var(--shadow-panel);
  z-index: 100;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 28px 24px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent-gray) transparent;
}

#detail-panel.open {
  transform: translateX(0);
}

#detail-panel::-webkit-scrollbar {
  width: 5px;
}
#detail-panel::-webkit-scrollbar-thumb {
  background: var(--color-accent-gray);
  border-radius: 3px;
}

#panel-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: var(--font-size-icon);
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color var(--transition-speed), background var(--transition-speed);
}

#panel-close:hover {
  color: var(--color-hover);
  background: rgba(255, 51, 204, 0.07);
}

#panel-content {
  padding-top: 8px;
}

.panel-field {
  margin-bottom: 18px;
}

.panel-field-label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.panel-field-value {
  font-size: var(--font-size-base);
  color: var(--text-main);
  line-height: 1.55;
  word-break: break-word;
}

.panel-field-value a {
  color: var(--color-accent-cyan);
  text-decoration: none;
  word-break: break-all;
}

.panel-field-value a:hover {
  color: var(--color-hover);
  text-decoration: underline;
}

.panel-title {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 20px;
  padding-right: 28px;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 12px;
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.panel-tag {
  font-size: var(--font-size-xs);
  padding: 3px 10px;
  background: rgba(102, 38, 123, 0.08);
  color: var(--color-primary);
  border-radius: 12px;
  font-weight: 500;
}

.panel-abstract {
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

/* =========================================================
   Loading / Spinner
   ========================================================= */
#loading-indicator {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.85);
  z-index: 200;
  flex-direction: column;
  gap: 16px;
  font-size: var(--font-size-base);
  color: var(--color-primary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--color-accent-gray);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 200px;
  }
}

@media (max-width: 680px) {
  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  #sidebar {
    width: 100%;
    min-width: 0;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  #main {
    overflow: visible;
  }

  #table-wrapper {
    overflow-x: auto;
  }

  #publications-table th[data-col="type"],
  #publications-table td.cell-type {
    display: none;
  }

  #detail-panel {
    width: 100vw;
    max-width: 100vw;
  }

  :root {
    --panel-width: 100vw;
  }
}
