/**
 * MatricaDiszkont – fejléc smart termékkereső dropdown
 * Verzió: 1.0.8 · STABIL – mobil fejléc audit + edge case fixek
 */

.md-header-search {
  --md-hs-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --md-hs-dur: 0.2s;
  position: relative;
  width: 100%;
}

.md-header-search__field {
  position: relative;
  width: 100%;
}

.md-header-search__input {
  width: 100%;
  transition:
    border-color var(--md-hs-dur) var(--md-hs-ease),
    box-shadow var(--md-hs-dur) var(--md-hs-ease);
}

.md-header-search__field:focus-within .md-header-search__input {
  border-color: rgba(74, 109, 146, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(74, 109, 146, 0.12);
}

.md-header-search__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 12050;
  max-height: min(70vh, 420px);
  overflow: auto;
  border: 1px solid rgba(74, 109, 146, 0.16);
  border-radius: 14px;
  background: #fff;
  box-shadow:
    0 18px 44px rgba(44, 62, 80, 0.14),
    0 4px 12px rgba(74, 109, 146, 0.08);
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.985);
  transform-origin: top center;
  pointer-events: none;
  transition:
    opacity var(--md-hs-dur) var(--md-hs-ease),
    transform 0.22s var(--md-hs-ease),
    visibility 0s linear var(--md-hs-dur);
}

.md-header-search__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition:
    opacity var(--md-hs-dur) var(--md-hs-ease),
    transform 0.22s var(--md-hs-ease),
    visibility 0s;
}

.md-header-search__panel[hidden]:not(.is-open) {
  display: block !important;
}

.md-header-search__panel[hidden].is-open {
  display: block !important;
}

.md-header-search__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none !important;
  color: #3d4654 !important;
  transition:
    background-color 0.16s ease,
    transform 0.16s var(--md-hs-ease);
}

.md-header-search__panel.is-open .md-header-search__item {
  animation: mdHsItemIn 0.22s var(--md-hs-ease) both;
}

.md-header-search__panel.is-open .md-header-search__item:nth-child(1) { animation-delay: 0.02s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(2) { animation-delay: 0.04s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(3) { animation-delay: 0.06s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(4) { animation-delay: 0.08s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(5) { animation-delay: 0.1s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(6) { animation-delay: 0.12s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(7) { animation-delay: 0.14s; }
.md-header-search__panel.is-open .md-header-search__item:nth-child(8) { animation-delay: 0.16s; }

.md-header-search__item:hover,
.md-header-search__item.is-active,
.md-header-search__item:focus-visible {
  background: rgba(232, 240, 247, 0.92);
  outline: none;
  transform: translateX(2px);
}

.md-header-search__thumb {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  background: #f4f7fb;
  border: 1px solid rgba(74, 109, 146, 0.1);
  transition: transform 0.18s var(--md-hs-ease);
}

.md-header-search__item:hover .md-header-search__thumb,
.md-header-search__item.is-active .md-header-search__thumb {
  transform: scale(1.04);
}

.md-header-search__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.md-header-search__thumb img.is-loaded {
  opacity: 1;
}

.md-header-search__thumb--empty {
  background: linear-gradient(135deg, #eef2f7, #f8fafc);
}

.md-header-search__copy {
  flex: 1 1 auto;
  min-width: 0;
}

.md-header-search__title {
  display: block;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: #3d4654;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md-header-search__price {
  display: inline-block;
  margin-top: 2px;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #2f6b4f;
}

.md-header-search__price--sale {
  margin-right: 8px;
}

.md-header-search__price--base {
  color: #7a8796;
  font-weight: 500;
  text-decoration: line-through;
}

.md-header-search__all {
  display: block;
  padding: 10px 14px 8px;
  border-top: 1px solid rgba(74, 109, 146, 0.1);
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: #4a6d92 !important;
  text-decoration: none !important;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.md-header-search__panel.is-open .md-header-search__all {
  animation: mdHsItemIn 0.22s var(--md-hs-ease) 0.12s both;
}

.md-header-search__all:hover {
  background: rgba(232, 240, 247, 0.72);
  color: #3d5a78 !important;
}

.md-header-search__loading,
.md-header-search__empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-family: 'Metropolis', system-ui, sans-serif;
  font-size: 0.88rem;
  color: #6b7585;
}

.md-header-search__panel.is-open .md-header-search__empty {
  animation: mdHsFadeIn 0.2s var(--md-hs-ease) both;
}

.md-header-search__dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.md-header-search__dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #4a6d92;
  opacity: 0.35;
  animation: mdHsDotPulse 0.9s ease-in-out infinite;
}

.md-header-search__dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.md-header-search__dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes mdHsItemIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mdHsFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes mdHsDotPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Awesomplete kikapcsolva – ne jelenjen meg dupla lista */
.md-header-search .awesomplete > ul {
  display: none !important;
}

#sp-top1 {
  overflow: visible !important;
}

#sp-top1 .sp-module,
#sp-top1 .sp-column {
  overflow: visible !important;
}

#sp-top1 .md-header-search__field {
  position: relative;
  z-index: 12060;
}

#sp-top1 .md-header-search__panel {
  z-index: 12070;
}

#sp-top1 .md-header-search .md-header-search__input {
  height: 40px;
  border-radius: 10px;
}

@media (max-width: 991.98px) {
  /*
   * Helix responsive.scss (max-width: 992px) elrejti #sp-top1-et – itt visszakapcsoljuk.
   * main.js moveHeader(): top-bar a headerbe kerül – kompakt 2 soros elrendezés.
   */
  #sp-top-bar {
    overflow: visible !important;
    padding: 6px 0 8px !important;
  }

  #sp-header {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    border-bottom: 1px solid #e5e5e5;
  }

  #sp-header #sp-top-bar {
    border-bottom: none !important;
    padding-bottom: 4px !important;
  }

  #sp-top-bar > .container > .container-inner > .row {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 6px;
    margin-left: 0;
    margin-right: 0;
  }

  #sp-top-bar #sp-logo {
    flex: 1 1 auto;
    order: 1;
    max-width: calc(100% - 132px);
  }

  #sp-top-bar #sp-top2 {
    flex: 0 0 auto;
    order: 2;
    margin-left: auto;
  }

  #sp-top-bar #sp-top1 {
    display: block !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    order: 3;
    margin-top: 0;
    padding: 0 8px 2px;
  }

  #sp-top-bar #sp-top1 .sp-column {
    text-align: left !important;
    padding: 0;
  }

  .md-mobile-search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .md-mobile-search-wrap {
    flex: 1 1 auto;
    min-width: 0;
  }

  .md-mobile-nav-slot {
    flex: 0 0 44px;
    width: 44px;
    align-self: center;
    overflow: visible;
  }

  .md-mobile-nav-slot .sp-module {
    width: 44px;
    height: 44px;
    margin: 0 !important;
    overflow: visible !important;
  }

  .md-mobile-nav-slot .sp-module-title {
    width: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0 !important;
    line-height: 44px !important;
    text-indent: -9999px;
    overflow: hidden;
    white-space: nowrap;
    border: 1px solid rgba(74, 109, 146, 0.22);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    display: block !important;
    position: relative !important;
  }

  /* Hamburger vonalak a gombon (theme.scss csak #sp-menu-left alatt ad :before/:after-et) */
  .md-mobile-nav-slot .sp-module:before,
  .md-mobile-nav-slot .sp-module:after {
    display: none !important;
  }

  .md-mobile-nav-slot .sp-module-title::before {
    content: "" !important;
    display: block !important;
    position: absolute;
    left: 11px;
    top: 13px;
    width: 22px;
    height: 10px;
    border-top: 2px solid #ff324d;
    border-bottom: 2px solid #ff324d;
    box-sizing: border-box;
    pointer-events: none;
  }

  .md-mobile-nav-slot .sp-module-title::after {
    content: "" !important;
    display: block !important;
    position: absolute;
    left: 11px;
    top: 21px;
    width: 22px;
    height: 0;
    border-bottom: 2px solid #ff324d;
    margin: 0 !important;
    font-size: 0 !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: none;
  }

  /* Zárva ne foglaljon helyet – különben fehér blokk takarja a termékeket */
  .md-mobile-nav-slot .sp-module-content {
    position: absolute !important;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    width: min(320px, calc(100vw - 24px)) !important;
    max-height: calc(100vh - 120px);
  }

  .md-mobile-nav-slot .sp-module-content:not(.categories-toggle) {
    max-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .md-mobile-nav-slot .sp-module-content.categories-toggle {
    max-height: min(calc(100vh - 120px), 520px) !important;
    padding: 36px 14px 14px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #sp-menu-left.md-mobile-nav-empty,
  #sp-header > .container > .container-inner > .row.md-mobile-header-row--collapsed {
    display: none !important;
  }

  #sp-top1 .mod-finder,
  #sp-top1 .md-header-search,
  #sp-top1 .md-header-search-host {
    width: 100%;
  }

  #sp-top1 .md-header-search .md-header-search__input,
  #sp-top1 .js-finder-search-query {
    height: 44px;
    font-size: 16px;
    border-radius: 12px;
  }

  #sp-header .sp-column {
    overflow: visible !important;
  }

  body.md-header-search-open {
    overflow: hidden;
  }

  .md-header-search__panel.is-open.md-header-search__panel--fixed {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    z-index: 12100;
    max-height: min(58vh, calc(100vh - var(--md-hs-panel-top, 120px) - 16px));
  }

  .md-header-search__title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .md-header-search__item:hover,
  .md-header-search__item.is-active {
    transform: none;
  }
}

@media (max-width: 767.98px) {
  .md-header-search__panel.is-open.md-header-search__panel--fixed {
    left: 12px;
    right: 12px;
    max-height: min(58vh, calc(100vh - var(--md-hs-panel-top, 120px) - 16px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .md-header-search__panel,
  .md-header-search__item,
  .md-header-search__thumb,
  .md-header-search__thumb img,
  .md-header-search__input,
  .md-header-search__all,
  .md-header-search__dots i {
    animation: none !important;
    transition: none !important;
  }

  .md-header-search__panel.is-open {
    opacity: 1;
    transform: none;
  }

  .md-header-search__thumb img.is-loaded {
    opacity: 1;
  }
}
