.search-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin: 50px 0;
}

.search-form {
  width: 50%;
  text-align: center;
}

.search-form input,
.search-form select {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  margin-top: 10px;
}

.checkbox-container label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
  /* keep checkbox size */
  width: 1rem;
  height: 1rem;
}

.search-button {
  margin-top: 10px;
  padding: 10px 20px;
  font-size: 16px;
}

.summary-container {
  margin-bottom: 50px;
}

.hidden {
  display: none;
}

.author-actions {
  margin-bottom: 50px;
}

.author-table-container {
  margin-bottom: 50px;
  position: relative;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.table-actions .btn {
  padding: 10px 20px;
  font-size: 16px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  border: none;
  display: inline-block;
  text-align: center;
}

.table-actions .btn:hover {
  background-color: #0056b3;
  color: white;
}

.form-container {
  max-width: 900px;
  margin: 24px auto;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

fieldset {
  border: 0;
  margin: 0 0 18px 0;
  padding: 0;
}

legend {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.9rem;
  color: #222;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="date"],
textarea,
select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  font-size: 0.95rem;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: #0b6;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: #333;
  border: 1px solid transparent;
}

.hint {
  font-size: 0.85rem;
  color: #666;
  margin-top: 6px;
}

.select-with-text {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-with-text select {
  flex: 1;
}

.select-with-text input[type="text"] {
  flex: 1;
  display: block;
}

/* sensible default for hidden text inputs used by JS */
input[type="text"][disabled] {
  opacity: 0.9;
}

/* responsive tweak */
@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
  margin-bottom: 12px;
}

/* force these specific blocks to stack full-width: join-date, email block, then name block */
.top-grid>.join-date,
.top-grid>.email-join,
.top-grid>.name-pair {
  grid-column: 1 / -1;
}

.name-pair {
  display: block;
}

/* Email + dates layout
   - default: email on its own row, dates stacked beneath
   - if a leave_date input exists: join and leave sit side-by-side
   - :has() used where supported; fallback class `.has-leave` supported by JS
*/
.email-join {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  align-items: start;
}

.email-join .field {
  display: flex;
  flex-direction: column;
}

.email-join .join-field {
  grid-column: 1 / -1;
  /* join date on second row in add form */
}

.email-join input[type="email"],
.email-join input[type="text"],
.email-join input[type="date"],
.email-join select {
  width: 100%;
  box-sizing: border-box;
}

/* edit form: if leave_date exists, keep join + leave side by side */
.email-join:has(input[name="leave_date"]),
.email-join.has-leave {
  grid-template-columns: 1fr 1fr;
}

.email-join:has(input[name="leave_date"]) .join-field,
.email-join.has-leave .join-field {
  grid-column: 1 / 2;
}

.email-join:has(input[name="leave_date"]) .leave-field,
.email-join.has-leave .leave-field {
  grid-column: 2 / 3;
}

@media (max-width: 640px) {

  .email-join,
  .email-join:has(input[name="leave_date"]),
  .email-join.has-leave {
    grid-template-columns: 1fr;
  }

  .email-join .join-field,
  .email-join .leave-field {
    grid-column: 1 / -1;
  }
}

/* name-block: three columns (first, second, last) on wide screens */
.name-block {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: start;
}

/* keep .full rule and responsive tweaks */
@media (max-width: 760px) {
  .top-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .name-block {
    grid-template-columns: 1fr;
  }
}

/* affiliation block/frame and title */
.affiliation-block {
  border: 1px solid #e6e6e6;
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fff;
}

/* ensure .hidden on affiliation blocks takes precedence (prevents other rules from showing the template) */
.affiliation-block.hidden {
  display: none;
}

/* title inserted above each affiliation block */
.affiliation-title {
  margin: 0 0 8px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #222;
}

/* place the add button on the right and avoid overlap */
.affiliation-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.affiliation-controls {
  text-align: right;
  margin-top: 8px;
}

/* ensure cloned blocks show by default (no inline style required) */
.affiliation-block {
  display: block;
}

/* form actions spacing */
.form-actions {
  margin-top: 16px;
}

/* sortable header indicator */
table.sortable thead th {
  position: relative;
  cursor: pointer;
  user-select: none;
  padding-right: 20px;
  /* room for indicator */
}

/* default faint indicator (both triangles) */
table.sortable thead th::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.12);
  /* down */
  box-sizing: border-box;
}

/* show upward triangle for ascending */
table.sortable thead th.sort-asc::after {
  border-top-color: rgba(0, 0, 0, 0.6);
  border-bottom: none;
  border-top: 6px solid currentColor;
  transform: translateY(-6px);
  border-bottom: 0;
  /* draw small upward triangle using pseudo-element before */
}

table.sortable thead th.sort-asc::before {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(2px);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid rgba(0, 0, 0, 0.12);
}

/* show downward triangle for descending */
table.sortable thead th.sort-desc::after {
  border-top-color: rgba(0, 0, 0, 0.12);
  border-bottom: 0;
  transform: translateY(-2px);
}

/* stronger color for active sort */
table.sortable thead th.sort-desc {
  color: inherit;
}

table.sortable thead th.sort-asc {
  color: inherit;
}

.sr-space {
  color: transparent;
  pointer-events: none;
  display: block;
}

table.sortable thead th.no-sort {
  cursor: default;
}

table.sortable thead th.no-sort::after {
  display: none;
}

table.sortable thead th.no-sort::before {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.5rem;
  color: white;
  font-weight: 600;
}

.mini-list {
  margin: 0;
  padding-left: 16px;
  list-style: disc;
  font-size: 1.0rem;
  color: black;
}

.card-toggle {
  border: 0;
  background: transparent;
  width: 26px;
  height: 26px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.card-toggle::after {
  content: "▾";
  display: inline-block;
  font-size: 1.5rem;
  line-height: 1;
  transition: transform .18s ease;
  opacity: .7;
  transform-origin: center;
}

.summary-card-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height .28s ease, opacity .18s ease;
  margin-top: 8px;
}

.summary-card.expanded .card-toggle::after {
  transform: rotate(180deg);
  opacity: 1;
}

.summary-card.expanded .summary-card-body {
  max-height: 400px;
  opacity: 1;
}

.summary-card-body .mini-list {
  margin: 6px 0 0 0;
  padding-left: 16px;
}

/* pagination toolbar: left spacer, centered pager, right controls (range + size) */
.table-pager {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid #eee;
  margin-top: 8px;
  font-size: 0.95rem;
  background: #fafafa;
}

/* three areas: left (flexible spacer), center (fixed), right (flexible, align end) */
.table-pager .pager-left {
  flex: 1;
}

.table-pager .pager-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.table-pager .pager-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

/* pager buttons */
.table-pager .pager-prev,
.table-pager .pager-next {
  border: 1px solid #ddd;
  background: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}

.table-pager .pager-prev[disabled],
.table-pager .pager-next[disabled] {
  opacity: .5;
  cursor: default;
}

/* info text */
.table-pager .pager-info {
  font-weight: 600;
}

.table-pager .pager-range {
  color: #666;
  font-size: 0.92rem;
}

/* size selector on the right, compact */
.table-pager .pager-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.table-pager .pager-size {
  margin-left: 6px;
  padding: 4px 6px;
  border: 1px solid #dcdcdc;
  border-radius: 4px;
  background: #fff;
}

/* ensure all controls sit on one line */
.table-pager * {
  vertical-align: middle;
}

/* small screens: collapse left spacer, allow right block to wrap if needed */
@media (max-width: 560px) {
  .table-pager {
    gap: 8px;
    padding: 8px;
    font-size: 0.92rem;
  }

  .table-pager .pager-left {
    display: none;
  }

  .table-pager .pager-center {
    gap: 6px;
  }

  .table-pager .pager-right {
    gap: 8px;
  }
}

/* name-pair: first + second name on one line, last name on the line below */

/* flatten internal fields: each field stacks label above input */
.name-block>div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.name-block>div input[type="text"] {
  width: 100%;
  box-sizing: border-box;
}

/* affiliation controls styling moved from inline styles */
.affiliation-controls {
  text-align: right;
  margin-top: 8px;
}

/* mobile: stack everything */
@media (max-width: 640px) {
  .name-block {
    grid-template-columns: 1fr;
  }

  .name-block>div {
    flex-direction: column;
  }

  .name-block>div input[type="text"] {
    width: 100%;
  }
}

/* Author card / modal visual tweaks */
#authorModal .modal-header {
  background: #007bff;
  /* blue matching blog header */
  color: #fff;
  border-bottom: 0;
  align-items: center;
  padding: 0.8rem 1rem;
}

/* center the title while leaving close button on the right */
#authorModal .modal-title {
  margin: 0 auto;
  font-weight: 700;
  font-size: 2.3rem;
  text-align: center;
  display: block;
  letter-spacing: 0.2px;
}

/* white close icon */
#authorModal .modal-header .close {
  color: #fff;
  opacity: 1;
}

/* Make the author name area visually prominent (block-style) */
.author-card-view .modal-title,
.author-card-view .author-name {
  display: block;
  width: 100%;
}

/* stronger legend styling to separate sections */
.author-card-view fieldset>legend {
  display: inline-block;
  background: #f1f7ff;
  color: #0b57b7;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: 0 1px 0 rgba(11, 87, 183, 0.06);
  font-size: 1.5rem;
}

/* make data/value blocks more visible and aligned with labels */
.author-card-view .field-value {
  background: #fbfdff;
  border-left: 3px solid #e6f0ff;
  padding: 8px 10px;
  border-radius: 4px;
  /* font-weight: 600; */
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
}

/* increase contrast for labels so they're clearly paired with values */
.author-card-view label {
  color: #263238;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

/* make affiliation blocks a little lighter & keep values aligned */
.author-card-view .affiliation-block {
  background: #ffffff;
  border: 1px solid #e9f0ff;
  padding: 12px;
  border-radius: 8px;
}

.author-card-view .author-block {
  background: #ffffff;
  border: 1px solid #e9f0ff;
  padding: 12px;
  border-radius: 8px;
}

/* tidy spacing inside form-grid for card view */
.author-card-view .form-grid>div {
  display: flex;
  flex-direction: column;
}

/* responsive: keep same ranking as edit form */
@media (max-width: 760px) {
  #authorModal .modal-dialog {
    max-width: 95%;
  }

  .author-card-view .name-block {
    grid-template-columns: 1fr;
  }
}

.author-card-view .email-join {
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.author-card-view .email-join .join-field {
  grid-column: 1 / 2 !important;
}

.author-card-view .email-join .leave-field {
  grid-column: 2 / 3 !important;
}

/* Keep values visually aligned and equal height even when empty */
.author-card-view .field-value {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  box-sizing: border-box;
}

/* small visual block around the author info */
.author-card-view .author-block {
  padding: 8px;
  background: #f8fbff;
  border-radius: 6px;
  margin-bottom: 8px;
}

#authorModal {
  z-index: 2050 !important;
}

/* backdrop just below modal */
.modal-backdrop.author-backdrop {
  z-index: 2040 !important;
}

/* Search form: stacked fields above, checkbox left and button right */
.search-form {
  width: 50%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  justify-items: stretch;
}

/* Make the query and category sit above and span both columns */
.search-form>input[type="text"],
.search-form>select {
  grid-column: 1 / -1;
  width: 100%;
  /* override previous rules */
  margin-top: 0;
  /* remove double top margin */
}

/* Checkbox on the left (second row) */
.search-form>.checkbox-container {
  grid-column: 1 / 2;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 6px;
}

/* Search button on the right (second row) */
.search-form>.search-button {
  grid-column: 2 / 3;
  justify-self: end;
  margin-top: 6px;
}

/* Small-screen: stack everything vertically */
@media (max-width: 640px) {
  .search-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .search-form>.checkbox-container,
  .search-form>.search-button {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }

  .search-form>.search-button {
    margin-top: 8px;
  }
}

/* Ensure header keeps enough height for large centered title */
#authorModal .modal-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1rem;
  /* a bit more vertical space */
  min-height: 4rem;
  /* reserve room for the large title */
}

/* Absolutely center the title both horizontally and vertically */
#authorModal .modal-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  line-height: 1;
  pointer-events: none;
}

/* Keep close button accessible at the right */
#authorModal .modal-header .close {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
}

/* Force Cancel + Search side-by-side on the right */
.search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 50%;
}

/* query + category span full width above */
.search-form>input[type="text"],
.search-form>select {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 0;
}

/* checkbox at left on the second row */
.search-form>.checkbox-container {
  grid-column: 1 / 2;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 6px;
}

/* Cancel (left) and Search (right) in separate columns, inline */
.search-form>.cancel-button {
  grid-column: 2 / 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  margin-right: 8px;
  width: auto;
}

.search-form>.search-button {
  grid-column: 3 / 4;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  width: auto;
}

/* Small screens: stack vertically */
@media (max-width: 640px) {
  .search-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .search-form>.checkbox-container,
  .search-form>.cancel-button,
  .search-form>.search-button {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    margin-right: 0;
  }

  .search-form>.search-button {
    margin-top: 8px;
  }
}
