/**
 * @file
 * Styling for the Dash Data Search Block.
 *
 * Provides styling for the search form with custom dropdown,
 * autocomplete suggestions, and help tooltip.
 */

/* =====================
   Base Container Styles
   ===================== */
.dash-data-search-block {
  margin: 12px 0 24px 0;
  background: transparent;
  max-width: 710px;
}

@media (min-width:992px) {
  #page-title .dash-data-search-block {
    max-width: 1100px;
  }

}

.dash-data-search-block {
  margin-left: auto;
  margin-right: auto;
}

.path-frontpage .dash-data-search-block {
}

.dash-data-search-block .search-controls {
  display: flex;
  align-items: stretch;
  height: 40px;
  border-radius: 0.25rem;
  overflow: visible;
  background: transparent;
  position: relative;
}

/* =====================
   Custom Dropdown Button
   ===================== */
.dash-data-search-block .dash-search-type-wrapper {
  position: relative;
  flex: 0 0 auto;
}

.dash-data-search-block .dash-dropdown-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 100%;
  min-width: 140px;
  padding: 8px 12px;
  border: none;
  border-radius: 0.25rem 0 0 0.25rem;
  background-color: #ffc107;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  outline: none;
  transition: background-color 0.15s ease-in-out;
}

body.dash-data-page .dash-data-search-block .dash-dropdown-button {
  min-width: 180px;
}

.dash-data-search-block .dash-dropdown-button:hover {
  background-color: #ffb300;
}

.dash-data-search-block .dash-dropdown-button:focus {
  background-color: #ffa000;
  outline: 2px solid #0056b3;
  outline-offset: -2px;
}

.dash-data-search-block .dash-dropdown-button[aria-expanded="true"] {
  background-color: #ffa000;
  border-radius: 0.25rem 0 0 0;
}

.dash-data-search-block .dash-dropdown-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-data-search-block .dash-dropdown-arrow {
  display: flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.dash-data-search-block .dash-dropdown-button[aria-expanded="true"] .dash-dropdown-arrow {
  transform: rotate(180deg);
}

/* =====================
   Dropdown Menu
   ===================== */
.dash-data-search-block .dash-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  margin: 0;
  padding: 00;
  list-style: none;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 1001;
}

#page-wrapper .dash-data-search-block .dash-dropdown-menu {
  background: #fff;
}

.dash-data-search-block .dash-dropdown-menu[aria-hidden="false"] {
  display: block;
}

.dash-data-search-block .dash-menu-item {
  padding: 8px 16px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dash-data-search-block .dash-menu-item:hover,
.dash-data-search-block .dash-menu-item:focus {
  background-color: #f0f7ff;
  color: #0f4c8e;
  outline: none;
}

.dash-data-search-block .dash-menu-item.active {
  background-color: #e6f0ff;
  color: #0056b3;
  font-weight: 500;
}

.dash-data-search-block .dash-menu-item.parent-item {
  font-weight: 600;
  color: #666;
  cursor: default;
  pointer-events: none;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.dash-data-search-block .dash-menu-item.child-item {
  padding-left: 28px;
}

/* =====================
   Search Input
   ===================== */
.dash-data-search-block .search-term-input {
  flex: 1 1 auto;
  height: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-left: none;
  border-right: none;
  font-size: 14px;
  line-height: 1.42857;
  color: #555;
  background: #fff;
  outline: none;
  border-radius: 0;
  z-index: 1;
}

.dash-data-search-block .search-term-input::placeholder {
  color: #999;
  opacity: 1;
}

.dash-data-search-block .search-term-input:focus {
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
}

/* =====================
   Search Submit Button
   ===================== */
.dash-data-search-block .search-submit-btn {
  flex: 0 0 auto;
  width: 44px;
  min-height: 34px;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0 0.25rem 0.25rem 0;
  background: #0f4c8e;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-data-search-block .search-submit-btn:hover {
  background: #0a3d73;
}

.dash-data-search-block .search-submit-btn:active {
  background: #082d56;
}

.dash-data-search-block .search-submit-btn:focus {
  outline: 2px solid #66afe9;
  outline-offset: -2px;
}

.dash-data-search-block .search-submit-btn svg {
  width: 24px;
  height: 24px;
}

/* =====================
   Search Help Tooltip
   ===================== */
.dash-data-search-block .search-help {
  position: relative;
  flex: 0 0 auto;
  margin-left: 8px;
}

.dash-data-search-block .search-help-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dash-data-search-block .search-help-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.dash-data-search-block .search-help-toggle:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.dash-data-search-block .search-help-toggle svg {
  width: 40px;
  height: 40px;
}

.dash-data-search-block .search-help-text {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 460px;
  padding: 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1002;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
}

.dash-data-search-block .search-help-text[aria-hidden="false"] {
  display: block;
}

.dash-data-search-block .search-help-arrow {
  position: absolute;
  top: -8px;
  right: 16px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #fff;
  border-color: transparent transparent #fff transparent !important; /* this overrides another border-color setting */
}

.dash-data-search-block .search-help-arrow::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid #ccc;
  z-index: -1;
}

.dash-data-search-block .search-help-text p {
  margin: 0 0 12px 0;
}

.dash-data-search-block .search-help-text p:last-child {
  margin-bottom: 0;
}

.dash-data-search-block .search-help-text strong {
  color: #0f4c8e;
}

.dash-data-search-block .search-help-text em {
  background: #f5f5f5;
  padding: 2px 4px;
  border-radius: 0.25rem;
  font-style: normal;
}

/* =====================
   Autocomplete Dropdown
   ===================== */
.dash-data-search-block .dash-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 0.25rem 0.25rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  max-height: 160px;
  overflow-y: auto;
  width: calc(100% - 48px);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0.2s;
}

.dash-data-search-block .dash-autocomplete-dropdown.show {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

#page-wrapper .dash-data-search-block .dash-autocomplete-dropdown {
  background: #fff;
}

.dash-data-search-block .dash-autocomplete-dropdown.show {
  display: block;
}

.dash-data-search-block .dash-autocomplete-item {
  padding: 4px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #eee;
  transition: background-color 0.15s ease;
}

.dash-data-search-block .dash-autocomplete-item:last-child {
  border-bottom: none;
}

.dash-data-search-block .dash-autocomplete-item:hover,
.dash-data-search-block .dash-autocomplete-item.highlighted {
  background-color: #f0f7ff;
  color: #0f4c8e;
}

.dash-data-search-block .dash-autocomplete-item.highlighted {
  background-color: #e6f0ff;
}

/* =====================
   Mobile Responsive
   ===================== */
@media (max-width:768px) {
  .dash-data-search-block .search-help-text {
    width: 320px;
  }

  .dash-data-search-block .dash-dropdown-button {
    min-width: 100px !important;
  }
}

@media (max-width:412px) {
  .dash-data-search-block .search-help-text {
    width: 220px;
  }

  .dash-data-search-block {
    max-width: 100%;
  }

  .dash-data-search-block .search-controls {
    flex-wrap: wrap;
    flex-direction: row;
    height: auto;
  }

  .dash-data-search-block .dash-search-type-wrapper {
    width: 100%;
  }

  .dash-data-search-block .dash-dropdown-button {
    width: 100%;
    border-radius: 0.25rem 0.25rem 0 0;
    justify-content: space-between;
  }

  .dash-data-search-block .dash-dropdown-menu {
    width: 100%;
  }

  .dash-data-search-block .search-term-input {
    flex: 1 1 auto;
    border-left: 1px solid #ccc;
    border-radius: 0;
    min-width: 0;
  }

  .dash-data-search-block .dash-autocomplete-dropdown {
    border-radius: 0 0 0.25rem 0.25rem;
  }

  .search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* First item = full row */
  .search-controls .dash-search-type-wrapper {
    flex: 0 0 100%;
  }

  /* Remaining items share a row */
  .search-controls #dash-search-term {
    flex: 1 1 auto;
    width: auto;
  }

  .search-controls #search-submit-btn {
    flex: 0 0 auto;
  }

  .search-controls .search-help {
    flex: 0 0 auto;
  }

}

/* =====================
   Dark Background Context
   ===================== */
.region-content-above .dash-data-search-block .search-help-toggle svg {
  stroke: white;
}

/* =====================
   Block Title (hidden)
   ===================== */
.block-dash-data-search-block h2.solo-block-title,
.block-dash-data-search-block h2.block-title {
  display: none;
}

/* =====================
   Solo Theme Overrides
   ===================== */
.solo-block.block-dash-data-search-block {
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: none;
}

/* =====================
   Drupal Admin Toolbar Compatibility
   ===================== */
body.toolbar-vertical .dash-data-search-block,
body.toolbar-horizontal .dash-data-search-block,
body.toolbar-tray-open .dash-data-search-block {
  margin-top: 0;
}

/* =====================
   Page Description
   ===================== */
.dash-data-page-description {
  color: white;
  margin: 0 0 20px 0;
  font-size: 14px;
}

.page-title-text {
  margin: 0;
  padding: 0;
}

/* =====================
   Search Term Highlight
   ===================== */
mark.highlighted-search-results {
  background-color: #ffeb3b !important;
  color: #333;
  padding: 1px 3px;
  border-radius: 0.25rem;
}

/* No results message styling */
.dash-search-no-results {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin: 10px 0;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 0.25rem;
  color: #856404;
  font-size: 14px;
  animation: slideDown 0.3s ease-out;
}

.dash-search-no-results.hiding {
  animation: slideUp 0.3s ease-out forwards;
}

.dash-search-no-results .no-results-dismiss {
  background: none;
  border: none;
  font-size: 20px;
  color: #856404;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.dash-search-no-results .no-results-dismiss:hover {
  opacity: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }

}
