/**
 * Custom Tag Selector - Similar to manufacturer selector but without sorting
 */
.custom-tag-selector {
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: white;
  padding: 8px;
  min-height: 38px;
  position: relative;
  cursor: text;
  font-family: inherit;
}

.custom-tag-selector:focus-within {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.tag-selected-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
  max-width: 100%;
}

.tag-selected-item {
  display: flex;
  align-items: center;
  background-color: #007bff;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 300px; /* Prevent extremely wide tags */
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-selected-item-text {
  margin-right: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 20px); /* Account for remove button */
}

.tag-remove-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.tag-remove-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.tag-input-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tag-search-input {
  border: none;
  outline: none;
  flex-grow: 1;
  font-size: 14px;
  padding: 0;
  background: transparent;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-search-input::placeholder {
  color: #999;
}

.tag-counter {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.tag-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
}

.tag-dropdown.hidden {
  display: none;
}

.tag-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tag-dropdown-item:hover:not(.disabled) {
  background-color: #f8f9fa;
}

.tag-dropdown-item.disabled {
  cursor: not-allowed;
  color: #999;
  background-color: #f8f9fa;
}

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

/* Responsive adjustments */
@media (max-width: 576px) {
  .tag-selected-items {
    gap: 2px;
  }

  .tag-selected-item {
    font-size: 11px;
    padding: 1px 4px;
  }

  .tag-search-input {
    font-size: 13px;
  }
}

/* Loading state */
.tag-dropdown-item.loading {
  color: #999;
  font-style: italic;
}

/* Create new tag hint */
.tag-create-hint {
  font-size: 12px;
  color: #007bff;
  padding: 4px 8px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  margin-top: 4px;
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-create-hint .tag-create-name {
  display: inline-block;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.tag-create-hint.visible {
  display: block;
}

/* Create tag actions */
.tag-create-actions {
  margin-top: 8px;
  text-align: center;
}

.tag-create-actions.hidden {
  display: none;
}

.tag-create-btn {
  font-size: 12px;
  padding: 4px 12px;
}