.ztp-barcode-search-module {
  position: relative;
  max-width: 620px;
  margin: 15px 0;
}

.ztp-barcode-search-line {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.ztp-barcode-search-line .ztp-barcode-input {
  min-width: 0;
  flex: 1 1 auto;
}

.ztp-barcode-search-line button {
  flex: 0 0 auto;
}

.ztp-barcode-result {
  position: relative;
  z-index: 20;
  margin-top: 8px;
  border-radius: 4px;
}

/* Match UniShop's live-search dropdown under both desktop and mobile search. */
.header-search {
  position: relative;
}

.header-search > .ztp-barcode-result {
  position: absolute;
  z-index: 10010;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 70vh;
  margin: 0;
  overflow-y: auto;
}

.ztp-barcode-result:empty {
  display: none;
}

.ztp-barcode-result-success {
  padding: 12px;
  background: #fff;
  border: 1px solid #ddd;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
}

.ztp-barcode-result-warning,
.ztp-barcode-result-error,
.ztp-barcode-result-info,
.ztp-barcode-result-loading {
  padding: 10px 12px;
  background: #fff8e1;
  border: 1px solid #f0d27a;
}

.ztp-barcode-result-error {
  background: #fff1f0;
  border-color: #e7aaa5;
}

.ztp-barcode-result-heading {
  margin: 0 0 10px;
  font-weight: 600;
}

.ztp-barcode-products {
  display: grid;
  gap: 12px;
}

.ztp-barcode-product {
  display: flex;
  gap: 14px;
  min-width: 0;
}

.ztp-barcode-product-image {
  display: block;
  flex: 0 0 120px;
  width: 120px;
  height: 120px;
  text-align: center;
}

.ztp-barcode-product-image img {
  max-width: 100%;
  max-height: 100%;
}

.ztp-barcode-product-info {
  min-width: 0;
  flex: 1 1 auto;
}

.ztp-barcode-product-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}

.ztp-barcode-product-actions .btn {
  margin: 0;
}

.ztp-barcode-add-to-cart.is-loading {
  opacity: .7;
  pointer-events: none;
}

.ztp-barcode-add-to-cart.is-added {
  background: #268a3b;
  border-color: #268a3b;
}

.ztp-barcode-add-to-cart.is-in-cart {
  background: #268a3b;
  border-color: #268a3b;
}

.ztp-barcode-add-to-cart .fa {
  margin-right: 5px;
}

.ztp-barcode-cart-message {
  flex: 1 0 100%;
  margin-top: 2px;
  color: #268a3b;
  font-size: 12px;
}

.ztp-barcode-cart-message.is-error {
  color: #a33a32;
}

.ztp-barcode-product-name {
  display: block;
  margin-bottom: 5px;
  font-size: 16px;
  font-weight: 600;
}

.ztp-barcode-price {
  margin: 4px 0;
  font-size: 16px;
}

.ztp-barcode-price del {
  margin-right: 5px;
  color: #888;
  font-size: 13px;
}

.ztp-barcode-stock {
  margin: 4px 0;
  font-size: 13px;
}

.ztp-barcode-stock.in-stock {
  color: #268a3b;
}

.ztp-barcode-stock.out-stock {
  color: #a33a32;
}

.ztp-barcode-meta {
  margin: 4px 0 8px;
  color: #777;
  font-size: 12px;
}

.ztp-barcode-gallery {
  display: flex;
  gap: 5px;
  margin: 8px 0;
}

.ztp-barcode-gallery-image {
  width: 34px;
  height: 34px;
  object-fit: cover;
  border: 1px solid #ddd;
}

.ztp-barcode-result-close {
  position: absolute;
  top: 3px;
  right: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #777;
  font-size: 24px;
  line-height: 24px;
}

.ztp-barcode-scanner {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .75);
}

.ztp-barcode-scanner-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.ztp-barcode-scanner-title {
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 600;
}

.ztp-barcode-scanner-close {
  position: absolute;
  top: 6px;
  right: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #777;
  font-size: 28px;
  line-height: 28px;
}

.ztp-barcode-video {
  display: block;
  width: 100%;
  min-height: 220px;
  max-height: 60vh;
  border-radius: 5px;
  background: #111;
  object-fit: cover;
}

.ztp-barcode-scanner-status {
  min-height: 22px;
  margin: 10px 0;
  color: #555;
}

.ztp-barcode-file-label {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.ztp-barcode-file-input {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 100%;
  min-height: 100%;
  opacity: 0;
  cursor: pointer;
}

.ztp-barcode-scanner-hint {
  margin-top: 9px;
  color: #888;
  font-size: 11px;
}

.ztp-barcode-open {
  margin-left: 4px;
}

/* UniShop2: search.twig places the search button absolutely on the right. */
body .header-search__form .ztp-barcode-open {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: 41px;
  width: 40px;
  height: calc(100% - 2px);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  transform: translateY(-50%);
}

body .header-search__form .ztp-barcode-open:hover,
body .header-search__form .ztp-barcode-open:focus {
  background: rgba(0, 0, 0, .06);
}

body .header-search__form .header-search__input {
  padding-right: 88px;
}

body .header-search .search-btn-clear {
  right: 85px;
}

.ztp-scan-icon {
  display: inline-flex;
  width: 24px;
  height: 20px;
  vertical-align: middle;
  line-height: 1;
}

.ztp-scan-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ztp-barcode-open .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#ztp-barcode-search-root {
  display: none !important;
}

@media (max-width: 480px) {
  .ztp-barcode-open {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 11px;
    border-color: #d4af37;
    background: #d4af37;
    color: #fff;
  }

  body .header-search__form .ztp-barcode-open {
    min-width: 40px;
    min-height: 0;
    border: 0;
    background: #d4af37;
    color: #fff;
  }

  body .header-search__form .ztp-barcode-open:hover,
  body .header-search__form .ztp-barcode-open:focus {
    background: #c49e2c;
  }

  .ztp-barcode-product {
    gap: 9px;
  }

  .ztp-barcode-product-image {
    flex-basis: 84px;
    width: 84px;
    height: 84px;
  }

  .ztp-barcode-scanner-panel {
    padding: 16px 12px;
  }
}
