/* Modern Table Styling */
:root {
  --primary-bg: #f8f9fa;
  --table-bg: #ffffff;
  --border-color: #e1e4e8;
  --header-bg: #f6f8fa;
  --header-text: #24292e;
  --row-hover: #f6f8fa;
  --text-primary: #24292e;
  --text-secondary: #586069;
  --link-color: #0366d6;
  --link-hover: #0256b9;
}

body {
  background-color: var(--primary-bg);
  color: var(--text-primary);
}

.reactable {
  background-color: var(--table-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.reactable table {
  border-spacing: 0;
  width: 100%;
}

/* Header styling */
.reactable .rt-thead {
  background-color: var(--header-bg);
  border-bottom: 2px solid var(--border-color);
}

.reactable .rt-th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  color: var(--header-text);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: 12px;
  border-right: none;
}

/* Cell styling */
.reactable .rt-td {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  border-right: none;
}

/* Row hover effect */
.reactable .rt-tbody .rt-tr:hover {
  background-color: var(--row-hover);
  transition: background-color 0.15s ease;
}

/* Striped rows (optional alternative) */
.reactable .rt-tbody .rt-tr:nth-child(even) {
  background-color: #fafbfc;
}

.reactable .rt-tbody .rt-tr:nth-child(even):hover {
  background-color: var(--row-hover);
}

/* Link styling */
.reactable a.journal-name {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.reactable a.journal-name:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Responsive table container */
.reactable-container {
  margin: 0rem 0;
}

/* Page title styling */
h1.title {
  color: var(--header-text);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* Description text */
.quarto-title-block p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
}

/* Improve overall page container */
#quarto-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Mobile Card Layout */
@media (max-width: 768px) {
  /* Ensure body and html don't allow horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Hide the table header on mobile */
  .reactable .rt-thead {
    display: none;
  }

  /* Make table, tbody, and rows block-level */
  .reactable table,
  .reactable .rt-tbody,
  .reactable .rt-tr {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Ensure reactable doesn't overflow */
  .reactable {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }

  .reactable table {
    table-layout: fixed;
    margin: 0;
  }

  /* Style each row as a card */
  .reactable .rt-tr {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--table-bg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .reactable .rt-tr:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
  }

  /* Remove striped background on mobile */
  .reactable .rt-tbody .rt-tr:nth-child(even) {
    background-color: var(--table-bg);
  }

  /* Make cells block-level and stack vertically */
  .reactable .rt-td {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 12px 16px;
    border-top: none;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }

  /* Ensure content inside cells also wraps */
  .reactable .rt-td > * {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

  .reactable .rt-td:last-child {
    border-bottom: none;
  }

  /* Add labels before each cell content */
  .reactable .rt-td [data-label]:before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
  }

  /* Style for title cell */
  .reactable .rt-td:nth-child(4) {
    font-size: 14px;
  }

  /* Adjust padding for content container on mobile */
  #quarto-content {
    padding: 1rem;
  }

  /* Adjust reactable container margin */
  .reactable-container {
    margin: 1rem 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Remove table border and shadow since cards have their own */
  .reactable {
    border: none;
    box-shadow: none;
    background-color: transparent;
  }

  /* Ensure all container elements respect width */
  #quarto-content > *,
  .quarto-title-block,
  main {
    max-width: 100%;
    overflow-x: hidden;
  }
}
