/* Mall Directory - Header Search
   Path: /wp-content/plugins/mall-directory/assets/css/md-header-search.css
*/

/* Root */
.md-header-search {
  position: relative;
  display: inline-flex;
  flex-direction: row-reverse; /* icon stays on the right, panel on the left */
  align-items: center;
  gap: 8px;                    /* keeps spacing so input never covers icon */
  line-height: 1;
  font: inherit;
}


/* Toggle button (search icon) */
.md-header-search .md-hs-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  border-radius: 999px;
  transition: background-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.md-header-search .md-hs-toggle:focus {
  outline: none;
}

.md-header-search .md-hs-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.md-header-search .md-hs-toggle:hover {
  background: rgba(0,0,0,0.06);
}

.md-header-search.is-open .md-hs-toggle {
  background: rgba(0,0,0,0.06);
}

/* Panel (expandable area) */
.md-header-search .md-hs-panel {
  position: relative;
  display: inline-block;
  min-width: 0;
}

/* Input wrapper */
.md-header-search .md-hs-inputwrap {
  display: flex;
  align-items: center;
  position: absolute;
  z-index: 5;
  top: -20px;
  right: 0px;

  /* Expand animation */
  max-width: 0;
  opacity: 0;
  transform: translateX(-6px); /* shift from right to left */
  pointer-events: none;

  transition: max-width 220ms ease, opacity 180ms ease, transform 220ms ease;
  will-change: max-width, opacity, transform;
}


/* Open state: expand */
.md-header-search.is-open .md-hs-inputwrap {
  max-width: 360px; /* desktop target width */
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

/* FIX: prevent hidden input from creating horizontal overflow */
.md-header-search .md-hs-inputwrap {
  overflow: hidden;
}



.md-hs-icon{
  height: 18px;
}

/* Input */
.md-header-search .md-hs-input {
  width: 180px;          /* matches max-width target */
  max-width: 360px;
  box-sizing: border-box;

  padding: 10px 36px 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.18);
  background: #fff;
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;

  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.md-header-search .md-hs-input::placeholder {
  opacity: 0.6;
}

.md-header-search .md-hs-input:focus {
  outline: none;
  border-color: rgba(0,0,0,0.35);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.08);
}

/* Clear button */
.md-header-search .md-hs-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 160ms ease, opacity 160ms ease;
}

.md-header-search .md-hs-clear:hover {
  background: rgba(0,0,0,0.06);
  opacity: 1;
}

.md-header-search .md-hs-clear:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Dropdown container */
.md-header-search .md-hs-dropdown {
  position: absolute;
  right: 0;     /* anchor to the right edge (near the icon) */
  left: auto;
  top: calc(100% + 25px);
  width: 100%;
  min-width: 240px;
  z-index: 9999;

  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);

  overflow: hidden;
}


/* Status line (loading/error) */
.md-header-search .md-hs-status {
  padding: 10px 12px;
  font-size: 12px;
  opacity: 0.8;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* Results list */
.md-header-search .md-hs-results {
  list-style: none;
  margin: 0;
  padding: 6px 0;

  max-height: 320px;
  overflow: auto;

  -webkit-overflow-scrolling: touch;
}

/* Item */
.md-header-search .md-hs-item {
  margin: 0;
  padding: 0;
}

.md-header-search .md-hs-link {
  display: flex;
  align-items: baseline;
  gap: 8px;

  padding: 10px 12px;
  text-decoration: none;
  color: inherit;

  transition: background-color 120ms ease;
}

.md-header-search .md-hs-title {
  font-size: 14px;
  font-weight: 600;
}

.md-header-search .md-hs-meta {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
}

/* Hover / active */
.md-header-search .md-hs-link:hover {
  background: rgba(0,0,0,0.05);
}

.md-header-search .md-hs-item.is-active .md-hs-link {
  background: rgba(0,0,0,0.08);
}

/* Empty state */
.md-header-search .md-hs-empty {
  padding: 10px 12px;
  font-size: 13px;
  opacity: 0.8;
}

/* Loading state (optional subtle) */
.md-header-search.is-loading .md-hs-input {
  background-color: rgba(0,0,0,0.02);
}

/* Dark headers: if your header is dark, you can add a wrapper class and override these:
   .header-dark .md-header-search .md-hs-input { background:#111; border-color:rgba(255,255,255,.2); color:#fff; }
*/

/* Responsive */
@media (max-width: 768px) {
  .md-header-search.is-open .md-hs-inputwrap {
    max-width: min(78vw, 420px);
  }
  .md-header-search .md-hs-input {
    width: min(78vw, 420px);
    max-width: min(78vw, 420px);
  }
}

@media (max-width: 480px) {
  /* On very small screens, dropdown should stay within viewport width */
  .md-header-search.is-open .md-hs-inputwrap {
    max-width: min(86vw, 420px);
  }
  .md-header-search .md-hs-input {
    width: min(86vw, 420px);
    max-width: min(86vw, 420px);
  }

  .md-header-search .md-hs-dropdown {
    min-width: 0;
    width: 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .md-header-search .md-hs-toggle,
  .md-header-search .md-hs-inputwrap,
  .md-header-search .md-hs-input,
  .md-header-search .md-hs-clear,
  .md-header-search .md-hs-link {
    transition: none !important;
  }
}
