/* Search Form Styles */
.catex-search-form {
  position: relative;
  max-width: 600px;
  margin: 0 auto 30px;
}

.catex-search-form form {
  display: flex;
  gap: 10px;
}

#term_search {
  flex: 1;
  padding: 5px 15px 4px;
  border: 1px solid #ddd;
  border-radius: 99px;
  font-size: 16px;
  transition: all 0.3s ease;
}

#term_search:focus {
  outline: none;
  border-color: #30AB64;
  box-shadow: 0 0 0 1px #30AB64;
}
.catex-search-submit {
    padding: 14px 20px 10px !important;
    background: #30AB64 !important;
    color: #fff !important;
    border: none;
    border-radius: 99px !important;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.catex-search-submit:hover {
  background: #135e96;
}

/* Autocomplete Results */
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.taxonomy-suggestion {
  padding: 10px 15px;
  border-bottom: 1px solid #eee;
  transition: background 0.2s ease;
}

.taxonomy-suggestion:last-child {
  border-bottom: none;
}

.taxonomy-suggestion a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #333;
  gap: 10px;
}

.taxonomy-suggestion:hover,
.taxonomy-suggestion.highlighted {
  background-color: #f0f0f1;
}

/* Autocomplete Thumbnails */
.suggestion-thumbnail {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 99px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.suggestion-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.suggestion-thumbnail-placeholder {
  background: #f0f0f1;
  color: #666;
}

.suggestion-content {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.suggestion-name {
  font-weight: 500;
}

.term-count {
  color: #666;
  font-size: 14px;
}

/* Results Grid */
.catex-lists {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

/* Clickable Item Link Wrapper - NEW */
.catex-item-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
}

.catex-item-link:hover {
  text-decoration: none;
  color: inherit;
}

.catex-item-link:focus {
  outline: 2px solid #2271b1;
  outline-offset: 2px;
  border-radius: 4px;
}

.catex-item {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px;
  transition: all 0.3s ease;
  cursor: pointer;
}

/* Updated hover styles for clickable items */
.catex-item-link:hover .catex-item,
.catex-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background-color: #30AB641A;
  border-color: #30AB641A;
}

/* Thumbnail styles for main results */
.catex-with-thumbnails .catex-item {
  padding: 20px;
}

.catex-item-content {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-flow: column;
}

.term-thumbnail {
  flex-shrink: 0;
  width: 110px;
  height: 110px;
  border-radius: 99px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.term-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.term-thumbnail-placeholder {
  background: #f0f0f1;
  color: #666;
  font-size: 24px;
}

.term-name {
  flex: 1;
  text-align: center;
  max-height: 25px;
  overflow: hidden;
}

.term-name h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

/* Updated term name styles for clickable items - MODIFIED */
.term-name span {
  color: #333333;
  text-decoration: none;
  transition: color 0.2s ease;
  font-weight: 500;
}

/* Legacy support for non-clickable items */
.term-name h4 a {
  color: #333333;
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Pagination */
.pagination {
  margin: 30px 0;
  text-align: right;
}

a.page-numbers {
  display: inline-block;
  padding: 8px 12px;
  margin: 0 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  transition: all 0.3s ease;
}

.page-numbers.current {
  background: #30AB64;
  color: #fff;
  border-color: #30AB64;
  padding: 11px 12px;
  border-radius: 4px;
  margin: 0 4px;
}

a.page-numbers:hover:not(.current) {
  background: #f0f0f1;
}

/* Status Messages */
.loading,
.no-results,
.error {
  padding: 15px;
  text-align: center;
  color: #666;
}

.error {
  color: #d63638;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
  .catex-search-form form {
      flex-direction: column;
  }

  .catex-search-submit {
      width: 100%;
  }

  .catex-lists {
      grid-template-columns: 1fr;
      gap: 15px;
  }

  .catex-item-content {
      gap: 12px;
  }

  .term-thumbnail {
      width: 50px;
      height: 50px;
  }

  .suggestion-thumbnail {
      width: 28px;
      height: 28px;
  }
}

@media screen and (max-width: 600px) {
  .catex-lists {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 15px;
  }

  .catex-item {
      padding: 15px;
  }

  .catex-with-thumbnails .catex-item {
      padding: 15px;
  }

  .catex-item-content {
      flex-direction: column;
      text-align: center;
      gap: 10px;
  }

  .term-thumbnail {
      width: 80px;
      height: 80px;
      align-self: center;
  }

  .pagination .page-numbers {
      padding: 6px 10px;
      margin: 0 2px;
  }

  .taxonomy-suggestion a {
      gap: 8px;
  }

  .suggestion-thumbnail {
      width: 24px;
      height: 24px;
  }
}

/* Accessibility */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

/* Focus styles for better accessibility - UPDATED */
.catex-item-link:focus-within,
.catex-item:focus-within,
.taxonomy-suggestion:focus-within {
  outline: 2px solid #2271b1;
  outline-offset: 2px;
}

.catex-item-link:focus .catex-item,
.catex-item a:focus,
.taxonomy-suggestion a:focus {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .catex-item {
    border-width: 2px;
  }
  
  .term-thumbnail-placeholder,
  .suggestion-thumbnail-placeholder {
    border: 1px solid currentColor;
  }
}

/* Reduced motion support - UPDATED */
@media (prefers-reduced-motion: reduce) {
  .catex-item,
  .catex-item-link,
  .catex-search-submit,
  .taxonomy-suggestion,
  #term_search {
    transition: none;
  }
  
  .catex-item-link:hover .catex-item,
  .catex-item:hover {
    transform: none;
  }
}

/* Print styles */
@media print {
  .catex-search-form,
  .autocomplete-results,
  .pagination {
    display: none;
  }
  
  .catex-lists {
    display: block;
  }
  
  .catex-item {
    break-inside: avoid;
    margin-bottom: 10px;
    box-shadow: none;
    border: 1px solid #000;
  }
}