:root {
  --width-search-small: 300px;
  --width-search-large: 600px;
}

.search {
  width: 100%;
  position: relative;
}

.search--small {
  max-width: var(--width-search-small);
}

.search--large {
  max-width: var(--width-search-large);
}

.search__container {
  position: relative;
  width: 100%;
}

.search__input {
  width: 100%;
  padding: 8px 40px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease;
}

.search__input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.search__container--large .search__input {
  padding: 12px 48px;
  font-size: 20px;
}

.search__input:focus {
  border-color: #3b82f6;
}

.search__icon,
.search__clear,
.search__loading {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
}

.search__icon {
  left: 12px;
  color: #64748b;
}

.search__container--large .search__icon {
  left: 16px;
}

.search__loading {
  right: 12px;
}

.search__container--large .search__loading {
  right: 16px;
}

.search__clear {
  right: 12px;
  color: #64748b;
  cursor: pointer;
  background-color: none;
  border: none;
  padding: 0;
}

.search__container--large .search__clear {
  right: 16px;
}

.spinner {
  animation: rotate 1s linear infinite;
  width: 20px;
  height: 20px;
}

.spinner circle {
  stroke: #3b82f6;
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

.search__results {
  position: absolute;
  left: 0;
  right: 0;
  margin-top: 8px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  max-height: 340px;
  overflow-y: auto;
  z-index: 50;

  width: 100%;
  min-width: fit-content;
}

.search__result-item {
  display: flex;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search__result-item:hover {
  background-color: #f8fafc;
}

.search__result-image {
  width: 60px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 12px;
}

.search__result-title {
  font-size: 14px;
  color: #1e293b;
}

.search__result-original {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

@media (prefers-color-scheme: dark) {
  .search__input {
    background-color: #343a40;
    border-color: #495057;
    color: #f8f9fa;
  }

  .search__input:focus {
    border-color: #228be6;
  }

  .search__icon,
  .search__clear {
    color: #adb5bd;
  }

  .spinner circle {
    stroke: #228be6;
  }

  .search__results {
    background-color: #343a40;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  }

  .search__result-item:hover {
    background-color: #495057;
  }

  .search__result-title {
    color: #f8f9fa;
  }

  .search__result-original {
    color: #adb5bd;
  }
}