/* ======================================
   HEMA SEARCH DRAWER - IMPROVED
   ====================================== */

.hd-search {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 86px;
  padding-left: 16px;
  padding-right: 16px;
  pointer-events: none;
}

.hd-search.is-active {
  pointer-events: auto;
}

.hd-search__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.hd-search.is-active .hd-search__overlay {
  opacity: 1;
}

/* PANEL */
.hd-search__panel {
  position: relative;
  width: 680px;
  max-width: 100%;
  max-height: calc(100vh - 86px - 32px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
  
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hd-search.is-active .hd-search__panel {
  transform: translateY(0);
  opacity: 1;
}

/* INNER */
.hd-search__inner {
  padding: 32px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

/* ======================================
   INPUT ROW
   ====================================== */

.hd-search__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.hd-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.hd-search__input {
  flex: 1;
  height: 56px;
  padding: 0 24px;
  border-radius: 999px;
  border: 2px solid #eee;
  background: #fafafa;
  font-family: var(--font-body);
  font-size: 16px;
  outline: none;
  transition: all 0.2s ease;
}

.hd-search__input:focus {
  border-color: #000;
  background: #fff;
}

.hd-search__close {
  height: 56px;
  width: 56px;
  border-radius: 999px;
  border: none;
  background: #f5f5f5;
  color: #000;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.hd-search__close:hover {
  background: #000;
  color: #fff;
  transform: rotate(90deg);
}

/* ======================================
   RESULTS (scrollable)
   ====================================== */

.hd-search__results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 20px;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hd-search__results::-webkit-scrollbar {
  width: 8px;
}

.hd-search__results::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
}

.hd-search__results::-webkit-scrollbar-track {
  background: transparent;
}

/* RESULT ITEM */
.hd-search-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  padding: 12px;
  transition: all 0.2s ease;
  position: relative;
}

.hd-search-item:hover,
.hd-search-item.is-active {
  background: #f5f5f5;
  transform: translateX(4px);
}

.hd-search-item__thumb {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  background: #fafafa;
  border: 1px solid #eee;
  flex-shrink: 0;
}

.hd-search-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hd-search-item__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hd-search-item__category {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}

.hd-search-item__title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  color: #000;
}

.hd-search-item__price {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-price);
  color: #000;
}

.hd-search-item__stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #16a34a;
  margin-top: 4px;
}

.hd-search-item__stock::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.hd-search-item__stock--out {
  color: #dc2626;
}

/* ======================================
   STATES (loading, empty, hint)
   ====================================== */

.hd-search-loading,
.hd-search-empty,
.hd-search-hint,
.hd-search-error {
  text-align: center;
  padding: 60px 24px;
  color: #666;
  font-size: 15px;
  line-height: 1.6;
}

.hd-search-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hd-search-loading::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid #eee;
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hd-search-empty strong,
.hd-search-hint strong {
  color: #000;
  font-weight: 600;
}

.hd-search-error {
  color: #dc2626;
}

/* VIEW ALL LINK */
.hd-search-footer {
  padding-top: 16px;
  border-top: 1px solid #eee;
  margin-top: 16px;
}

.hd-search-viewall {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: #000;
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
}

.hd-search-viewall:hover {
  background: #333;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ======================================
   MOBILE
   ====================================== */

@media (max-width: 768px) {
  .hd-search {
    padding-top: 72px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .hd-search__panel {
    width: 100%;
    max-height: calc(100vh - 72px - 16px);
    border-radius: 16px;
  }

  .hd-search__inner {
    padding: 20px;
  }

  .hd-search__head {
    padding-bottom: 16px;
  }

  .hd-search__input {
    height: 48px;
    padding: 0 20px;
    font-size: 16px;
  }

  .hd-search__close {
    height: 48px;
    width: 48px;
    font-size: 18px;
  }

  .hd-search-item {
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 10px;
  }

  .hd-search-item__thumb {
    width: 72px;
    height: 72px;
  }

  .hd-search-item__title {
    font-size: 14px;
  }

  .hd-search-item__price {
    font-size: 15px;
  }

  .hd-search-loading,
  .hd-search-empty,
  .hd-search-hint {
    padding: 40px 20px;
    font-size: 14px;
  }
}