.advanced-search-page {
  min-height: calc(100vh - 78px);
  padding: 54px 8% 80px;
}

.search-heading {
  max-width: 760px;
  margin-bottom: 28px;
}

.search-heading h1 {
  margin: 16px 0 12px;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.08;
  letter-spacing: -1px;
}

.search-heading p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.advanced-search-panel {
  position: sticky;
  top: 14px;
  z-index: 20;
  margin-bottom: 34px;
  padding: 26px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.advanced-search-form label,
.search-main-field {
  display: grid;
  gap: 9px;
}

.advanced-search-form label > span,
.search-main-field > label {
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.search-input-wrap {
  position: relative;
}

.search-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-input-row input,
.search-filter-grid select {
  width: 100%;
  min-height: 50px;
  padding: 0 15px;
  background: #fff;
  color: var(--text);
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  outline: none;
  font: inherit;
}

.search-input-row input:focus,
.search-filter-grid select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.search-input-row button,
.search-reset-btn,
.search-load-more-btn,
.search-empty-reset {
  min-height: 50px;
  padding: 0 24px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
}

.search-input-row button {
  color: #fff;
  background: var(--blue);
  border: 0;
}

.search-input-row button:hover {
  background: var(--blue-dark);
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 310px;
  padding: 8px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .16);
}

.search-suggestions[hidden] {
  display: none;
}

.search-suggestions button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  color: #334155;
  background: transparent;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.search-suggestions button:hover,
.search-suggestions button.is-active {
  color: #1d4ed8;
  background: #eff6ff;
}


.search-filter-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.search-filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.search-filter-toggle-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.search-filter-toggle-btn:active {
  transform: translateY(1px);
}

.search-filter-toggle-chevron {
  display: inline-block;
  font-size: 17px;
  line-height: 1;
  transition: transform .25s ease;
}

.search-filter-toggle-btn.is-collapsed .search-filter-toggle-chevron {
  transform: rotate(180deg);
}

.search-filter-content {
  max-height: 720px;
  overflow: visible;
  opacity: 1;
  transition: max-height .32s ease, opacity .2s ease, margin .32s ease;
}

.search-filter-content.is-collapsed {
  max-height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.recent-searches {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid #e2e8f0;
}

.recent-searches[hidden] {
  display: none;
}

.recent-searches-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.recent-searches-head button {
  padding: 4px 0;
  color: #2563eb;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.recent-search-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-search-chip {
  padding: 8px 11px;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.recent-search-chip:hover {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.search-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.search-reset-wrap {
  display: flex;
  align-items: end;
}

.search-reset-btn {
  width: 100%;
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.search-reset-btn:hover {
  background: #dbeafe;
}

.search-results-section {
  min-height: 300px;
}

.search-results-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.search-results-label {
  color: var(--blue);
  font-weight: 900;
}

.search-results-header h2 {
  margin-top: 7px;
  font-size: clamp(26px, 4vw, 36px);
}

#searchResultCount {
  color: var(--muted);
  font-weight: 700;
}

.active-search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 20px;
}

.active-search-filters[hidden] {
  display: none;
}

.active-search-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: #1d4ed8;
  background: #dbeafe;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.active-search-filter:hover {
  background: #bfdbfe;
}

.active-search-filter span {
  font-size: 17px;
  line-height: 1;
}

.search-doc-card {
  min-width: 0;
}

.search-file-format {
  padding: 5px 9px;
  color: #475569;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.search-doc-author {
  margin: 13px 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-results-section .empty-state,
.search-loading-state {
  grid-column: 1 / -1;
}

.search-empty-state,
.search-error-state {
  padding: 48px 24px;
  text-align: center;
  border-radius: 20px;
}

.search-empty-state {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}

.search-empty-state strong,
.search-error-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.search-empty-state p,
.search-error-state p {
  margin-bottom: 18px;
  color: #64748b;
}

.search-empty-icon {
  margin-bottom: 13px;
  font-size: 42px;
}

.search-empty-reset {
  color: #fff;
  background: #2563eb;
  border: 0;
}

.search-error-state {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.search-loading-state {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.search-loading-state span {
  min-height: 230px;
  border-radius: 20px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: searchSkeleton 1.25s infinite linear;
}

@keyframes searchSkeleton {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.search-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.search-load-more-btn {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.search-load-more-btn:hover {
  background: #dbeafe;
}

.search-load-more-btn[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .search-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .advanced-search-panel {
    position: static;
  }

  .search-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-loading-state {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .advanced-search-page {
    padding: 34px 18px 60px;
  }

  .advanced-search-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .search-input-row {
    grid-template-columns: 1fr;
  }

  .search-input-row button {
    width: 100%;
  }

  .search-filter-toggle-row {
    justify-content: stretch;
  }

  .search-filter-toggle-btn {
    width: 100%;
  }

  .search-filter-grid,
  .search-loading-state {
    grid-template-columns: 1fr;
  }

  .search-filter-grid {
    gap: 14px;
  }

  .search-results-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
