/* Header search action button */
.header-v4 .menu-cart-container .search-trigger-desktop {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d8e0f0;
  background: #f6f8fd;
  color: #2d3553;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-v4 .menu-cart-container .search-trigger-desktop i {
  font-size: 19px;
  line-height: 1;
}

.header-v4 .menu-cart-container .search-trigger-desktop:hover {
  background: #edf2ff;
  border-color: #bcc8eb;
  color: #4256a1;
}

.header-v4 .menu-cart-container .search-trigger-desktop:focus-visible {
  outline: 2px solid #b8c4ea;
  outline-offset: 2px;
}

/* Keep desktop clean, mobile uses existing icon-header search trigger */
@media (max-width: 991px) {
  .header-v4 .menu-cart-container .search-trigger-desktop {
    display: none;
  }
}

/* Search modal */
.modal-search-header {
  position: fixed;
  inset: 0;
  z-index: 10020;
  background: rgba(12, 16, 31, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-search-header.show-modal-search {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.container-search-header {
  width: min(760px, 100%);
  position: relative;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e6eaf3;
  box-shadow: 0 20px 50px rgba(15, 25, 54, 0.2);
  padding: 18px;
  overflow: visible;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-search-header.show-modal-search .container-search-header {
  transform: translateY(0);
}

.btn-hide-modal-search {
  position: absolute;
  right: -12px;
  top: -12px;
  width: 36px;
  height: 36px;
  border: 1px solid #e1e6f2;
  border-radius: 50%;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(39, 61, 133, 0.18);
}

.btn-hide-modal-search img {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.btn-hide-modal-search:hover {
  background: #f5f8ff;
  border-color: #b9c6ed;
}

.wrap-search-header {
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid #d8deec;
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  position: relative;
}

.wrap-search-header:focus-within {
  border-color: #aebde8;
  box-shadow: 0 0 0 3px rgba(88, 119, 204, 0.15);
}

.wrap-search-header .search-submit-btn {
  min-width: 112px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: #eef2fb;
  color: #4256a1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 8px;
  padding: 0 16px;
  transition: background-color 0.2s ease, color 0.2s ease;
  order: 3;
  margin-left: auto;
}

.wrap-search-header .search-submit-btn:hover {
  background: #dfe7fb;
}

.wrap-search-header .search-submit-btn .search-submit-text {
  font-family: Poppins-Medium;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.wrap-search-header input {
  width: auto;
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1d233d;
  font-family: Poppins-Regular;
  font-size: 18px;
  line-height: 1.3;
  padding: 0 12px;
  order: 1;
}

.wrap-search-header input::placeholder {
  color: #7a839f;
}

.wrap-search-header input[readonly] {
  cursor: progress;
}

.wrap-search-header .search-clear-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f4f6fc;
  color: #6673a5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9);
  pointer-events: none;
  transition: all 0.2s ease;
  order: 2;
}

.wrap-search-header.has-value .search-clear-btn {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  pointer-events: auto;
}

.wrap-search-header .search-clear-btn:hover {
  background: #e6ecfb;
  color: #4256a1;
}

.search-feedback {
  margin: 10px 2px 0;
  min-height: 18px;
  font-family: Poppins-Regular;
  font-size: 13px;
  color: #6f7898;
}

.search-suggestions {
  margin-top: 10px;
  border: 1px solid #dbe3f5;
  background: #fff;
  border-radius: 12px;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.search-suggestions.is-visible {
  display: block;
}

.search-suggestions.is-busy {
  position: relative;
}

.search-suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #edf1fb;
  text-decoration: none;
}

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

.search-suggestion-item .search-suggestion-text {
  font-family: Poppins-Medium;
  font-size: 14px;
  color: #2a3356;
}

.search-suggestion-item .search-suggestion-meta {
  font-family: Poppins-Regular;
  font-size: 11px;
  color: #7e88a9;
  white-space: nowrap;
}

.search-suggestion-item:hover {
  background: #f3f6ff;
}

.search-suggestion-item.is-active,
.search-suggestion-item:focus-visible {
  background: #eaf0ff;
  outline: none;
  box-shadow: inset 0 0 0 1px #bfd0fb;
}

.search-suggestion-item.is-query .search-suggestion-text {
  color: #4156a0;
}

.search-suggestion-empty {
  padding: 12px;
  font-family: Poppins-Regular;
  font-size: 13px;
  color: #6f7898;
}

.search-suggestion-empty.is-loading {
  color: #4256a1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-suggestion-empty.is-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid #d9e1f7;
  border-top-color: #4256a1;
  border-radius: 50%;
  animation: search-spin 0.8s linear infinite;
  flex: 0 0 14px;
}

.search-feedback.is-ready {
  color: #4256a1;
}

.search-feedback.is-warning {
  color: #c25b1b;
}

.search-feedback.is-loading {
  color: #34407d;
}

.search-feedback.is-success {
  color: #1f6d46;
}

.js-search-form.is-loading .search-submit-btn {
  pointer-events: none;
  opacity: 0.9;
  filter: saturate(0.9);
  position: relative;
  padding-right: 34px;
}

.js-search-form.is-loading .search-submit-icon {
  animation: none;
}

.js-search-form.is-loading .search-submit-btn::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid rgba(66, 86, 161, 0.25);
  border-top-color: #4256a1;
  border-radius: 50%;
  animation: search-spin 0.75s linear infinite;
}

@keyframes search-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 767px) {
  .modal-search-header {
    align-items: flex-start;
    padding: max(14px, calc(env(safe-area-inset-top) + 10px)) 14px
      max(14px, calc(env(safe-area-inset-bottom) + 10px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .container-search-header {
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
  }

  .wrap-search-header input,
  .wrap-search-header button {
    font-size: 30px;
  }

  .wrap-search-header {
    height: 90px;
  }
}

@media (max-width: 575px) {
  .modal-search-header {
    padding-right: 12px;
    padding-left: 12px;
  }

  .container-search-header {
    padding: 14px;
    border-radius: 14px;
  }

  .btn-hide-modal-search {
    right: -8px;
    top: -8px;
    width: 34px;
    height: 34px;
  }

  .wrap-search-header .search-submit-btn {
    min-width: 44px;
    padding: 0;
  }

  .wrap-search-header .search-submit-btn .search-submit-text {
    display: none;
  }

  .wrap-search-header input {
    font-size: 16px;
  }
}
