/* Search trigger button */
.search-trigger {
  margin-left: 1.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 62.5rem;
  border: 0.0625rem solid #969696;
  background: rgba(249, 249, 249, 0.5);
  color: var(--text-title);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  width: 100%;
  max-width: 15rem;
  font-family: inherit;
}

.search-trigger:hover {
  background: #f5f5f5;
  color: #333;
}

.search-trigger__icon {
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
}

.search-trigger__shortcut {
  margin-left: auto;
  display: inline-flex;
  gap: 0.125rem;
}

.search-trigger__kbd {
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 0.0625rem solid #e0e0e0;
  background: #fff;
  font-size: 0.9rem;
  color: var(--text-title);
}

/* Modal overlay */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.search-modal--open {
  opacity: 1;
  visibility: visible;
}

/* Search dialog */
.search-dialog {
  width: 98vw;
  max-width: 37.5rem;
  background: #fff;
  border-radius: 0.75rem;
  border: 0.0625rem solid #e0e0e0;
  box-shadow: 0 1.5625rem 3.125rem rgba(0, 0, 0, 0.15);
  transform: translateY(-1.25rem);
  transition: transform 0.3s ease;
}

.search-modal--open .search-dialog {
  transform: translateY(0);
}

/* Search header */
.search-dialog__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  border-bottom: 0.0625rem solid rgba(0, 0, 0, 0.08);
}

.search-dialog__icon-wrapper {
  position: relative;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.search-dialog__spinner {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 0.125rem solid #f3f3f3;
  border-top: 0.125rem solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.search-dialog__spinner--visible {
  opacity: 1;
}

.search-dialog__search-icon {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.3s ease;
  color: #666;
}

.search-dialog__search-icon--hidden {
  opacity: 0;
}

.search-dialog__input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1rem 0;
  padding-left: 0.2rem;
  font-size: 1rem;
  color: #333;
  outline: none;
  font-family: inherit;
}

.search-dialog__input:focus-visible {
  outline: var(--focus-border);
  outline-offset: -0.125rem;
  border-radius: 0.2rem;
}

.search-dialog__input::placeholder {
  color: #999;
}

.search-dialog__close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  background: #f5f5f5;
  border: 0.0625rem solid #e0e0e0;
  border-radius: 0.375rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.search-dialog__close-btn:hover {
  background: #e8e8e8;
  color: #333;
}

.search-dialog__close-btn svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* Search results container */
.search-dialog__results {
  max-height: 28.75rem;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-dialog__results::-webkit-scrollbar {
  width: 0.375rem;
}

.search-dialog__results::-webkit-scrollbar-track {
  background: transparent;
}

.search-dialog__results::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 0.1875rem;
}

/* Initial message */
.search-dialog__initial-message {
  padding: 2.5rem 1.25rem;
  text-align: center;
}

/* Search results list */
.search-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results-list__item {
  margin: 0;
  padding: 0;
}

/* Search result link */
.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  border: 0.125rem solid transparent;
  width: 100%;
}

.search-result:hover {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
}

.search-result:focus {
  background: rgba(102, 126, 234, 0.08);
  border-color: rgba(102, 126, 234, 0.2);
  outline: none;
}

.search-result:focus-visible {
  outline: 0.25rem solid #667eea;
  background: rgba(102, 126, 234, 0.08);
  box-shadow: 0 0 0 0.0625rem #667eea;
}

/* Header z-index reduction when modal is open */
.search-modal--open ~ * #brx-header,
.search-modal--open ~ #brx-header,
body.search-modal-open #brx-header {
  z-index: 0 !important;
}

/* Footer z-index reduction when modal is open */
.search-modal--open ~ * #brx-footer,
.search-modal--open ~ #brx-footer,
body.search-modal-open #brx-footer {
  z-index: -1 !important;
}
/* Main content z-index reduction when modal is open */
body.search-modal-open main,
body.search-modal-open #main,
body.search-modal-open .main-content {
  z-index: -1 !important;
}

.search-result__content {
  flex: 1;
  min-width: 0;
}

.search-result__title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Post type tags */
.search-result__tag {
  padding: 0.125rem 0.5rem;
  border-radius: 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03125rem;
  flex-shrink: 0;
}

.search-result__tag--post {
  background: #166534;
  color: #ffffff;
}

.search-result__tag--page,
.search-result__tag--archive {
  background: #c2410c;
  color: #ffffff;
}

.search-result__tag--lernen {
  background: #1d4ed8;
  color: #ffffff;
}

.search-result__tag--quiz {
  background: #6b21a8;
  color: #ffffff;
}

.search-result__tag--videos {
  background: #b91c1c;
  color: #ffffff;
}

/* No results message */
.search-dialog__no-results {
  padding: 2.5rem 1.25rem;
  text-align: center;
}

/* Search highlight */
.search-highlight {
  background: rgba(255, 235, 59, 0.3);
  font-weight: 600;
}

/* Animations */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive design */
@media (max-width: 991px) {
  .search-trigger {
    margin-top: 0.7rem;
    margin-left: 0;
    min-height: 2.2rem;
  }

  .search-trigger__shortcut {
    display: none;
  }
}

@media (max-width: 767px) {
  .search-dialog {
    width: 95vw;
  }

  .search-dialog__header {
    padding: 0 1rem;
  }

  .search-dialog__input {
    font-size: 1rem;
  }
}
