/* Stili principali per il widget di ricerca */
.search-widget-custom {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  width: 100%;
  max-height: 420px;
  overflow-y: auto;
  background-color: transparent;
  position: relative;
  margin: 0 auto;
  border: none;
}

/* Container dell'input di ricerca */
.search-widget-custom .search-input-container {
  position: fixed;
  top: 10px;
  width: 100%;
  transform: translateX(-50%);
  max-width: 550px;
  z-index: 999;
  border: none;
  overflow: hidden;
  transition: height 0.3s ease-in-out;
}

/* Layout per la riga di input */
.search-widget-custom .search-input-container .col-12:first-child {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  background-color: #fbfbfb;
  border-radius: 8px;
}

/* Stile dell'input di ricerca */
.search-widget-custom #search-select {
  flex: 1;
  padding: 8px 12px;
  border: none;
  font-size: 1.1rem;
  line-height: 1.4rem;
  color: #1b2a5a;
  background: transparent;
  outline: none;
  width: 100%;
  transition: all 0.2s ease-in-out;
}

.search-widget-custom #search-select:hover {
  cursor: pointer;
  box-shadow: 0 0 0 2px #ffa600;
}

.search-widget-custom #search-select::placeholder {
  color: #9CA3AF;
}

/* Stile del select per le categorie */
.search-widget-custom .category-select {
  width: 190px;
  padding: 8px 32px 8px 12px;
  border: none;
  background-color: #F9FAFB;
  font-size: 1.1rem;
  line-height: 1.4rem;
  color: #1b2a5a;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%236B7280' stroke-width='1.67' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  opacity: 0.5;
}

.search-widget-custom .category-select option {
  cursor: pointer !important;
  font-family: 'Outfit', sans-serif !important;
}

/* Stile del pulsante di ricerca */
.search-widget-custom .search-input-container button[type="submit"] {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-widget-custom .search-input-container button[type="submit"] img {
  width: 20px;
  height: 20px;
}

.search-wrapper {
  display: flex;
  justify-content: center;
}

.search-widget-custom form {
  margin: 0 auto;
  text-align: center;
  width: fit-content;
}

.search-widget-custom #search-results {
  display: none;
  width: 100%;
  position: absolute;
  top: 50px;
  left: 0;
  padding: .5rem;
  height: 380px;
  overflow-y: auto;
  z-index: 9;
  background-color: #fff;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

#search-results::-webkit-scrollbar {
  width: 6px;
}

#search-results::-webkit-scrollbar-thumb {
  background: #aaa;
  border-radius: 3px;
}

#search-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-results {
  width: 100%;
}

.search-widget-custom .search-result-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding-bottom: 5px;
  padding-top: 5px;
  border-bottom: 1px solid #E5E7EB;
  z-index: 99;
  transition: background-color 0.2s;
}

.search-widget-custom .search-result-item:hover {
  background-color: #F9FAFB;
}

.search-widget-custom .search-result-item:last-child {
  border-bottom: none;
}

/* Immagine del prodotto */
.search-widget-custom .search-result-item .product-image {
  width: 110px;
  height: 80px;
  flex-shrink: 0;
}

.search-widget-custom .search-result-item .product-image img {
  width: 100%;
  max-height: 70px;
  object-fit: cover;
}

/* Informazioni del prodotto */
.search-widget-custom .search-result-item .product-info {
  flex: 1;
  text-align: right;
}

.search-widget-custom .search-result-item .product-info .product-name {
  margin: 0 0 4px;
  text-align: left;
  font-size: 1.1rem;
  line-height: 1.4rem;
  color: #1b2a5a;
  font-weight: 700;
}

.search-widget-custom .search-result-item .product-info .product-name a {
  color: inherit;
  text-decoration: none;
}

.search-widget-custom .search-result-item .product-info .product-name a:hover {
  color: #1b2a5a;
}

.search-widget-custom .search-result-item .product-info .product-price {
  font-size: 14px;
  font-weight: bold;
  line-height: 20px;
  color: #1b2a5a;
  font-weight: 500;
}

/* Footer dei risultati */
.search-widget-custom .search-results-footer {
  display: none;
  position: absolute;
  bottom: 0;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 30px;
  padding: 1.1rem;
  background: #F9FAFB;
  z-index: 999;
}

.search-widget-custom .search-results-footer .view-all-link {
  color: #1b2a5a;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  text-decoration: none;
}

.search-widget-custom .search-results-footer .view-all-link:hover {
  text-decoration: underline;
}

/* Pulsante di chiusura */
.search-widget-custom .search-results-footer .search-dialog-close {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #6B7280;
}

.search-widget-custom .search-results-footer .search-dialog-close:hover {
  color: #1b2a5a;
}

.search-widget-custom .search-results-footer .search-dialog-close svg {
  width: 20px;
  height: 20px;
}

.search-widget-custom .search-results-footer a {
  margin-top: 0;
  color: #808080 !important;
  text-decoration: none;
  transition: color 0.3s ease-in-out;
}

.search-widget-custom .search-results-footer a:hover {
  color: #ffa600;
  text-decoration: underline;
}

.search-widget-custom .search-results-footer a.view-all-link,
.search-widget-custom .search-results-footer button{
  font-size: 1rem;
  font-weight: 700;
  color: #1b2a5a !important;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  background-color: #F9FAFB;
}

@keyframes spin {
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Stili responsive */
@media (max-width: 1080px) {
  .search-widget-custom .search-input-container {
    max-width: 400px;
  }

  .search-widget-custom .search-result-item .product-image {
    height: 60px;
  }

  .search-widget-custom .search-result-item .product-image img {
    max-height: 60px;
  }

  .search-widget-custom .search-result-item .product-info .product-name {
    font-size: 1rem;
  }

  .search-widget-custom .search-result-item:last-child {
    margin-top: .5rem;
  }
}

@media (max-width: 960px) {
  .search-widget-custom {
    position: absolute;
    top: -30px;
    width: 93%;
  }

  .search-widget-custom .search-input-container {
    position: relative;
    top: 0;
    margin-top: 0;
    border: none;
    box-shadow: none;
    transform: translateX(0);
  }

  .search-widget-custom .search-input-container .col-12:first-child {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px;
  }

  .search-widget-custom #search-select {
    font-size: 1rem;
    flex: 1;
    min-width: 0;
  }

  .search-widget-custom .category-select {
    font-size: 1rem;
    max-width: 50%;
    flex-shrink: 1;
  }

  .search-widget-custom .search-result-item {
    padding: 8px 12px;
  }

  .search-widget-custom .search-result-item .product-image img {
    max-height: 50px;
  }

}

@media (max-width: 560px) {
  .search-widget-custom {
    position: absolute;
    top: 70px;
    width: 92%;
  }
}