/* Kalama search suggestions: white, anthracite, hairline borders, gold accents. */
#search_widget.ks-ready {
  --ks-ink: #17191c;
  --ks-muted: #6b7076;
  --ks-line: rgba(20, 24, 27, 0.1);
  --ks-soft: #f6f4ef;
  --ks-gold: #b98b11;
  --ks-gold-soft: rgba(185, 139, 17, 0.12);
  --ks-ok: #2f7d4f;
  --ks-warn: #a46a00;
  --ks-off: #9a9ea3;
  position: relative;
}

#search_widget.ks-ready .search-widgets__dropdown {
  display: none !important;
}

#search_widget.ks-ready form {
  position: relative;
}

/* Loading: thin gold line along the bottom of the field, no layout change. */
#search_widget .ks-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

#search_widget .ks-progress::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: var(--ks-gold);
  animation: ks-progress 0.9s ease-in-out infinite;
}

#search_widget.ks-loading .ks-progress {
  opacity: 1;
}

@keyframes ks-progress {
  from { left: -35%; }
  to { left: 100%; }
}

.ks-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ks-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 10070;
  width: min(680px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--ks-line);
  border-top: 2px solid var(--ks-gold);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 48px rgba(20, 24, 27, 0.16), 0 2px 6px rgba(20, 24, 27, 0.06);
  color: var(--ks-ink);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
}

.ks-panel[hidden] {
  display: none;
}

.ks-panel__scroll {
  max-height: min(var(--ks-max-h, 640px), 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ks-section {
  padding: 12px 12px 4px;
}

.ks-section + .ks-section {
  border-top: 1px solid var(--ks-line);
}

.ks-section__title {
  margin: 0 4px 8px;
  color: var(--ks-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ks-panel mark {
  padding: 0;
  background: none;
  color: inherit;
  font-weight: 700;
  box-shadow: inset 0 -0.42em 0 var(--ks-gold-soft);
}

/* A. Categories */
.ks-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 8px;
}

.ks-cat {
  display: inline-flex;
  max-width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--ks-line);
  border-radius: 999px;
  background: #fff;
  color: var(--ks-ink) !important;
  text-decoration: none !important;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ks-cat__icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 1.5px solid var(--ks-gold);
  border-radius: 3px;
  box-shadow: 3px 3px 0 -1.5px #fff, 3px 3px 0 0 var(--ks-gold);
}

.ks-cat__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ks-cat:hover,
.ks-cat.is-active {
  border-color: var(--ks-gold);
  background: var(--ks-soft);
}

/* B. Products */
.ks-products {
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}

.ks-product {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  min-height: 74px;
  align-items: center;
  gap: 14px;
  padding: 8px;
  border-radius: 8px;
  color: var(--ks-ink) !important;
  text-decoration: none !important;
  transition: background-color 0.12s ease;
}

.ks-product:hover,
.ks-product.is-active {
  background: var(--ks-soft);
}

.ks-product.is-active {
  box-shadow: inset 3px 0 0 var(--ks-gold);
}

.ks-product__thumb {
  display: flex;
  width: 60px;
  height: 60px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--ks-line);
  border-radius: 6px;
  background: #fff;
}

.ks-product__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ks-product__noimg {
  width: 26px;
  height: 26px;
  border: 1.5px solid #d5d7da;
  border-radius: 4px;
}

.ks-product__body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.ks-product__cat {
  overflow: hidden;
  color: var(--ks-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ks-product__name {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.ks-product__stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.ks-product__stock::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.ks-stock-0 { color: var(--ks-ok); }
.ks-stock-1 { color: var(--ks-warn); }
.ks-stock-2 { color: var(--ks-off); }

.ks-product__prices {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
}

.ks-product__price {
  font-size: 15px;
  font-weight: 700;
}

.ks-product__price.is-sale {
  color: #b3261e;
}

.ks-product__old {
  color: var(--ks-muted);
  font-size: 12px;
}

.ks-product__badge {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ks-gold);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* C. All results: stays visible at the bottom while the list scrolls. */
.ks-all {
  position: sticky;
  bottom: 12px;
  z-index: 1;
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 4px 12px 12px;
  box-shadow: 0 0 0 12px #fff;
  border-radius: 8px;
  background: var(--ks-ink);
  color: #fff !important;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none !important;
  text-transform: uppercase;
  transition: background-color 0.15s ease;
}

.ks-all:hover,
.ks-all.is-active {
  background: var(--ks-gold);
}

.ks-all__count {
  font-weight: 500;
}

.ks-empty {
  padding: 22px 20px;
  text-align: center;
}

.ks-empty__title {
  margin: 0 0 4px;
  font-weight: 600;
}

.ks-empty__hint {
  margin: 0;
  color: var(--ks-muted);
  font-size: 13px;
}

.ks-option:focus-visible {
  outline: 2px solid var(--ks-gold);
  outline-offset: -2px;
}

/* Mobile: the widget lives in the theme's fixed search sheet, so the panel flows below the field. */
.ks-panel.ks-panel--mobile {
  position: static;
  width: 100%;
  margin-top: 10px;
  transform: none;
  border-radius: 10px;
  box-shadow: none;
}

.ks-panel--mobile .ks-panel__scroll {
  max-height: var(--ks-max-h, 70vh);
}

.ks-panel--mobile .ks-section {
  padding: 10px 6px 2px;
}

.ks-panel--mobile .ks-cats {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.ks-panel--mobile .ks-cat {
  min-height: 40px;
  flex: 0 0 auto;
}

.ks-panel--mobile .ks-product {
  grid-template-columns: 72px minmax(0, 1fr);
  grid-template-areas: "thumb body" "thumb prices";
  min-height: 88px;
  gap: 4px 12px;
}

.ks-panel--mobile .ks-product__thumb {
  grid-area: thumb;
  width: 72px;
  height: 72px;
}

.ks-panel--mobile .ks-product__body {
  grid-area: body;
}

.ks-panel--mobile .ks-product__prices {
  grid-area: prices;
  flex-direction: row;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px;
}

.ks-panel--mobile .ks-all {
  bottom: 0;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 575.98px) {
  .ks-product__name {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #search_widget .ks-progress::after {
    animation: none;
    left: 0;
    width: 100%;
  }
}
