/* =========================
   Ingredient Selector Component
   ========================= */

.ingredient-selector {
  position: relative;
  width: 100%;
}

.ingredient-input-wrapper {
  position: relative;
  width: 100%;
}

.ingredient-input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 14px;
  border: 1px solid var(--neutral-200);
  border-radius: 12px;
  background: var(--white);
  color: var(--neutral-900);
  font-size: 14px;
  outline: none;
  transition: box-shadow .2s, border-color .2s;
}

.ingredient-input:focus {
  box-shadow: var(--ring);
  border-color: var(--primary-500);
}

.ingredient-input:disabled {
  background: var(--neutral-50);
  color: var(--neutral-700);
  cursor: not-allowed;
}

.ingredient-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: var(--neutral-200);
  border-radius: 50%;
  color: var(--neutral-700);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  z-index: 2;
}

.ingredient-clear-btn:hover {
  background: var(--neutral-900);
  color: var(--white);
}

.ingredient-loading {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.ingredient-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--neutral-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Dropdown */
.ingredient-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 320px;
  background: var(--white);
  border: 1px solid var(--neutral-200);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  overflow-y: auto;
  z-index: 100;
  animation: dropdownSlideIn 0.2s ease-out;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ingredient-dropdown::-webkit-scrollbar {
  width: 8px;
}

.ingredient-dropdown::-webkit-scrollbar-track {
  background: var(--neutral-50);
  border-radius: 0 12px 12px 0;
}

.ingredient-dropdown::-webkit-scrollbar-thumb {
  background: var(--neutral-200);
  border-radius: 4px;
}

.ingredient-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-700);
}

/* Items */
.ingredient-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color .15s;
  border-bottom: 1px solid var(--neutral-200);
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-item:hover,
.ingredient-item.highlighted {
  background: var(--primary-50);
}

.ingredient-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--primary-500);
}

.ingredient-item-content {
  flex: 1;
  min-width: 0;
}

.ingredient-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--neutral-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.ingredient-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--neutral-700);
}

.ingredient-item-type {
  padding: 2px 8px;
  background: var(--neutral-50);
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ingredient-item-sep {
  color: var(--neutral-200);
}

.ingredient-item-pres {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.ingredient-empty {
  padding: 48px 24px;
  text-align: center;
}

.ingredient-empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
  color: var(--neutral-500);
  margin-left: auto;
  margin-right: auto;
}

.ingredient-empty-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--neutral-900);
  margin-bottom: 8px;
}

.ingredient-empty-hint {
  font-size: 12px;
  color: var(--neutral-700);
}

/* States */
.ingredient-selector.has-error .ingredient-input {
  border-color: #EF4444;
}

.ingredient-selector.has-error .ingredient-input:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.ingredient-item-icon svg,
.ingredient-empty-icon svg,
.ingredient-clear-btn svg {
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
  .ingredient-dropdown {
    max-height: 240px;
  }

  .ingredient-item {
    padding: 10px 12px;
  }

  .ingredient-item-name {
    font-size: 13px;
  }

  .ingredient-item-meta {
    font-size: 11px;
  }
}
