/*
 * Specto Live Search Frontend Styles
 */

/* === FRONTEND SEARCH STYLES === */
/* Search input */
.specto-live-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  transition: border-color 0.3s;
  font-size: 16px;
}

.specto-live-search-input:focus {
  border-color: #2271b1;
  outline: none;
}

.specto-live-search-input.searching {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke="%23cccccc"/><path d="M12 6v6l4 2" stroke="%23cccccc"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
}

/* Search results container */
.specto-search-results {
  position: absolute;
  z-index: 1000;
  width: 100%;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: #fff;
  /* border: 1px solid #ddd; */
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-top: 2px;
  display: none;
}

/* Results list */
.specto-search-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.specto-search-result-item {
  border-bottom: 1px solid #eee;
}

.specto-search-result-item:last-child {
  border-bottom: none;
}

.specto-search-result-link {
  display: flex;
  padding: 10px;
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s;
}

.specto-search-result-link:hover {
  background-color: #f9f9f9;
  text-decoration: none;
}

.specto-search-result-image {
  flex: 0 0 60px;
  margin-right: 10px;
}

.specto-search-result-image img {
  max-width: 100%;
  height: auto;
  display: block;
}

.specto-search-result-info {
  flex: 1;
}

.specto-search-result-title {
  font-weight: bold;
  margin-bottom: 5px;
}

.specto-search-result-price {
  color: #555;
  font-weight: bold;
}

.specto-search-result-sku {
  color: #777;
  font-size: 0.8em;
  margin-top: 5px;
}

/* Live search */
.live-product-search {
  position: relative;
}

.search-input-wrapper {
  position: relative;
}

#live-product-search-input {
  display: block !important;
  width: 100% !important;
  height: 40px !important;
  padding: 0 20px !important;
  font-size: 0.875rem !important;
  line-height: normal !important;
  border: none !important;
  box-sizing: border-box !important;
  background-color: #fff !important;
  color: var(--col-text-title, #333) !important;
  border-radius: var(--round-full, 0px) !important;
}

@media (max-width: 991px) {
  #live-product-search-input {
    height: 36px;
    padding: 0 18px;
  }
}

.clear-input {
  display: none;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 24px;
  color: var(--col-text-status-danger);
}

@keyframes spin {
  0% {
    transform: translateY(-50%) rotate(0deg);
  }
  100% {
    transform: translateY(-50%) rotate(360deg);
  }
}

#live-product-search-results {
  position: absolute;
  top: calc(100% + var(--sp-xs));
  left: 0;
  width: 100%;
  background: #fff;
  box-shadow: 0 15px 20px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  z-index: 1000;
  max-height: calc(100vh - 100px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#live-product-search-results.hidden-results {
  display: none;
}

#live-product-search-results .no-results {
  font-size: 0.75rem;
  /* padding: var(--sp-xs); */
  padding: var(--sp-xs) var(--sp-l);
}

.search-result-categories {
  padding: var(--sp-s) var(--sp-l);
}

.search-categories-heading {
  color: var(--col-text-title);
  font-family: Oswald, sans-serif;
  font-size: 1.25rem;
  margin-bottom: var(--sp-2xs);
}

.search-categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2xs);
}

.search-categories-list a {
  display: inline-block;
  background: var(--col-surface-primary);
  color: var(--col-text-inverse);
  font-size: 0.875rem;
  padding: var(--sp-3xs) var(--sp-xs);
  border-radius: var(--round-full);
  white-space: nowrap;
}

.results-items {
  /* height: 60vh; */
  /* max-height: 700px; */
  max-height: 60dvh;
  overflow-y: auto;
}

.live-search-item {
  display: flex;
  padding: var(--sp-xs) var(--sp-l);
  text-decoration: none;
  color: inherit;
}

.live-search-item:hover {
  background-color: var(--col-surface-primary--focus);
}

.live-search-item + .live-search-item {
  border-top: 1px solid #eee;
}

.search-item-left {
  flex: 0 0 50px;
  margin-right: 10px;
}

.product-image {
  width: 50px;
  height: 50px;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-item-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.product-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1px;
  line-height: 1.2;
}

.product-description {
  font-size: 0.75rem;
  color: var(--col-text-content);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
}

.woocommerce-Price-amount .amount bdi {
  color: var(--col-text-title);
  font-family: Oswald, sans-serif;
  font-weight: 700;
}

.results-button {
  display: block;
  text-align: center;
  line-height: 40px;
  background: var(--col-surface-primary);
  color: var(--col-text-inverse);
  text-decoration: none;
  font-weight: 700;
}

/* PRICE STYLING OVERRIDES */

.live-search-item .product-price {
  font-family: Oswald, sans-serif;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.live-search-item .product-price .woocommerce-Price-amount {
  color: var(--col-text-title);
}

.live-search-item .product-price ins {
  text-decoration: none;
}

.live-search-item .product-price ins .woocommerce-Price-amount {
  color: var(--col-text-danger);
  font-weight: 700;
  text-decoration: none;
}

.live-search-item .product-price del,
.live-search-item .product-price del .woocommerce-Price-amount {
  color: var(--col-text-title);
  font-size: 0.75rem;
}

.live-search-item .product-price del .woocommerce-Price-amount {
  font-weight: 400;
}

.live-search-item .product-price del {
  text-decoration: line-through;
  order: 1;
}

.live-search-item .product-price .from-text {
  font-family: "Open sans", sans-serif;
  font-weight: 400;
  color: var(--col-text-content);
  font-size: 0.75rem;
}

/* === LOADER === */
.spinner {
  width: 26px;
  height: 26px;
  --c: radial-gradient(farthest-side, var(--p1-70) 92%, #0000);
  background: var(--c) 50% 0, var(--c) 50% 100%, var(--c) 100% 50%,
    var(--c) 0 50%;
  background-size: 8px 8px;
  background-repeat: no-repeat;
  animation: spinner-kh173p 1s infinite;
}

@keyframes spinner-kh173p {
  to {
    transform: rotate(0.5turn);
  }
}

/* Loader wrapper: positioned */
.loader-wrap {
  display: block;
  position: absolute;
  right: 0px;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Hide loader wrapper when inactive */
.loader-wrap.hidden {
  display: none;
}

/* Clear input button */
.clear-input.hidden {
  display: none;
}
