/* Shared entity / catalog search combo + typeahead */
.cx-search {
  --cx-s-ink: #14213d;
  --cx-s-muted: #6b7280;
  --cx-s-acc: #1d4e89;
  --cx-s-line: #e4e8ee;
  --cx-s-surface: #f6f7f9;
  position: relative;
  width: min(100%, 22rem);
}

.cx-search--catalog {
  width: min(100%, 40rem);
  margin-bottom: 0.75rem;
}

/* Ask page: same bar as catalog, no type filter */
.cx-search--ask .cx-search__mode {
  flex: 0 0 auto;
  height: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 0.7rem 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--cx-s-ink);
  background: var(--cx-s-surface);
  white-space: nowrap;
  user-select: none;
}

.cx-search__go {
  flex: 0 0 2.6rem;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--cx-s-line);
  border-radius: 0.55rem;
  background: var(--cx-s-acc);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.cx-search__go:hover {
  background: #163a66;
  border-color: #163a66;
  color: #fff;
}

.cx-search__go:focus-visible {
  outline: 2px solid var(--cx-s-acc);
  outline-offset: 2px;
}

.cx-search__bar {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.cx-search__combo {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 2.6rem;
  background: #fff;
  border: 1px solid var(--cx-s-line);
  border-radius: 0.55rem;
  overflow: hidden;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.cx-search__combo:focus-within {
  border-color: #8eb0d4;
  box-shadow: 0 0 0 2px rgba(29, 78, 137, 0.1);
}

.cx-search__type {
  flex: 0 0 auto;
  max-width: 9.5rem;
  height: 100%;
  border: 0;
  background: var(--cx-s-surface);
  padding: 0 1.25rem 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--cx-s-ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='none' stroke='%236b7280' stroke-width='1.6' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  line-height: 1.2;
}

.cx-search__type:focus {
  outline: none;
}

.cx-search__sep {
  width: 1px;
  align-self: stretch;
  margin: 0.45rem 0;
  background: var(--cx-s-line);
  flex: 0 0 auto;
}

.cx-search__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding-left: 0.55rem;
  color: #9aa3b2;
}

.cx-search__combo:focus-within .cx-search__icon {
  color: var(--cx-s-acc);
}

.cx-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0 0.7rem 0 0.4rem;
  font-size: 0.92rem;
  color: var(--cx-s-ink);
  outline: 0;
}

.cx-search__input::placeholder {
  color: #9aa3b2;
}

.cx-search__input::-webkit-search-decoration,
.cx-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.cx-search__filters-btn {
  position: relative;
  flex: 0 0 2.6rem;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--cx-s-line);
  border-radius: 0.55rem;
  background: #fff;
  color: var(--cx-s-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.cx-search__filters-btn:hover,
.cx-search__filters-btn[aria-expanded="true"],
.cx-search__filters-btn.is-open,
.cx-search__filters-btn.is-active {
  color: var(--cx-s-acc);
  border-color: #b6c6db;
  background: #f8fafc;
}

.cx-search__filters-dot {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--cx-s-acc);
}

/* Typeahead dropdown — right under search combo */
.cx-search__suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(2.6rem + 0.35rem);
  z-index: 40;
  max-height: min(50vh, 20rem);
  overflow: auto;
  border-radius: 0.55rem;
  border: 1px solid var(--cx-s-line);
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 33, 61, 0.1);
  padding: 0.3rem;
}

/* When filters btn is present, suggest aligns under combo only */
.cx-search--catalog .cx-search__suggest {
  /* leave space for filter icon on the right */
  right: calc(2.6rem + 0.4rem);
}

.cx-search__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 0.45rem;
  padding: 0.4rem 0.55rem;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.cx-search__item:hover,
.cx-search__item:focus,
.cx-search__item.is-active {
  background: rgba(29, 78, 137, 0.08);
  outline: 0;
}

.cx-search__avatar {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.4rem;
  object-fit: cover;
  background: #e8ecf1;
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.cx-search__avatar--person {
  border-radius: 50%;
}

.cx-search__avatar--empty {
  display: inline-block;
  background: linear-gradient(145deg, #e8ecf1, #d5dbe5);
}

.cx-search__meta {
  flex: 1 1 auto;
  min-width: 0;
}

.cx-search__item strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cx-s-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cx-search__meta > span {
  display: block;
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cx-search__empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  color: #6c757d;
}

.cx-search__footer {
  display: block;
  padding: 0.4rem 0.65rem 0.35rem;
  font-size: 0.72rem;
  color: #8a94a6;
  border-top: 1px solid rgba(20, 33, 61, 0.06);
  margin-top: 0.15rem;
}

/* Filters panel under the bar */
.cx-search__filters {
  margin-top: 0.45rem;
  padding: 0.65rem 0.7rem 0.7rem;
  border: 1px solid var(--cx-s-line);
  border-radius: 0.55rem;
  background: #fff;
}

.cx-search__filters[hidden] {
  display: none !important;
}

.cx-search__filters-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.45rem 0.55rem;
}

.cx-search__field {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  flex: 1 1 8rem;
  min-width: 0;
}

.cx-search__field--year {
  flex: 0 1 5.5rem;
  max-width: 6.25rem;
}

.cx-search__label {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cx-s-muted);
}

.cx-search__control {
  width: 100%;
  height: 2.2rem;
  border: 1px solid var(--cx-s-line);
  border-radius: 0.4rem;
  background: var(--cx-s-surface);
  padding: 0 0.55rem;
  font-size: 0.86rem;
  color: var(--cx-s-ink);
}

.cx-search__control--select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='none' stroke='%236b7280' stroke-width='1.6' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
  padding-right: 1.4rem;
}

.cx-search__control:focus {
  outline: none;
  border-color: #8eb0d4;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(29, 78, 137, 0.1);
}

.cx-search__filters-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.cx-search__apply {
  height: 2.2rem;
  border: 0;
  border-radius: 0.4rem;
  background: var(--cx-s-acc);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.95rem;
  cursor: pointer;
}

.cx-search__apply:hover {
  background: #163a66;
}

@media (max-width: 575.98px) {
  .cx-search,
  .cx-search--catalog {
    width: 100%;
    max-width: 100%;
  }
  .cx-search__type {
    max-width: 7.5rem;
    font-size: 0.78rem;
  }
  .cx-search--catalog .cx-search__suggest {
    right: 0;
  }
  .cx-search__field--year {
    max-width: none;
    flex: 1 1 5rem;
  }
  .cx-search__filters-actions {
    width: 100%;
    margin-left: 0;
  }
  .cx-search__apply {
    width: 100%;
  }
}
