/**
 * Fixperts - Search 컴포넌트 스타일
 * 재사용 가능한 검색창 컴포넌트 스타일
 */

.search {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* 헤더에서 사용될 때 */
.header__container .search {
  max-width: 500px;
  margin: 0;
  flex: 1;
}

.search__input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  border-radius: 24px;
  background: var(--color-bg-primary);
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.search__input {
  flex: 1;
  height: 44px;
  padding: 0 80px 0 54px; /* 오른쪽 패딩 증가 (버튼 공간 확보) */
  border: 1px solid rgba(223, 225, 229, 0);
  border-radius: 24px;
  border-top-right-radius: 0; /* 오른쪽 상단 모서리 제거 (버튼과 연결) */
  border-bottom-right-radius: 0; /* 오른쪽 하단 모서리 제거 (버튼과 연결) */
  font-size: var(--font-size-base);
  outline: none;
  transition: all var(--transition-fast);
  background: transparent; /* wrapper의 배경 사용 */
  box-shadow: none; /* wrapper의 shadow 사용 */
}

.search__input-wrapper:hover {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.search__input-wrapper:focus-within {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.search__input::placeholder {
  color: var(--color-search-text-secondary);
}

/* 포커스 시 placeholder 투명하게 */
.search__input:focus::placeholder {
  opacity: 0;
}

.search__input:focus::-webkit-input-placeholder {
  opacity: 0;
}

.search__input:focus::-moz-placeholder {
  opacity: 0;
}

.search__input:focus:-ms-input-placeholder {
  opacity: 0;
}

.search__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.search__icon-svg {
  width: 100%;
  height: 100%;
  fill: var(--color-search-icon);
}

.search__icon-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 검색 버튼 (검색창 안에 배치) */
.search__button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  height: 16px;
  padding: 0 5px;
  margin-right: 10px;
  border: none;
  border-radius: 18px; /* 검색창의 border-radius와 조화 */
  background: transparent; /* 배경색 제거 */
  color: var(--color-search-text-secondary); /* 기본 텍스트 색상 */
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.search__button:hover {
  color: var(--color-accent); /* 호버 시 텍스트 색상 */
}

.search__button:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

/* 자동완성 드롭다운 */
.search__dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-search-border);
  border-radius: 24px;
  box-shadow: 0 4px 6px rgba(32, 33, 36, 0.28);
  max-height: 500px;
  overflow-y: auto;
  z-index: var(--z-index-sticky);
}

.search__dropdown--visible {
  display: block;
}

.search__dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

.search__dropdown-item:hover,
.search__dropdown-item--selected {
  background-color: var(--color-search-bg-hover);
}

.search__dropdown-item:focus-visible {
  background-color: var(--color-search-bg-hover);
  outline: 2px solid var(--color-secondary);
  outline-offset: -2px;
}

.search__dropdown-item:first-child {
  border-radius: 24px 24px 0 0;
}

.search__dropdown-item:last-child {
  border-radius: 0 0 24px 24px;
}

/* 브랜드 로고 */
.search__brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

/* 제품 텍스트 (제품명 · 모델번호) */
.search__item-text {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  color: var(--color-search-text);
  font-weight: 400;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search__dropdown-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-search-text-tertiary);
  font-size: var(--font-size-sm);
}

/* ============================================
   반응형
   ============================================ */

@media (max-width: 768px) {
  .search__input {
    height: 48px;
    font-size: 15px;
    padding: 0 80px 0 52px; /* 오른쪽 패딩 증가 (버튼 공간 확보) */
  }

  .search__icon {
    left: 16px;
  }

  .search__button {
    height: 40px;
    padding: 0 14px;
    font-size: var(--font-size-xs);
    border-radius: 20px;
  }

  .header__container .search {
    max-width: none;
  }
}
