/* Global search UI */
.navbar-mk {
  overflow: visible;
}

.navbar-mk .container,
.navbar-mk .container-fluid,
.navbar-mk .navbar-collapse,
.navbar-mk .mk-navbar-actions {
  overflow: visible;
}

.mk-search-nav-slot {
  min-width: 0;
  position: relative;
  transition: width 0.2s ease, max-width 0.2s ease;
}

.mk-search-nav-slot--desktop {
  flex: 0 0 auto;
  width: 168px;
  max-width: 168px;
}

.mk-search-nav-slot--desktop.is-expanded {
  width: 220px;
  max-width: 220px;
}

.mk-search-nav-slot--mobile {
  flex: 1 1 auto;
  max-width: min(180px, 42vw);
  min-width: 110px;
}

.mk-search-wrap {
  min-width: 0;
  max-width: none;
  width: 100%;
  position: relative;
}

.mk-search-input-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mk-search-input-group:focus-within {
  border-color: var(--primary, #D97706);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.mk-search-input-group .bi-search {
  color: #9ca3af;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.mk-search-input-group .form-control {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  width: 100%;
  font-size: 0.875rem;
  min-width: 0;
  line-height: 1.4;
}

.mk-search-input-group .form-control::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* Dropdown — default (inline) */
.mk-search-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  z-index: 1080;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.85rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  max-height: 320px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Navbar dropdown — wider panel, right-aligned */
.mk-search-dropdown--nav {
  left: auto;
  right: 0;
  width: min(340px, calc(100vw - 2rem));
  min-width: 300px;
  max-height: min(380px, calc(100vh - 120px));
}

.mk-search-results-list {
  overflow-y: auto;
  max-height: 280px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.mk-search-quick {
  padding: 0.85rem 0.85rem 0.65rem;
}

.mk-search-quick .mk-search-chips {
  padding-bottom: 0.65rem;
}

.mk-search-browse-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary, #D97706);
  text-decoration: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.mk-search-browse-link:hover {
  background: rgba(217, 119, 6, 0.05);
  color: var(--primary, #D97706);
}

.mk-search-suggestion {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.12s ease;
}

.mk-search-suggestion:last-child {
  border-bottom: 0;
}

.mk-search-suggestion:hover {
  background: rgba(217, 119, 6, 0.06);
}

.mk-search-suggestion-thumb {
  width: 44px;
  height: 44px;
  border-radius: 0.5rem;
  overflow: hidden;
  flex-shrink: 0;
  background: #f3f4f6;
}

.mk-search-suggestion-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mk-search-suggestion-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  font-size: 1.1rem;
}

.mk-search-suggestion-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.mk-search-suggestion-name {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mk-search-suggestion-meta {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mk-search-view-all {
  display: block;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary, #D97706);
  text-decoration: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.mk-search-view-all:hover {
  background: rgba(217, 119, 6, 0.05);
}

.mk-search-empty,
.mk-search-loading {
  padding: 1.25rem 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

.mk-search-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.mk-search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mk-search-chip {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #374151;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.mk-search-chip:hover {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.3);
  color: #1f2937;
}

.mk-search-mobile {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.mk-search-page-filters {
  position: sticky;
  top: calc(var(--mk-header-offset, 5rem) + 0.5rem);
}

/* ========== Search results page ========== */
.mk-search-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: clip;
}

.mk-search-page-main {
  flex: 1 1 auto;
  padding: 1.25rem 0 2.5rem;
  min-width: 0;
}

.mk-search-page-layout > [class*="col-"] {
  min-width: 0;
}

.mk-search-page-header .emoji {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.mk-search-page-bar {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.mk-search-page-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 0.4rem 0.5rem 0.4rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.mk-search-page-bar-inner:focus-within {
  border-color: var(--primary, #D97706);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.mk-search-page-bar-inner .bi-search {
  color: #9ca3af;
  flex-shrink: 0;
}

.mk-search-page-bar-inner .form-control {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0.35rem 0;
  font-size: 1rem;
  min-width: 0;
}

.mk-search-page-bar-inner .btn {
  border-radius: 999px;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.mk-search-page-submit__icon {
  display: none;
}

.mk-search-page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.mk-search-page-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.mk-search-page-sort {
  min-width: 0;
}

.mk-search-page-summary {
  color: rgba(26, 46, 18, 0.82);
  font-size: 0.92rem;
}

.mk-search-page-layout {
  align-items: flex-start;
}

/* Filter panel — hidden until moved into sidebar or offcanvas */
body.mk-search-page #searchFiltersPanel {
  display: none;
}

#searchFiltersDesktopHost #searchFiltersPanel,
#searchFiltersMobileHost #searchFiltersPanel {
  display: block;
}

.mk-search-filter-toggle {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* Mobile filter bottom sheet */
.mk-search-filters-offcanvas {
  --bs-offcanvas-height: min(85vh, 640px);
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
}

.mk-search-filters-offcanvas .offcanvas-header {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.mk-search-filters-offcanvas .offcanvas-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mk-search-filters-offcanvas .offcanvas-footer {
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.mk-search-page-filters--mobile {
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.mk-search-page-filters--mobile .mk-search-filters-heading {
  display: none;
}

.mk-search-page-filters--mobile .card-body {
  padding: 1rem 1.25rem 1.25rem !important;
}

.mk-search-page-filters--mobile .form-select,
.mk-search-page-filters--mobile .form-control {
  min-height: 44px;
  font-size: 16px;
}

.mk-search-page-filters--mobile .form-check-input {
  width: 1.15rem;
  height: 1.15rem;
}

.mk-search-sort-select {
  min-width: 10rem;
}

.mk-search-results-grid {
  width: 100%;
}

.mk-search-empty-state {
  max-width: 360px;
}

/* Result cards */
.mk-search-result-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mk-search-result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}

.mk-search-card-link {
  display: block;
  text-decoration: none;
}

.mk-search-card-media {
  aspect-ratio: 4 / 3;
  background: linear-gradient(145deg, #f9fafb 0%, #f3f4f6 100%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mk-search-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mk-search-card-media--empty {
  color: #d1d5db;
  font-size: 2.5rem;
}

.mk-search-card-body {
  padding: 1rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0.5rem;
}

.mk-search-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.mk-search-card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  word-break: break-word;
}

.mk-search-card-price {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.mk-search-card-price-old {
  font-size: 0.8125rem;
  color: #9ca3af;
  text-decoration: line-through;
}

.mk-search-card-price-now {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--primary, #D97706);
}

.mk-search-card-desc {
  font-size: 0.8125rem;
  color: #6b7280;
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mk-search-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.mk-search-card-badges .badge {
  font-size: 0.6875rem;
  font-weight: 600;
}

.mk-search-card-delivery {
  font-size: 0.75rem;
  color: #6b7280;
  margin: 0;
}

.mk-search-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.mk-search-card-actions .btn {
  min-height: 40px;
}

.mk-search-card-actions .btn-outline-secondary {
  width: 40px;
  padding-left: 0;
  padding-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Hide redundant navbar mini-search on search page */
.mk-search-page .mk-search-nav-slot {
  display: none !important;
}

@media (min-width: 768px) {
  .mk-search-card-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .mk-search-card-price {
    flex-shrink: 0;
    text-align: right;
  }
}

@media (max-width: 575.98px) {
  .mk-search-card-actions {
    flex-wrap: wrap;
  }

  .mk-search-card-actions .btn-primary-mk {
    flex: 1 1 100%;
  }
}

@media (max-width: 767.98px) {
  .mk-search-page-filters {
    position: static;
  }

  .mk-search-page-main {
    padding-top: 1rem;
  }

  .mk-search-input-group .form-control {
    min-height: 40px;
    font-size: 16px;
  }

  .mk-search-page-header .h2 {
    font-size: 1.35rem;
  }
}

@media (min-width: 992px) {
  .mk-search-nav-slot--desktop {
    width: 180px;
    max-width: 180px;
  }

  .mk-search-nav-slot--desktop.is-expanded {
    width: 240px;
    max-width: 240px;
  }
}

@media (max-width: 991.98px) {
  .mk-search-dropdown--nav {
    position: fixed;
    top: calc(var(--mk-header-offset, 4.5rem) + 0.25rem);
    left: 1rem;
    right: 1rem;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  body.mk-search-page.mk-has-mobile-dock {
    padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  }

  .mk-search-page-container {
    max-width: 100%;
    padding-left: max(0.65rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.65rem, env(safe-area-inset-right, 0px));
  }

  .mk-search-page-main {
    padding-top: 0.65rem;
    padding-bottom: 1.5rem;
  }

  .mk-search-page-header {
    text-align: left;
    margin-bottom: 0.75rem !important;
  }

  .mk-search-page-header .emoji,
  .mk-search-page-header__sub {
    display: none;
  }

  .mk-search-page-header .h2 {
    font-size: 1.15rem;
    margin-bottom: 0 !important;
    font-family: Georgia, "Times New Roman", serif;
    color: #1a2e12;
  }

  .mk-search-page-bar {
    position: sticky;
    top: calc(var(--mk-header-offset, 4.5rem) + 0.25rem);
    z-index: 1015;
    max-width: none;
    margin-bottom: 0.75rem;
  }

  .mk-search-page-bar-inner {
    flex-wrap: nowrap;
    border-radius: 0.9rem;
    padding: 0.35rem 0.4rem 0.35rem 0.75rem;
    gap: 0.45rem;
    box-shadow: 0 2px 12px rgba(10, 46, 0, 0.08);
  }

  .mk-search-page-bar-inner .form-control {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
    min-height: 2.5rem;
    padding: 0.25rem 0;
  }

  .mk-search-page-submit {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    padding: 0 !important;
    border-radius: 50% !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mk-search-page-submit__label {
    display: none;
  }

  .mk-search-page-submit__icon {
    display: inline-block;
    font-size: 1rem;
  }

  .mk-search-page-toolbar {
    gap: 0.5rem;
  }

  .mk-search-page-summary {
    flex: 1 1 100%;
    font-size: 0.84rem;
  }

  .mk-search-page-toolbar__actions {
    width: 100%;
    justify-content: space-between;
  }

  .mk-search-filter-toggle {
    min-height: 2.35rem;
    border-radius: 999px;
    padding-left: 0.75rem;
    padding-right: 0.85rem;
    gap: 0.35rem;
    display: inline-flex;
    align-items: center;
  }

  .mk-search-filter-toggle__label {
    font-size: 0.82rem;
  }

  .mk-search-page-sort {
    flex: 1 1 auto;
    max-width: 11rem;
  }

  .mk-search-sort-select {
    min-width: 0;
    width: 100%;
    min-height: 2.35rem;
    border-radius: 999px;
    font-size: 0.82rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
  }

  .mk-search-results-grid {
    --bs-gutter-x: 0.55rem;
    --bs-gutter-y: 0.65rem;
  }

  .mk-search-results-grid > .col-12.col-sm-6,
  .mk-search-results-grid > .col-6,
  .mk-search-results-grid > .col-md-4,
  .mk-search-results-grid > .col-lg-3 {
    flex: 0 0 50%;
    max-width: 50%;
    padding-left: calc(var(--bs-gutter-x) * 0.5);
    padding-right: calc(var(--bs-gutter-x) * 0.5);
  }

  .mk-search-results-grid .mk-home-card__slot-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
  }

  .mk-search-results-grid .mk-home-card__slot-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.18rem 0.55rem;
    font-size: 0.62rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--mk-green, #3d5229);
    border-color: var(--mk-green, #3d5229);
    color: #fff;
  }

  .mk-search-results-grid .mk-home-card__footer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "price price"
      "wishlist actions";
    gap: 0.35rem;
    width: 100%;
    align-items: center;
    min-width: 0;
  }

  .mk-search-results-grid .mk-home-card__price {
    grid-area: price;
    width: 100%;
    min-width: 0;
  }

  .mk-search-results-grid .mk-home-card__wishlist {
    grid-area: wishlist;
  }

  .mk-search-results-grid .mk-weekly-card__cart-wrap {
    grid-area: actions;
    justify-self: end;
    margin-left: 0;
    max-width: 100%;
  }

  .mk-search-results-grid .mk-weekly-qty {
    min-width: 0;
    max-width: 4.85rem;
    height: 1.75rem;
    padding: 0 0.08rem;
  }

  .mk-search-results-grid .mk-weekly-qty__btn {
    width: 1.45rem;
    font-size: 0.9rem;
  }

  .mk-search-results-grid .mk-weekly-qty__value {
    min-width: 0.75rem;
    font-size: 0.8rem;
  }
}

/* Mobile search sheet (header search icon) */
body.mk-mobile-search-open {
  overflow: hidden;
}

.mk-mobile-search {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

.mk-mobile-search[hidden] {
  display: none !important;
}

.mk-mobile-search__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 46, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
}

.mk-mobile-search__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-height: min(88dvh, 720px);
  background: #fffdf9;
  border-radius: 1.1rem 1.1rem 0 0;
  box-shadow: 0 -12px 40px rgba(10, 46, 0, 0.16);
  pointer-events: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mk-mobile-search__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.65rem;
  border-bottom: 1px solid rgba(61, 82, 41, 0.1);
}

.mk-mobile-search__input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #fff;
  border: 1px solid rgba(61, 82, 41, 0.14);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}

.mk-mobile-search__input-wrap:focus-within {
  border-color: var(--mk-orange, #d97706);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.mk-mobile-search__input-wrap .bi-search {
  color: #9ca3af;
  flex-shrink: 0;
}

.mk-mobile-search__input-wrap .form-control {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  min-height: 1.5rem;
  font-size: 16px;
}

.mk-mobile-search__close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--mk-green, #3d5229);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.35rem 0.15rem;
}

.mk-mobile-search__results {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 12rem;
  max-height: calc(min(88dvh, 720px) - 4.5rem);
}

.mk-mobile-search__results .mk-search-results-list {
  max-height: none;
}

.mk-mobile-search__results .mk-search-suggestion {
  padding: 0.75rem 0.85rem;
}

.mk-mobile-search__results .mk-search-view-all {
  display: block;
  padding: 0.85rem;
  text-align: center;
  font-weight: 600;
  color: var(--mk-green, #3d5229);
  text-decoration: none;
  border-top: 1px solid rgba(61, 82, 41, 0.08);
}
