/* ============================================
   Estilos Customizados para o Componente de Busca
   Baseado no tema KeenThemes/Metronic, mas com classes customizadas
   para evitar que o KTSearch tente inicializar
   ============================================ */

/* Container principal do search */
.custom-header-search {
  position: relative;
  display: flex;
  align-items: stretch;
}

@media (min-width: 992px) {
  .custom-header-search {
    width: 350px;
  }
}

/* Toggle mobile */
.custom-search-toggle-mobile {
  display: flex;
  align-items: center;
  cursor: pointer;
}

@media (min-width: 992px) {
  .custom-search-toggle-mobile {
    display: none;
  }
}

/* Form desktop - expandido */
.custom-search-form {
  display: none;
  width: 100%;
  position: relative;
  margin-bottom: 0;
}

@media (min-width: 992px) {
  .custom-search-form {
    display: block;
    margin-bottom: 0;
  }
}

/* Input de busca */
.custom-search-input {
  padding-left: 3.25rem !important;
  border-radius: 0.475rem;
}

.custom-search-input-flush {
  padding-left: 0.75rem !important;
  border: 1px solid var(--bs-border-color) !important;
  background-color: var(--bs-gray-100) !important;
  border-radius: 0.475rem !important;
}

/* Mobile: input com fundo cinza mais claro */
@media (max-width: 991.98px) {
  .custom-search-input-flush {
    background-color: #f5f8fa !important;
    border-color: #e1e3e9 !important;
  }
  
  /* Dark mode no mobile */
  [data-bs-theme="dark"] .custom-search-input-flush {
    background-color: #1e1e2d !important;
    border-color: #2b2b40 !important;
    color: #fff;
  }
}

/* Ícone de busca */
.custom-search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.custom-search-form .custom-search-icon {
  left: 1.25rem;
}

.custom-search-dropdown .custom-search-icon {
  left: 0.75rem;
}

/* Spinner de loading */
.custom-search-spinner {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  line-height: 0;
  display: flex;
  align-items: center;
}

/* Botão de limpar/reset */
.custom-search-reset {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  line-height: 0;
  display: block;
  padding: 0.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
}

/* Dropdown/Menu do search (mobile e desktop - aparece quando há texto) */
.custom-search-dropdown {
  position: absolute;
  z-index: 1050;
  padding: 1.75rem;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.475rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* Mobile: alinhar à direita, no canto da tela, sem vazar */
@media (max-width: 991.98px) {
  .custom-search-dropdown {
    top: calc(100% + 0.25rem);
    left: auto;
    right: 0.5rem;
    min-width: 280px;
    max-width: calc(100vw - 1rem);
    transform: translateX(0);
  }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 991.98px) {
  .custom-search-dropdown {
    min-width: 325px;
    max-width: 375px;
  }
}

/* Desktop: mais próximo do input */
@media (min-width: 992px) {
  .custom-search-dropdown {
    top: calc(100% + 0.25rem);
    left: 0;
    right: auto;
    min-width: 350px;
    max-width: 400px;
  }
}

.custom-search-dropdown-wrapper {
  position: relative;
}

.custom-search-dropdown-form {
  width: 100%;
  position: relative;
  margin-bottom: 0.75rem;
}

/* Separador */
.custom-search-separator {
  border-top: 1px solid var(--bs-border-color);
  margin: 1.5rem 0;
}

/* Área de resultados */
.custom-search-results {
  max-height: 200px;
  overflow-y: auto;
}

@media (min-width: 992px) {
  .custom-search-results {
    max-height: 350px;
  }
}

/* Mensagens de estado */
.custom-search-message {
  text-align: center;
  color: var(--bs-secondary-color);
  padding: 1.25rem 0;
  font-size: 0.875rem;
}

/* Estados vazios/placeholder */
.custom-search-empty {
  text-align: center;
  color: var(--bs-secondary-color);
  padding: 1.25rem 0;
  font-size: 0.875rem;
}

/* Responsividade */
@media (max-width: 575.98px) {
  .custom-search-dropdown {
    min-width: 280px;
    max-width: calc(100vw - 2rem);
  }
}
