/* needed so we can center our content from inside parent theme container */
.directory-parent {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100% !important;
  margin-top: 20px;
  margin-bottom: 20px;
}

.directory-container {
  margin-top: 15px auto;
  width: 95%;
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

.directory-header {
  padding: 20px;
  padding-right: 10px;
  border-bottom: 1px solid #ddd;
  display: flex;
  flex-wrap: wrap;
  position: relative;
}

.header-text {
  flex: 0 1 auto;
  padding-right: 15px;
  margin-right: auto; /* Push everything else to the right */
  margin-bottom: 1rem;
  align-items: left;
  justify-content: right;
}
.header-right {
  display: block;
}

.header-right-top {
  margin-right: 15px;
}

.filter-container {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  width: 100%;
}

.search-button {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #6a6a6a;
  padding: 0;
  cursor: pointer;
  transition: all 0.4s ease;
}

.search-button:not(:disabled):hover {
  background: #e0e0e0;
  color: #6a6a6a;
}

#match-any-input-box {
  width: 100%;
  box-sizing: border-box;
}

.header-right-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: right;
  margin-right: 15px;
  margin-top: 10px;
}

#advanced-filter-button {
  padding: 4px 10px;
  font-size: 0.875rem;
}

#metadata-filter-panel {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid #ddd;
  padding: 10px;
  margin-top: 15px;
  box-sizing: border-box;
}


.metafields-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 10px 0;
  align-items: flex-end;
  justify-content: space-between;
  width: 100%;
}

.metafields-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  margin-top: 10px;
}

#metadata-filter-form {
  display: block;
  width: 100%;
  margin: 0;
}

.metadata-field {
  flex: 0 1 auto; /* don't grow, allow shrink, auto basis */
  min-width: 80px;
  max-width: 220px;
  width: fit-content; /* Size to content but respect min/max */
  margin-bottom: 0;
}

.metadata-field label {
  display: block;
  font-weight: 550;
  margin-bottom: 5px;
  font-size: 0.8rem;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 100%;
}

.checkbox-field input[type="checkbox"] {
  margin: 0;
}

.checkbox-field label {
  margin: 0;
  cursor: pointer; /* Make the label clickable */
}

.metadata-field select,
.metadata-field input {
  width: 100%;
  min-width: 0; /* Allow shrinking below default */
  max-width: 100%; /* Respect parent's max-width */
  box-sizing: border-box;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.8rem;
  height: 35px;
}

/* Responsive behavior for smaller screens */
@media (max-width: 768px) {
  .metafields-container {
    gap: 10px;
  }
  
  .metadata-field {
    flex: 1 1 calc(50% - 10px); /* Two columns on medium screens */
    min-width: 80px;
    max-width: none; /* Remove max-width constraint on smaller screens */
  }
}

@media (max-width: 480px) {
  .metadata-field {
    flex: 1 1 100%; /* Single column on very small screens */
    max-width: none;
  }
}

.apply-filters-button {
  flex: 0 0 auto; /* don't grow, don't shrink, auto width */
  padding: 7px 15px;
  height: 40px;
  font-size: 0.875rem;
  font-weight: 650;
  margin-top: auto;
  margin-left: auto; /* Push button to the right */
  white-space: nowrap;
}

.apply-filters-button:hover {
  background: #e0e0e0;
  color: #6a6a6a;
}

.sort-select {
  width: auto;
  display: inline-block;
  font-size: 0.875rem;
}

select {
  background-color: white;
  color: #666;
}

.any-text-filter,
.metadata-sort {
  display: flex;
  align-items: center;
  font-size-adjust: 0.8rem;
}

.any-text-filter input,
.metadata-sort select {
  font-size: 0.875rem; /* 14px if base is 16px */
  padding: 4px 8px; /* Adjust padding to match smaller text */
  height: 30px; /* Make input/select height consistent */
}

.any-text-filter input::placeholder {
  font-size: 0.875rem;
  color: #666;
}

.search-any-button {
  height: 30px;
  width: 35px;
  margin-left: 5px;
}

.search-any-button .dashicons {
  font-family: "dashicons";
  font-size: 1.2em;
  color: #333;
  vertical-align: middle;
}

select option[disabled] {
  color: #999;
  font-style: italic;
}

.reset-button {
  padding: 4px 10px;
  font-size: 0.875rem;
}

.reset-button:disabled {
  opacity: 0.5;
  cursor: default;
  background: #eee;
  color: #6a6a6a;
  border-color: #eee;
}

.reset-button:not(:disabled):hover {
  background: #e0e0e0;
  color: #6a6a6a;
}

.subheader {
  display: flex;
  justify-content: space-between;
  align-items: center; /* vertical */
}

.subheader #filter-results {
  font-size: 0.875rem;
  color: #666;
  display: block;
  text-align: left;
  margin-top: 5px;
  margin-left: 20px;
}

.filter-result-item {
  display: inline-block;
  white-space: nowrap;
  border: 1px solid #dbcdcd;
  border-radius: 6px;
  font-size: 0.875rem;
  padding: 2px 4px;
  margin: 2px;
}

.subheader .pagination {
  display: flex;
  justify-content: right;
}

.grid-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;

  padding: 20px;
}

.card {
  background: #fff;
  margin: 20px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  transition: transform 0.3s ease;

  display: grid;
  grid-template-areas:
    "header header" /* First row spans both columns */
    "thumbnail meta"; /* Second row splits into image and meta */
  grid-template-columns: 3fr 2fr; /* Give image more room than meta data */
  max-width: 300px;
}

.card:hover {
  transform: translateY(-5px); /* Slight upward movement */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); /* Larger shadow */
}

.card-header {
  grid-area: header;
  margin: 2px 5px 0px 5px;
}

.card-thumbnail {
  grid-area: thumbnail;
  margin: 5px;
  height: auto;
  background: #f5f5f5;
  border: 1px solid lightslategrey;
  font-size: 12px;
  align-content: center;
  text-align: center;
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  padding: 0;
}

.meta-data {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 5px;
  min-width: 0; /* Prevent overflow of content so it doesn't squeeze the thumbnail image */
}

.meta-filter-btn {
  display: inline-flex;
  padding: 1px 6px;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  transition: all 0.2s ease;
  text-wrap: wrap;
  width: fit-content;
  font-size: 0.8em;
  line-height: 1.2;
  margin: 1px;
  font-size: clamp(0.65rem, 1vw, 0.75rem);
}

.meta-filter-btn:hover {
  color: black;
  background-color: #e0e0e0;
  border-color: #046bd2;
  cursor: pointer;
}

.meta-data-date {
  font-size: 0.8em;
  color: #666;
  margin: 4px 2px;
  margin-top: auto; /* Calculate top margin to display date at bottom of the card */
}

.login-link {
  position: absolute;
  right: 15px;
  bottom: 5px;

  font-size: 0.75rem;
}

.login-link a {
  color: #046bd2;
  font-weight: 500;
  font-size: 1.0rem;
  text-decoration: none;
}

.login-link a:hover {
  text-decoration: underline;
}

/* Pagination container */
.pagination {
  display: flex;
  justify-content: right;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 20px;
  margin-right: 20px;
}

/* Individual page links */
.pagination a,
.pagination span {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2px 4px;
  margin: 0 4px;
  border: 1px solid #cccccc70;
  text-decoration: none;
  color: #333;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Current page */
.pagination .current {
  background-color: #0274be;
  color: #fff;
  border-color: #0274be;
}

/* Hover state */
.pagination a:hover {
  background-color: #f0f0f0;
}

/* Previous/Next links */
.pagination .prev,
.pagination .next {
  font-family: "dashicons";
  font-size: 0;
  width: 30px;
  height: 30px;
}

.pagination .next {
  margin-right: 0px; /* let container handle the margin */
}

.pagination .dots {
  border: none;
  margin: 0 2px;
  padding: 0px;
  position: relative;
  top: 0.4px; /* Make the dots lower to align with bottom of other buttons, not bottom of other text */
}

/* Icon styling (example using Font Awesome) */
.pagination .prev::before,
.pagination .next::before {
  font-family: "dashicons";
  font-weight: 400;
  font-size: 16px;
  color: #333;
}

.pagination .prev::before {
  content: "\f341"; /* Left arrow */
}

.pagination .next::before {
  content: "\f345"; /* Right arrow */
}
