/* Research Section with Filtering */
.research-section {
  position: relative;
}

.research-header {
  margin-bottom: 30px;
}

/* Filter Controls Styling */
.filter-controls {
  background-color: #f9f5ea;
  border-radius: 8px;
  padding: 15px;
  margin: 25px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border: 1px solid rgba(184, 134, 11, 0.2);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  margin-bottom: 15px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-select {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--medium-gray);
  background-color: white;
  color: var(--text-color);
  font-family: 'PT Serif', serif;
  font-size: 0.9rem;
  min-width: 150px;
  cursor: pointer;
  transition: border-color 0.3s, box-shadow 0.3s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%233E2C1B' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filter-select:focus {
  outline: none;
  border-color: var(--highlight-color);
  box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.2);
}

label {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--text-color);
}

.reset-button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border: none;
  background-color: var(--medium-gray);
  color: var(--text-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s;
  margin-left: auto;
}

.reset-button:hover {
  background-color: #bbb;
}

/* Category Pills */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 15px;
}

.pill {
  display: inline-block;
  padding: 6px 14px;
  background-color: var(--light-gray);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  border: 1px solid transparent;
  font-family: 'Open Sans', sans-serif;
  text-transform: capitalize;
}

.pill:hover {
  background-color: rgba(184, 134, 11, 0.1);
  border-color: var(--highlight-color);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pill.active {
  background-color: var(--highlight-color);
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.more-categories {
  position: relative;
  display: inline-block;
}

.more-pill {
  display: flex;
  align-items: center;
  gap: 4px;
}

.categories-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  z-index: 10;
  min-width: 180px;
  display: none;
  flex-direction: column;
  gap: 5px;
  margin-top: 5px;
  max-height: 300px;
  overflow-y: auto;
}

.more-categories:hover .categories-dropdown {
  display: flex;
}

.dropdown-pill {
  text-align: left;
  border-radius: 4px;
  padding: 6px 10px;
}

/* Results count */
.results-count {
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--dark-gray);
  font-style: italic;
}

/* Enhanced post metadata styling */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 15px;
  align-items: center;
}

.post-date, .original-date, .post-author {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--dark-gray);
}

.post-date::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.original-date::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.post-author::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M12 12c2.2 0 4-1.8 4-4s-1.8-4-4-4-4 1.8-4 4 1.8 4 4 4zm0 2c-2.7 0-8 1.3-8 4v2h16v-2c0-2.7-5.3-4-8-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

/* Loading indicator */
.loader {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(237, 224, 202, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  border-radius: 8px;
}

.loader-icon {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(184, 134, 11, 0.3);
  border-radius: 50%;
  border-top-color: var(--highlight-color);
  animation: spin 1s ease-in-out infinite;
}

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

/* No results message */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--dark-gray);
  background-color: #f9f5ea;
  border-radius: 8px;
  margin: 30px 0;
}

.no-results svg {
  margin-bottom: 15px;
  opacity: 0.5;
}

.no-results a {
  color: var(--highlight-color);
  font-weight: bold;
}

/* Pagination Styling - NEW */
.pagination-container {
  display: flex;
  justify-content: center;
  margin: 40px 0 20px;
}

.pagination-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 5px;
  align-items: center;
}

.pagination-item {
  display: inline-block;
}

.pagination-item a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background-color: var(--light-gray);
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 1px solid var(--medium-gray);
}

.pagination-item a:hover {
  background-color: var(--light-highlight);
  color: white;
}

.pagination-item.active a {
  background-color: var(--highlight-color);
  color: white;
  border-color: var(--highlight-color);
}

.pagination-item.disabled a {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-prev a,
.pagination-next a {
  font-size: 1.2rem;
}

.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--dark-gray);
}

/* Smooth transitions */
.post-item {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.post-item.hiding {
  opacity: 0;
  transform: translateY(10px);
}

.post-item.showing {
  animation: fadeIn 0.4s ease forwards;
}

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

/* Enhanced Author Filter Styling */
.search-select-wrapper {
  position: relative;
  width: 100%;
  max-width: 250px;
}

/* Improved search input styling */
.author-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px; /* Add space for the search icon */
  border-radius: 4px;
  border: 1px solid var(--medium-gray);
  background-color: white;
  color: var(--text-color);
  font-family: 'PT Serif', serif;
  font-size: 0.9rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

/* Add search icon */
.search-select-wrapper::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 2;
}

.author-search-input:focus {
  outline: none;
  border-color: var(--highlight-color);
  box-shadow: 0 0 0 2px rgba(184, 134, 11, 0.2);
}

/* Hide the default select - we'll show it when needed */
.filter-select.author-select {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 38px; /* Match the input height */
  cursor: pointer;
  z-index: 1;
}

/* Dropdown for search results styling */
.author-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background-color: white;
  border: 1px solid var(--medium-gray);
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  z-index: 10;
  margin-top: 4px;
  display: none;
}

.author-dropdown.active {
  display: block;
}

.author-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.author-dropdown-item:hover {
  background-color: var(--light-gray);
}

.author-dropdown-item.selected {
  background-color: rgba(184, 134, 11, 0.1);
  font-weight: bold;
}

/* NEW: Highlighting in author dropdown */
.author-dropdown-item strong {
  background-color: rgba(184, 134, 11, 0.2); /* Subtle highlight */
  font-weight: bold;
  border-radius: 2px;
}

.author-dropdown-item.no-results {
  font-style: italic;
  color: var(--dark-gray);
  cursor: default;
  padding: 15px 12px;
  text-align: center;
  border-top: 1px solid var(--medium-gray);
}

/* Clear button */
.clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.search-select-wrapper.has-value .clear-search {
  opacity: 1;
}

/* Selected value display */
.selected-author {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-color);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 60px);
  display: none;
}

.search-select-wrapper.has-selected .selected-author {
  display: block;
}

.search-select-wrapper.has-selected .author-search-input {
  color: transparent;
}

.search-select-wrapper.has-selected.is-focused .selected-author {
  display: none;
}

.search-select-wrapper.has-selected.is-focused .author-search-input {
  color: var(--text-color);
}

/* Mobile optimization */
@media screen and (max-width: 768px) {
  .filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .filter-select {
    width: 100%;
  }
  
  .reset-button {
    margin-left: 0;
    align-self: flex-start;
  }
  
  .post-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .search-select-wrapper {
    width: 100%;
    max-width: 100%;
  }
  
  .author-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 50vh;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    animation: slideUp 0.3s ease;
  }
  
  .author-dropdown-header {
    padding: 15px;
    border-bottom: 1px solid var(--medium-gray);
    text-align: center;
    position: sticky;
    top: 0;
    background: white;
    font-weight: bold;
  }
  
  .author-dropdown-close {
    position: absolute;
    right: 15px;
    top: 15px;
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%23666666' d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
  }
  
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  
  /* Responsive pagination - NEW */
  .pagination-item:not(.pagination-prev):not(.pagination-next):not(.active):not(.pagination-ellipsis) {
    display: none;
  }
  
  .pagination-item.active {
    display: inline-block;
  }
}

/* Overlay for mobile */
.author-dropdown-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 999;
}

.author-dropdown-overlay.active {
  display: block;
}

/* Mobile overflow fixes */
*, *::before, *::after {
  box-sizing: border-box;
}

.filter-controls {
  overflow: hidden;
}

@media screen and (max-width: 768px) {
  .filter-group label {
    width: 100%;
    display: block;
    margin-bottom: 5px;
  }
  
  .author-search-input {
    padding-right: 30px;
  }
  
  .clear-search {
    right: 8px;
  }
  
  .selected-author {
    max-width: calc(100% - 70px);
  }
}

/* Focus states for accessibility - NEW */
.pagination-item a:focus,
.author-search-input:focus {
  outline: 2px solid var(--highlight-color);
  outline-offset: 2px;
}

/* Animation for page transitions - NEW */
.post-item {
  animation: fadeIn 0.4s ease forwards;
}

/* Screen reader only text - NEW */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}